Make git-prune-script executable again.
[git/dscho.git] / git-resolve-script
blobc04c0307b2b7c2b83c7707c90b844aa958a6c407
1 #!/bin/sh
3 # Resolve two trees.
5 head="$1"
6 merge="$2"
7 merge_repo="$3"
9 rm -f .git/MERGE_HEAD .git/ORIG_HEAD
10 echo $head > .git/ORIG_HEAD
11 echo $merge > .git/MERGE_HEAD
14 # The remote name is just used for the message,
15 # but we do want it.
17 if [ "$merge_repo" == "" ]; then
18 echo "git-resolve-script <head> <remote> <merge-repo-name>"
19 exit 1
22 common=$(git-merge-base $head $merge)
23 if [ -z "$common" ]; then
24 echo "Unable to find common commit between" $merge $head
25 exit 1
28 if [ "$common" == "$merge" ]; then
29 echo "Already up-to-date. Yeeah!"
30 exit 0
32 if [ "$common" == "$head" ]; then
33 echo "Updating from $head to $merge."
34 echo "Destroying all noncommitted data!"
35 echo "Kill me within 3 seconds.."
36 sleep 3
37 git-read-tree -m $merge && git-checkout-cache -f -a && git-update-cache --refresh
38 echo $merge > .git/HEAD
39 git-diff-tree -p ORIG_HEAD HEAD | diffstat -p1
40 exit 0
42 echo "Trying to merge $merge into $head"
43 git-read-tree -m $common $head $merge
44 merge_msg="Merge of $merge_repo"
45 result_tree=$(git-write-tree 2> /dev/null)
46 if [ $? -ne 0 ]; then
47 echo "Simple merge failed, trying Automatic merge"
48 git-merge-cache git-merge-one-file-script -a
49 merge_msg="Automatic merge of $merge_repo"
50 result_tree=$(git-write-tree) || exit 1
52 result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree -p $head -p $merge_head)
53 echo "Committed merge $result_commit"
54 echo $result_commit > .git/HEAD
55 git-checkout-cache -f -a && git-update-cache --refresh
56 git-diff-tree -p ORIG_HEAD HEAD | diffstat -p1