@matheusbsbs / matheus-bagliano / commits / e1447e38c0
Fork 0

Log ref changes made by git-merge and git-pull.

When git-merge updates HEAD as a result of a merge record what happened during the merge into the reflog associated with HEAD (if any). The log reports who caused the update (git-merge or git-pull, by invoking git-merge), what the remote ref names were and the type of merge process used. The merge information can be useful when reviewing a reflog for a branch such as `master` where fast forward and trivial in index merges might be common as the user tracks an upstream. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Shawn Pearce committed Jul 11, 2006 at 01:52 UTC e1447e38c00bdc1904458cfabb4bb3ffb678a271
2 files changed +16 -4
git-merge.sh
+14 -3
@@ -58,7 +58,13 @@ squash_message () {
58 }
59
60 finish () {
61 - test '' = "$2" || echo "$2"
61 + if test '' = "$2"
62 + then
63 + rlogm="$rloga"
64 + else
65 + echo "$2"
66 + rlogm="$rloga: $2"
67 + fi
68 case "$squash" in
69 t)
70 echo "Squash commit -- not updating HEAD"
@@ -70,7 +76,7 @@ finish () {
76 echo "No merge message -- not updating HEAD"
77 ;;
78 *)
73 - git-update-ref HEAD "$1" "$head" || exit 1
79 + git-update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1
80 ;;
81 esac
82 ;;
@@ -88,6 +94,7 @@ finish () {
94 esac
95 }
96
97 +rloga=
98 while case "$#" in 0) break ;; esac
99 do
100 case "$1" in
@@ -117,6 +124,9 @@ do
124 die "available strategies are: $all_strategies" ;;
125 esac
126 ;;
127 + --reflog-action=*)
128 + rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`
129 + ;;
130 -*) usage ;;
131 *) break ;;
132 esac
@@ -131,6 +141,7 @@ shift
141
142 # All the rest are remote heads
143 test "$#" = 0 && usage ;# we need at least one remote head.
144 +test "$rloga" = '' && rloga="merge: $@"
145
146 remoteheads=
147 for remote
@@ -316,7 +327,7 @@ if test '' != "$result_tree"
327 then
328 parents=$(git-show-branch --independent "$head" "$@" | sed -e 's/^/-p /')
329 result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents) || exit
319 - finish "$result_commit" "Merge $result_commit, made by $wt_strategy."
330 + finish "$result_commit" "Merge made by $wt_strategy."
331 dropsave
332 exit 0
333 fi
git-pull.sh
+2 -1
@@ -102,5 +102,6 @@ case "$strategy_args" in
102 esac
103
104 merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
105 -git-merge $no_summary $no_commit $squash $strategy_args \
105 +git-merge "--reflog-action=pull $*" \
106 + $no_summary $no_commit $squash $strategy_args \
107 "$merge_name" HEAD $merge_head