3 # use "$1" or something in a real script, this
9 rm -f .git/MERGE_HEAD .git/ORIG_HEAD
10 cp .git/HEAD .git/ORIG_HEAD
12 echo "Getting object database"
13 rsync -avz --ignore-existing $merge_repo/objects/. ${SHA1_FILE_DIRECTORY:-.git/objects}/.
15 echo "Getting remote $merge_name"
16 rsync -L $merge_repo/$merge_name .git/MERGE_HEAD || exit 1
19 merge_head=$(cat .git/MERGE_HEAD)
20 common=$(git-merge-base $head $merge_head)
21 if [ -z "$common" ]; then
22 echo "Unable to find common commit between" $merge_head $head
26 # Get the trees associated with those commits
27 common_tree=$(git-cat-file commit $common | sed 's/tree //;q')
28 head_tree=$(git-cat-file commit $head | sed 's/tree //;q')
29 merge_tree=$(git-cat-file commit $merge_head | sed 's/tree //;q')
31 if [ "$common" == "$merge_head" ]; then
32 echo "Already up-to-date. Yeeah!"
35 if [ "$common" == "$head" ]; then
36 echo "Updating from $head to $merge_head."
37 echo "Destroying all noncommitted data!"
38 echo "Kill me within 3 seconds.."
40 git-read-tree -m $merge_tree && git-checkout-cache -f -a && git-update-cache --refresh
41 echo $merge_head > .git/HEAD
42 git-diff-tree -p ORIG_HEAD HEAD | diffstat -p1
45 echo "Trying to merge $merge_head into $head"
46 git-read-tree -m $common_tree $head_tree $merge_tree
47 merge_msg="Merge of $merge_repo"
48 result_tree=$(git-write-tree 2> /dev/null)
50 echo "Simple merge failed, trying Automatic merge"
51 git-merge-cache git-merge-one-file-script -a
52 merge_msg="Automatic merge of $merge_repo"
53 result_tree=$(git-write-tree) || exit 1
55 result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree -p $head -p $merge_head)
56 echo "Committed merge $result_commit"
57 echo $result_commit > .git/HEAD
58 git-checkout-cache -f -a && git-update-cache --refresh
59 git-diff-tree -p ORIG_HEAD HEAD | diffstat -p1