@matheusbsbs / matheus-bagliano / commits / 4f692b1978
Fork 0

Allow git-merge not to commit.

Martin Langhoff wants to use git-merge from outside git-pull and wants to do further processing; for this, he wants git-merge no to commit even when it cleanly merges. I think other script writers would want something like that as well, so here it is. Instead of the "merge commit message" parameter (which usually is made for you by "git-pull" which calls this command), you pass an empty string to it. Then it will not update your HEAD -- you can do whatever you want with the resulting index file, which contains the merge results. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Oct 22, 2005 at 04:45 UTC 4f692b19788364ed0bd65983579edcd6e5444f2b
1 file changed +17 -11
git-merge.sh
+17 -11
@@ -38,10 +38,20 @@ restorestate() {
38 fi
39 }
40
41 -summary() {
41 +finish () {
42 + test '' = "$2" || echo "$2"
43 + case "$merge_msg" in
44 + '')
45 + echo "No merge message -- not updating HEAD"
46 + ;;
47 + *)
48 + git-update-ref HEAD "$1" "$head" || exit 1
49 + ;;
50 + esac
51 +
52 case "$no_summary" in
53 '')
44 - git-diff-tree -p -M $head "$1" |
54 + git-diff-tree -p -M "$head" "$1" |
55 git-apply --stat --summary
56 ;;
57 esac
@@ -108,7 +118,7 @@ case "$#,$common" in
118 1,"$1")
119 # If head can reach all the merge then we are up to date.
120 # but first the most common case of merging one remote
111 - echo "Already up-to-date. Yeeah!"
121 + echo "Already up-to-date."
122 dropsave
123 exit 0
124 ;;
@@ -116,10 +126,9 @@ case "$#,$common" in
126 # Again the most common case of merging one remote.
127 echo "Updating from $head to $1."
128 git-update-index --refresh 2>/dev/null
119 - git-read-tree -u -m $head "$1" &&
129 new_head=$(git-rev-parse --verify "$1^0") &&
121 - git-update-ref HEAD "$new_head" "$head" || exit 1
122 - summary "$1"
130 + git-read-tree -u -m $head "$new_head" &&
131 + finish "$new_head" "Fast forward"
132 dropsave
133 exit 0
134 ;;
@@ -140,8 +149,7 @@ case "$#,$common" in
149 echo "$merge_msg" |
150 git-commit-tree $result_tree -p HEAD -p "$1"
151 ) || exit
143 - git-update-ref HEAD $result_commit $head
144 - summary $result_commit
152 + finish "$result_commit" "In-index merge"
153 dropsave
154 exit 0
155 fi
@@ -237,9 +245,7 @@ then
245 parents="$parents -p $remote"
246 done
247 result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents) || exit
240 - echo "Committed merge $result_commit, made by $wt_strategy."
241 - git-update-ref HEAD $result_commit $head
242 - summary $result_commit
248 + finish "$result_commit" "Merge $result_commit, made by $wt_strategy."
249 dropsave
250 exit 0
251 fi