Skip to content

Commit 81b43b5

Browse files
committed
Merge branch 'cc/maint-commit-reflog-msg' into maint
* cc/maint-commit-reflog-msg: commit: use value of GIT_REFLOG_ACTION env variable as reflog message
2 parents abd3fd3 + 643cb5f commit 81b43b5

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

builtin/commit.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,13 +1252,16 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
12521252
}
12531253

12541254
/* Determine parents */
1255+
reflog_msg = getenv("GIT_REFLOG_ACTION");
12551256
if (initial_commit) {
1256-
reflog_msg = "commit (initial)";
1257+
if (!reflog_msg)
1258+
reflog_msg = "commit (initial)";
12571259
} else if (amend) {
12581260
struct commit_list *c;
12591261
struct commit *commit;
12601262

1261-
reflog_msg = "commit (amend)";
1263+
if (!reflog_msg)
1264+
reflog_msg = "commit (amend)";
12621265
commit = lookup_commit(head_sha1);
12631266
if (!commit || parse_commit(commit))
12641267
die("could not parse HEAD commit");
@@ -1269,7 +1272,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
12691272
struct strbuf m = STRBUF_INIT;
12701273
FILE *fp;
12711274

1272-
reflog_msg = "commit (merge)";
1275+
if (!reflog_msg)
1276+
reflog_msg = "commit (merge)";
12731277
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
12741278
fp = fopen(git_path("MERGE_HEAD"), "r");
12751279
if (fp == NULL)
@@ -1292,7 +1296,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
12921296
if (allow_fast_forward)
12931297
parents = reduce_heads(parents);
12941298
} else {
1295-
reflog_msg = "commit";
1299+
if (!reflog_msg)
1300+
reflog_msg = "commit";
12961301
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
12971302
}
12981303

t/t3501-revert-cherry-pick.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ test_expect_success 'cherry-pick after renaming branch' '
4747
git cherry-pick added &&
4848
test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&
4949
test -f opos &&
50-
grep "Add extra line at the end" opos
50+
grep "Add extra line at the end" opos &&
51+
git reflog -1 | grep cherry-pick
5152
5253
'
5354

@@ -57,7 +58,8 @@ test_expect_success 'revert after renaming branch' '
5758
git revert added &&
5859
test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
5960
test -f spoo &&
60-
! grep "Add extra line at the end" spoo
61+
! grep "Add extra line at the end" spoo &&
62+
git reflog -1 | grep revert
6163
6264
'
6365

0 commit comments

Comments
 (0)