{"thread":{"id":"4841","subject":"[PATCH] Log ref changes made by git-merge and git-pull.","startedAt":"2006-07-11T05:52:54Z","lastAt":"2006-07-11T05:52:54Z","messageCount":1,"participants":["Shawn Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"23614","messageId":"20060711055254.GA11636@spearce.org","threadId":"4841","inReplyTo":null,"subject":"[PATCH] Log ref changes made by git-merge and git-pull.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-07-11T05:52:54Z","receivedAt":"2006-07-11T05:52:54Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"When git-merge updates HEAD as a result of a merge record what\nhappened during the merge into the reflog associated with HEAD\n(if any).  The log reports who caused the update (git-merge or\ngit-pull, by invoking git-merge), what the remote ref names were\nand the type of merge process used.\n\nThe merge information can be useful when reviewing a reflog for\na branch such as `master` where fast forward and trivial in index\nmerges might be common as the user tracks an upstream.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n git-merge.sh |   17 ++++++++++++++---\n git-pull.sh  |    3 ++-\n 2 files changed, 16 insertions(+), 4 deletions(-)\n\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 24e3b50..a9cfafb 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -58,7 +58,13 @@ squash_message () {\n }\n \n finish () {\n-\ttest '' = \"$2\" || echo \"$2\"\n+\tif test '' = \"$2\"\n+\tthen\n+\t\trlogm=\"$rloga\"\n+\telse\n+\t\techo \"$2\"\n+\t\trlogm=\"$rloga: $2\"\n+\tfi\n \tcase \"$squash\" in\n \tt)\n \t\techo \"Squash commit -- not updating HEAD\"\n@@ -70,7 +76,7 @@ finish () {\n \t\t\techo \"No merge message -- not updating HEAD\"\n \t\t\t;;\n \t\t*)\n-\t\t\tgit-update-ref HEAD \"$1\" \"$head\" || exit 1\n+\t\t\tgit-update-ref -m \"$rlogm\" HEAD \"$1\" \"$head\" || exit 1\n \t\t\t;;\n \t\tesac\n \t\t;;\n@@ -88,6 +94,7 @@ finish () {\n \tesac\n }\n \n+rloga=\n while case \"$#\" in 0) break ;; esac\n do\n \tcase \"$1\" in\n@@ -117,6 +124,9 @@ do\n \t\t\tdie \"available strategies are: $all_strategies\" ;;\n \t\tesac\n \t\t;;\n+\t--reflog-action=*)\n+\t\trloga=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n+\t\t;;\n \t-*)\tusage ;;\n \t*)\tbreak ;;\n \tesac\n@@ -131,6 +141,7 @@ shift\n \n # All the rest are remote heads\n test \"$#\" = 0 && usage ;# we need at least one remote head.\n+test \"$rloga\" = '' && rloga=\"merge: $@\"\n \n remoteheads=\n for remote\n@@ -316,7 +327,7 @@ if test '' != \"$result_tree\"\n then\n     parents=$(git-show-branch --independent \"$head\" \"$@\" | sed -e 's/^/-p /')\n     result_commit=$(echo \"$merge_msg\" | git-commit-tree $result_tree $parents) || exit\n-    finish \"$result_commit\" \"Merge $result_commit, made by $wt_strategy.\"\n+    finish \"$result_commit\" \"Merge made by $wt_strategy.\"\n     dropsave\n     exit 0\n fi\ndiff --git a/git-pull.sh b/git-pull.sh\nindex d337bf4..f380437 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -102,5 +102,6 @@ case \"$strategy_args\" in\n esac\n \n merge_name=$(git-fmt-merge-msg <\"$GIT_DIR/FETCH_HEAD\") || exit\n-git-merge $no_summary $no_commit $squash $strategy_args \\\n+git-merge \"--reflog-action=pull $*\" \\\n+\t$no_summary $no_commit $squash $strategy_args \\\n \t\"$merge_name\" HEAD $merge_head\n-- \n1.4.1.gc48f\n"}]}