2005-04-18 21:15:10 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-06-09 01:38:20 +02:00
|
|
|
# Copyright (c) Linus Torvalds, 2005
|
|
|
|
#
|
|
|
|
# This is the git per-file merge script, called with
|
2005-04-18 21:15:10 +02:00
|
|
|
#
|
2005-04-18 23:17:58 +02:00
|
|
|
# $1 - original file SHA1 (or empty)
|
|
|
|
# $2 - file in branch1 SHA1 (or empty)
|
|
|
|
# $3 - file in branch2 SHA1 (or empty)
|
2005-04-18 21:15:10 +02:00
|
|
|
# $4 - pathname in repository
|
2005-05-02 08:53:32 +02:00
|
|
|
# $5 - orignal file mode (or empty)
|
|
|
|
# $6 - file in branch1 mode (or empty)
|
|
|
|
# $7 - file in branch2 mode (or empty)
|
2005-04-18 21:15:10 +02:00
|
|
|
#
|
2005-04-18 23:17:58 +02:00
|
|
|
# Handle some trivial cases.. The _really_ trivial cases have
|
2005-04-30 01:25:05 +02:00
|
|
|
# been handled already by git-read-tree, but that one doesn't
|
2005-06-09 01:38:20 +02:00
|
|
|
# do any merges that might change the tree layout.
|
2005-04-19 04:55:19 +02:00
|
|
|
|
2005-04-18 23:17:58 +02:00
|
|
|
case "${1:-.}${2:-.}${3:-.}" in
|
2005-04-18 21:15:10 +02:00
|
|
|
#
|
2005-06-09 02:56:09 +02:00
|
|
|
# Deleted in both or deleted in one and unchanged in the other
|
2005-04-18 21:15:10 +02:00
|
|
|
#
|
2005-06-09 02:56:09 +02:00
|
|
|
"$1.." | "$1.$1" | "$1$1.")
|
2005-04-24 05:50:10 +02:00
|
|
|
echo "Removing $4"
|
2005-07-29 11:00:45 +02:00
|
|
|
if test -f "$4"; then
|
2005-06-25 11:24:50 +02:00
|
|
|
rm -f -- "$4"
|
|
|
|
fi &&
|
2005-07-29 11:00:45 +02:00
|
|
|
exec git-update-cache --remove -- "$4"
|
2005-06-09 01:38:20 +02:00
|
|
|
;;
|
|
|
|
|
2005-04-18 21:15:10 +02:00
|
|
|
#
|
2005-05-02 08:53:32 +02:00
|
|
|
# Added in one.
|
2005-04-18 21:15:10 +02:00
|
|
|
#
|
2005-04-24 05:50:10 +02:00
|
|
|
".$2." | "..$3" )
|
2005-06-09 02:56:09 +02:00
|
|
|
echo "Adding $4"
|
|
|
|
git-update-cache --add --cacheinfo "$6$7" "$2$3" "$4" &&
|
|
|
|
exec git-checkout-cache -u -f -- "$4"
|
2005-06-09 01:38:20 +02:00
|
|
|
;;
|
|
|
|
|
2005-04-24 05:50:10 +02:00
|
|
|
#
|
2005-05-02 08:53:32 +02:00
|
|
|
# Added in both (check for same permissions).
|
2005-04-24 05:50:10 +02:00
|
|
|
#
|
2005-05-02 08:53:32 +02:00
|
|
|
".$3$2")
|
2005-04-24 05:50:10 +02:00
|
|
|
if [ "$6" != "$7" ]; then
|
2005-05-02 08:53:32 +02:00
|
|
|
echo "ERROR: File $4 added identically in both branches,"
|
|
|
|
echo "ERROR: but permissions conflict $6->$7."
|
2005-04-24 05:50:10 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2005-06-09 02:56:09 +02:00
|
|
|
echo "Adding $4"
|
|
|
|
git-update-cache --add --cacheinfo "$6" "$2" "$4" &&
|
|
|
|
exec git-checkout-cache -u -f -- "$4"
|
2005-06-09 01:38:20 +02:00
|
|
|
;;
|
|
|
|
|
2005-04-18 23:17:58 +02:00
|
|
|
#
|
2005-05-02 08:53:32 +02:00
|
|
|
# Modified in both, but differently.
|
2005-04-18 23:17:58 +02:00
|
|
|
#
|
|
|
|
"$1$2$3")
|
2005-05-02 08:53:32 +02:00
|
|
|
echo "Auto-merging $4."
|
2005-05-07 21:26:15 +02:00
|
|
|
orig=`git-unpack-file $1`
|
|
|
|
src2=`git-unpack-file $3`
|
2005-06-09 01:38:20 +02:00
|
|
|
|
2005-06-09 02:56:09 +02:00
|
|
|
# We reset the index to the first branch, making
|
|
|
|
# git-diff-file useful
|
2005-07-29 11:00:45 +02:00
|
|
|
git-update-cache --add --cacheinfo "$6" "$2" "$4"
|
2005-06-09 02:56:09 +02:00
|
|
|
git-checkout-cache -u -f -- "$4" &&
|
|
|
|
merge "$4" "$orig" "$src2"
|
2005-04-24 05:50:10 +02:00
|
|
|
ret=$?
|
2005-06-09 02:56:09 +02:00
|
|
|
rm -f -- "$orig" "$src2"
|
2005-06-08 23:26:55 +02:00
|
|
|
|
2005-04-24 05:50:10 +02:00
|
|
|
if [ "$6" != "$7" ]; then
|
2005-06-09 01:38:20 +02:00
|
|
|
echo "ERROR: Permissions conflict: $5->$6,$7."
|
2005-06-08 20:40:59 +02:00
|
|
|
ret=1
|
2005-04-24 05:50:10 +02:00
|
|
|
fi
|
2005-06-08 23:26:55 +02:00
|
|
|
|
2005-04-24 05:50:10 +02:00
|
|
|
if [ $ret -ne 0 ]; then
|
2005-06-08 20:40:59 +02:00
|
|
|
echo "ERROR: Merge conflict in $4."
|
2005-04-19 04:55:19 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2005-06-09 02:56:09 +02:00
|
|
|
exec git-update-cache -- "$4"
|
2005-06-09 01:38:20 +02:00
|
|
|
;;
|
|
|
|
|
2005-04-18 23:17:58 +02:00
|
|
|
*)
|
2005-06-09 01:38:20 +02:00
|
|
|
echo "ERROR: $4: Not handling case $1 -> $2 -> $3"
|
|
|
|
;;
|
2005-04-18 23:17:58 +02:00
|
|
|
esac
|
|
|
|
exit 1
|