git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Pearce <spearce@spearce.org>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: [PATCH] Log ref changes made by git-merge and git-pull.
Date: Tue, 11 Jul 2006 01:52:54 -0400	[thread overview]
Message-ID: <20060711055254.GA11636@spearce.org> (raw)

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>
---
 git-merge.sh |   17 ++++++++++++++---
 git-pull.sh  |    3 ++-
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/git-merge.sh b/git-merge.sh
index 24e3b50..a9cfafb 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -58,7 +58,13 @@ squash_message () {
 }
 
 finish () {
-	test '' = "$2" || echo "$2"
+	if test '' = "$2"
+	then
+		rlogm="$rloga"
+	else
+		echo "$2"
+		rlogm="$rloga: $2"
+	fi
 	case "$squash" in
 	t)
 		echo "Squash commit -- not updating HEAD"
@@ -70,7 +76,7 @@ finish () {
 			echo "No merge message -- not updating HEAD"
 			;;
 		*)
-			git-update-ref HEAD "$1" "$head" || exit 1
+			git-update-ref -m "$rlogm" HEAD "$1" "$head" || exit 1
 			;;
 		esac
 		;;
@@ -88,6 +94,7 @@ finish () {
 	esac
 }
 
+rloga=
 while case "$#" in 0) break ;; esac
 do
 	case "$1" in
@@ -117,6 +124,9 @@ do
 			die "available strategies are: $all_strategies" ;;
 		esac
 		;;
+	--reflog-action=*)
+		rloga=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+		;;
 	-*)	usage ;;
 	*)	break ;;
 	esac
@@ -131,6 +141,7 @@ shift
 
 # All the rest are remote heads
 test "$#" = 0 && usage ;# we need at least one remote head.
+test "$rloga" = '' && rloga="merge: $@"
 
 remoteheads=
 for remote
@@ -316,7 +327,7 @@ if test '' != "$result_tree"
 then
     parents=$(git-show-branch --independent "$head" "$@" | sed -e 's/^/-p /')
     result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents) || exit
-    finish "$result_commit" "Merge $result_commit, made by $wt_strategy."
+    finish "$result_commit" "Merge made by $wt_strategy."
     dropsave
     exit 0
 fi
diff --git a/git-pull.sh b/git-pull.sh
index d337bf4..f380437 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -102,5 +102,6 @@ case "$strategy_args" in
 esac
 
 merge_name=$(git-fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
-git-merge $no_summary $no_commit $squash $strategy_args \
+git-merge "--reflog-action=pull $*" \
+	$no_summary $no_commit $squash $strategy_args \
 	"$merge_name" HEAD $merge_head
-- 
1.4.1.gc48f

                 reply	other threads:[~2006-07-11  5:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060711055254.GA11636@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).