From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 7/7] rebase -i: write better reflog messages
Date: Wed, 19 Jun 2013 00:25:37 +0530 [thread overview]
Message-ID: <1371581737-10013-8-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1371581737-10013-1-git-send-email-artagnon@gmail.com>
Now that the "checkout" invoked internally from "rebase -i" knows to
honor GIT_REFLOG_ACTION, we can start to use it to write a better reflog
message when "rebase -i anotherbranch", "rebase -i --onto branch",
etc. internally checks out the new fork point. We will write:
rebase -i (start): checkout master
instead of the old
rebase -i (start)
[jc: add rebase-reflog test]
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
git-rebase--interactive.sh | 14 ++++++++++----
t/t3404-rebase-interactive.sh | 15 +++++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index f953d8d..8429c87 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -95,12 +95,15 @@ commit_message () {
git cat-file commit "$1" | sed "1,/^$/d"
}
-orig_reflog_action="$GIT_REFLOG_ACTION"
+base_reflog_action="$GIT_REFLOG_ACTION"
comment_for_reflog () {
- case "$orig_reflog_action" in
+ case "$base_reflog_action" in
+ # if GIT_REFLOG_ACTION was set by caller git-rebase, overwrite
+ # it with rebase -i.
''|rebase*)
GIT_REFLOG_ACTION="rebase -i ($1)"
+ base_reflog_action="$GIT_REFLOG_ACTION"
export GIT_REFLOG_ACTION
;;
esac
@@ -326,6 +329,7 @@ pick_one_preserving_merges () {
if [ "$1" != "-n" ]
then
# detach HEAD to current parent
+ GIT_REFLOG_ACTION="$base_reflog_action: checkout $first_parent"
output git checkout $first_parent 2> /dev/null ||
die "Cannot move HEAD to $first_parent"
fi
@@ -608,10 +612,10 @@ do_next () {
newhead=$(git rev-parse HEAD) &&
case $head_name in
refs/*)
- message="$GIT_REFLOG_ACTION: $head_name onto $onto" &&
+ message="$base_reflog_action: $head_name onto $onto" &&
git update-ref -m "$message" $head_name $newhead $orig_head &&
git symbolic-ref \
- -m "$GIT_REFLOG_ACTION: returning to $head_name" \
+ -m "$base_reflog_action: returning to $head_name" \
HEAD $head_name
;;
esac && {
@@ -838,6 +842,7 @@ comment_for_reflog start
if test ! -z "$switch_to"
then
+ GIT_REFLOG_ACTION="$base_reflog_action: checkout $switch_to"
output git checkout "$switch_to" -- ||
die "Could not checkout $switch_to"
fi
@@ -981,6 +986,7 @@ has_action "$todo" ||
test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
+GIT_REFLOG_ACTION="$base_reflog_action: checkout $onto_name"
output git checkout $onto || die_abort "could not detach HEAD"
git update-ref ORIG_HEAD $orig_head
do_rest
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 79e8d3c..f7d0147 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -934,6 +934,21 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' '
test L = $(git cat-file commit HEAD | sed -ne \$p)
'
+test_expect_success 'rebase -i produces readable reflog' '
+ git reset --hard &&
+ git branch -f branch1 H &&
+ git rebase -i --onto I F branch1 &&
+ cat >expect <<-\EOF &&
+ rebase -i (start): checkout I
+ rebase -i (pick): G
+ rebase -i (pick): H
+ rebase -i (finish): returning to refs/heads/branch1
+ EOF
+ tail -n 4 .git/logs/HEAD |
+ sed -e "s/.* //" >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'rebase -i respects core.commentchar' '
git reset --hard &&
git checkout E^0 &&
--
1.8.3.1.455.g5932b31
next prev parent reply other threads:[~2013-06-18 18:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 18:55 [PATCH v2 0/7] Re-roll rr/rebase-checkout-reflog Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 1/7] t/t7512-status-help: test "HEAD detached from" Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 2/7] wt-status: remove unused field in grab_1st_switch_cbdata Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 3/7] t/t2012-checkout-last: test "checkout -" after a rebase Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 4/7] status: do not depend on rebase reflog messages Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 5/7] checkout: respect GIT_REFLOG_ACTION Ramkumar Ramachandra
2013-06-18 18:55 ` [PATCH v2 6/7] rebase: write better reflog messages Ramkumar Ramachandra
2013-06-18 20:35 ` Junio C Hamano
2013-06-19 5:39 ` Johannes Sixt
2013-06-19 6:09 ` Ramkumar Ramachandra
2013-06-19 6:24 ` Johannes Sixt
2013-06-19 16:58 ` Junio C Hamano
2013-06-19 17:53 ` Junio C Hamano
2013-06-19 18:29 ` Junio C Hamano
2013-06-18 18:55 ` Ramkumar Ramachandra [this message]
2013-06-18 20:36 ` [PATCH v2 7/7] rebase -i: " Junio C Hamano
2013-06-18 20:38 ` Ramkumar Ramachandra
2013-06-18 20:55 ` Junio C Hamano
2013-06-19 4:07 ` Ramkumar Ramachandra
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371581737-10013-8-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).