Add "unpack-file" helper that unpacks a sha1 blob into a tmpfile.
[git/dscho.git] / git-merge-one-file-script
blob26dbe63e0217d6e6761e8c758b1633169266b345
1 #!/bin/sh
3 # This is the git merge script, called with
5 # $1 - original file (or empty string)
6 # $2 - file in branch1 (or empty string)
7 # $3 - file in branch2 (or empty string)
8 # $4 - pathname in repository
11 # Case 1: file removed in both
13 if [ -z "$2$3" ]; then
14 rm -- "$4"
15 update-cache --remove -- "$4"
16 exit 0
19 # Case 2: file exists in just one
21 if [ "$2$3" == "$3$2" ]; then
22 cat "$2$3" > "$4"
23 update-cache --add -- "$4"
24 exit 0
27 # Case 3: file exists in both
29 src="$1"
30 if [ -z "$1" ]; then
31 src=/dev/null
32 fi
33 echo "Auto-merging $4"
34 cp "$3" "$4"
35 merge "$4" "$src" "$2" && update-cache --add -- "$4"