summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-07-22 16:12:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-07-22 20:54:57 (GMT)
commitd04520e3446acdcbdf1d30c812aa31d6a003c171 (patch)
tree3bbef2f4283be922cc9f8a61c82b8f03e24f0808 /t
parent0dc310e8608c05f40be3390607f301ffc4284e6d (diff)
downloadgit-d04520e3446acdcbdf1d30c812aa31d6a003c171.zip
git-d04520e3446acdcbdf1d30c812aa31d6a003c171.tar.gz
git-d04520e3446acdcbdf1d30c812aa31d6a003c171.tar.bz2
reset: give better reflog messages
The reset command creates its reflog entry from argv. However, it does so after having run parse_options, which means the only thing left in argv is any non-option arguments. Thus you would end up with confusing reflog entries like: $ git reset --hard HEAD^ $ git reset --soft HEAD@{1} $ git log -2 -g --oneline 8e46cad HEAD@{0}: HEAD@{1}: updating HEAD 1eb9486 HEAD@{1}: HEAD^: updating HEAD However, we must also consider that some scripts may set GIT_REFLOG_ACTION before calling reset, and we need to show their reflog action (with our text appended). For example: rebase -i (squash): updating HEAD On top of that, we also set the ORIG_HEAD reflog action (even though it doesn't generally exist). In that case, the reset argument is somewhat meaningless, as it has nothing to do with what's in ORIG_HEAD. This patch changes the reset reflog code to show: $GIT_REFLOG_ACTION: updating {HEAD,ORIG_HEAD} as before, but only if GIT_REFLOG_ACTION is set. Otherwise, show: reset: moving to $rev for HEAD, and: reset: updating ORIG_HEAD for ORIG_HEAD (this is still somewhat superfluous, since we are in the ORIG_HEAD reflog, obviously, but at least we now mention which command was used to update it). While we're at it, we can clean up the code a bit: - Use strbufs to make the message. - Use the "rev" parameter instead of showing all options. This makes more sense, since it is the only thing impacting the writing of the ref. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1412-reflog-loop.sh8
1 files changed, 4 insertions, 4 deletions
diff --git a/t/t1412-reflog-loop.sh b/t/t1412-reflog-loop.sh
index 7f519e5..647d888 100755
--- a/t/t1412-reflog-loop.sh
+++ b/t/t1412-reflog-loop.sh
@@ -21,10 +21,10 @@ test_expect_success 'setup reflog with alternating commits' '
test_expect_success 'reflog shows all entries' '
cat >expect <<-\EOF
- topic@{0} two: updating HEAD
- topic@{1} one: updating HEAD
- topic@{2} two: updating HEAD
- topic@{3} one: updating HEAD
+ topic@{0} reset: moving to two
+ topic@{1} reset: moving to one
+ topic@{2} reset: moving to two
+ topic@{3} reset: moving to one
topic@{4} branch: Created from HEAD
EOF
git log -g --format="%gd %gs" topic >actual &&