]> git.ipfire.org Git - thirdparty/git.git/blame - git-merge-one-file-script
[PATCH] provide better committer information to commit-tree.c
[thirdparty/git.git] / git-merge-one-file-script
CommitLineData
839a7a06
LT
1#!/bin/sh
2#
3# This is the git merge script, called with
4#
e3b4be7f
LT
5# $1 - original file SHA1 (or empty)
6# $2 - file in branch1 SHA1 (or empty)
7# $3 - file in branch2 SHA1 (or empty)
839a7a06
LT
8# $4 - pathname in repository
9#
10#
e3b4be7f
LT
11# Handle some trivial cases.. The _really_ trivial cases have
12# been handled already by read-tree, but that one doesn't
13# do any merges that migth change the tree layout
839a7a06 14#
e3b4be7f
LT
15
16case "${1:-.}${2:-.}${3:-.}" in
839a7a06 17#
e3b4be7f 18# deleted in both, or deleted in one and unchanged in the other
839a7a06 19#
e3b4be7f
LT
20"$1.." | "$1.$1" | "$1$1.")
21 rm -f -- "$4"
22 update-cache --remove -- "$4"
839a7a06 23 exit 0
e3b4be7f
LT
24 ;;
25
839a7a06 26#
e3b4be7f 27# added in one, or added identically in both
839a7a06 28#
e3b4be7f
LT
29".$2." | "..$3" | ".$2$2")
30 mv $(unpack-file "${2:-$3}") $4
31 update-cache --add -- $4
32 exit 0
33 ;;
34
35#
36# Modified in both, but differently ;(
37#
38"$1$2$3")
39 echo "Auto-merging $4"
40 orig=$(unpack-file $1)
41 src1=$(unpack-file $2)
42 src2=$(unpack-file $3)
43 merge "$src2" "$orig" "$src1" || echo Leaving conflict merge in $src2 && exit 1
44 cp "$src2" "$4" && update-cache --add -- "$4" && exit 0
45 ;;
46
47*)
48 echo "Not handling case $1 -> $2 -> $3"
49 ;;
50esac
51exit 1