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