You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
1.9 KiB
89 lines
1.9 KiB
20 years ago
|
#!/bin/sh
|
||
|
#
|
||
20 years ago
|
# Copyright (c) Linus Torvalds, 2005
|
||
|
#
|
||
|
# This is the git per-file merge script, called with
|
||
20 years ago
|
#
|
||
20 years ago
|
# $1 - original file SHA1 (or empty)
|
||
|
# $2 - file in branch1 SHA1 (or empty)
|
||
|
# $3 - file in branch2 SHA1 (or empty)
|
||
20 years ago
|
# $4 - pathname in repository
|
||
20 years ago
|
# $5 - orignal file mode (or empty)
|
||
|
# $6 - file in branch1 mode (or empty)
|
||
|
# $7 - file in branch2 mode (or empty)
|
||
20 years ago
|
#
|
||
20 years ago
|
# Handle some trivial cases.. The _really_ trivial cases have
|
||
20 years ago
|
# been handled already by git-read-tree, but that one doesn't
|
||
20 years ago
|
# do any merges that might change the tree layout.
|
||
20 years ago
|
|
||
20 years ago
|
case "${1:-.}${2:-.}${3:-.}" in
|
||
20 years ago
|
#
|
||
20 years ago
|
# Deleted in both or deleted in one and unchanged in the other
|
||
20 years ago
|
#
|
||
20 years ago
|
"$1.." | "$1.$1" | "$1$1.")
|
||
19 years ago
|
if [ "$2" ]; then
|
||
|
echo "Removing $4"
|
||
|
fi
|
||
20 years ago
|
if test -f "$4"; then
|
||
20 years ago
|
rm -f -- "$4"
|
||
|
fi &&
|
||
19 years ago
|
exec git-update-index --remove -- "$4"
|
||
20 years ago
|
;;
|
||
|
|
||
20 years ago
|
#
|
||
20 years ago
|
# Added in one.
|
||
20 years ago
|
#
|
||
20 years ago
|
".$2." | "..$3" )
|
||
20 years ago
|
echo "Adding $4"
|
||
19 years ago
|
git-update-index --add --cacheinfo "$6$7" "$2$3" "$4" &&
|
||
|
exec git-checkout-index -u -f -- "$4"
|
||
20 years ago
|
;;
|
||
|
|
||
20 years ago
|
#
|
||
20 years ago
|
# Added in both (check for same permissions).
|
||
20 years ago
|
#
|
||
20 years ago
|
".$3$2")
|
||
20 years ago
|
if [ "$6" != "$7" ]; then
|
||
20 years ago
|
echo "ERROR: File $4 added identically in both branches,"
|
||
|
echo "ERROR: but permissions conflict $6->$7."
|
||
20 years ago
|
exit 1
|
||
|
fi
|
||
20 years ago
|
echo "Adding $4"
|
||
19 years ago
|
git-update-index --add --cacheinfo "$6" "$2" "$4" &&
|
||
|
exec git-checkout-index -u -f -- "$4"
|
||
20 years ago
|
;;
|
||
|
|
||
20 years ago
|
#
|
||
20 years ago
|
# Modified in both, but differently.
|
||
20 years ago
|
#
|
||
|
"$1$2$3")
|
||
20 years ago
|
echo "Auto-merging $4."
|
||
20 years ago
|
orig=`git-unpack-file $1`
|
||
|
src2=`git-unpack-file $3`
|
||
20 years ago
|
|
||
20 years ago
|
# We reset the index to the first branch, making
|
||
|
# git-diff-file useful
|
||
19 years ago
|
git-update-index --add --cacheinfo "$6" "$2" "$4"
|
||
|
git-checkout-index -u -f -- "$4" &&
|
||
20 years ago
|
merge "$4" "$orig" "$src2"
|
||
20 years ago
|
ret=$?
|
||
20 years ago
|
rm -f -- "$orig" "$src2"
|
||
20 years ago
|
|
||
20 years ago
|
if [ "$6" != "$7" ]; then
|
||
20 years ago
|
echo "ERROR: Permissions conflict: $5->$6,$7."
|
||
20 years ago
|
ret=1
|
||
20 years ago
|
fi
|
||
20 years ago
|
|
||
20 years ago
|
if [ $ret -ne 0 ]; then
|
||
20 years ago
|
echo "ERROR: Merge conflict in $4."
|
||
20 years ago
|
exit 1
|
||
|
fi
|
||
19 years ago
|
exec git-update-index -- "$4"
|
||
20 years ago
|
;;
|
||
|
|
||
20 years ago
|
*)
|
||
20 years ago
|
echo "ERROR: $4: Not handling case $1 -> $2 -> $3"
|
||
|
;;
|
||
20 years ago
|
esac
|
||
|
exit 1
|