commit: use value of GIT_REFLOG_ACTION env variable as reflog message
The environment variable GIT_REFLOG_ACTION was used by git-commit.sh,
but when it was converted to a builtin
(f5bbc3225c
, Port git commit to C,
Nov 8 2007) this was lost.
Let's use it again as it is more user friendly when reverting or
cherry-picking to see "revert" or "cherry-pick" in the reflog rather
than to just see "commit".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
0d4dbcd35e
commit
643cb5f7c9
@ -1232,12 +1232,15 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Determine parents */
|
/* Determine parents */
|
||||||
|
reflog_msg = getenv("GIT_REFLOG_ACTION");
|
||||||
if (initial_commit) {
|
if (initial_commit) {
|
||||||
|
if (!reflog_msg)
|
||||||
reflog_msg = "commit (initial)";
|
reflog_msg = "commit (initial)";
|
||||||
} else if (amend) {
|
} else if (amend) {
|
||||||
struct commit_list *c;
|
struct commit_list *c;
|
||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
|
|
||||||
|
if (!reflog_msg)
|
||||||
reflog_msg = "commit (amend)";
|
reflog_msg = "commit (amend)";
|
||||||
commit = lookup_commit(head_sha1);
|
commit = lookup_commit(head_sha1);
|
||||||
if (!commit || parse_commit(commit))
|
if (!commit || parse_commit(commit))
|
||||||
@ -1249,6 +1252,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
|||||||
struct strbuf m = STRBUF_INIT;
|
struct strbuf m = STRBUF_INIT;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
|
if (!reflog_msg)
|
||||||
reflog_msg = "commit (merge)";
|
reflog_msg = "commit (merge)";
|
||||||
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
|
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
|
||||||
fp = fopen(git_path("MERGE_HEAD"), "r");
|
fp = fopen(git_path("MERGE_HEAD"), "r");
|
||||||
@ -1272,6 +1276,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
|||||||
if (allow_fast_forward)
|
if (allow_fast_forward)
|
||||||
parents = reduce_heads(parents);
|
parents = reduce_heads(parents);
|
||||||
} else {
|
} else {
|
||||||
|
if (!reflog_msg)
|
||||||
reflog_msg = "commit";
|
reflog_msg = "commit";
|
||||||
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
|
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,8 @@ test_expect_success 'cherry-pick after renaming branch' '
|
|||||||
git cherry-pick added &&
|
git cherry-pick added &&
|
||||||
test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&
|
test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&
|
||||||
test -f opos &&
|
test -f opos &&
|
||||||
grep "Add extra line at the end" opos
|
grep "Add extra line at the end" opos &&
|
||||||
|
git reflog -1 | grep cherry-pick
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -57,7 +58,8 @@ test_expect_success 'revert after renaming branch' '
|
|||||||
git revert added &&
|
git revert added &&
|
||||||
test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
|
test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
|
||||||
test -f spoo &&
|
test -f spoo &&
|
||||||
! grep "Add extra line at the end" spoo
|
! grep "Add extra line at the end" spoo &&
|
||||||
|
git reflog -1 | grep revert
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user