Add the simple scripts I used to do a merge with content conflicts.
[git/git.git] / git-merge-one-file-script
CommitLineData
839a7a06
LT
1#!/bin/sh
2#
3# This is the git merge script, called with
4#
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
9#
10#
11# Case 1: file removed in both
12#
13if [ -z "$2$3" ]; then
14 rm -- "$4"
15 update-cache --remove -- "$4"
16 exit 0
17fi
18#
19# Case 2: file exists in just one
20#
21if [ "$2$3" == "$3$2" ]; then
22 cat "$2$3" > "$4"
23 update-cache --add -- "$4"
24 exit 0
25fi
26#
27# Case 3: file exists in both
28#
29src="$1"
30if [ -z "$1" ]; then
31 src=/dev/null
32fi
33echo "Auto-merging $4"
34cp "$3" "$4"
35merge "$4" "$src" "$2" && update-cache --add -- "$4"