Skip to content

Commit 6cd52ed

Browse files
committed
Merge branch 'cc/maint-commit-reflog-msg'
* cc/maint-commit-reflog-msg: commit: use value of GIT_REFLOG_ACTION env variable as reflog message
2 parents 9cb16a9 + 643cb5f commit 6cd52ed

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

builtin/commit.c

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

12691269
/* Determine parents */
1270+
reflog_msg = getenv("GIT_REFLOG_ACTION");
12701271
if (initial_commit) {
1271-
reflog_msg = "commit (initial)";
1272+
if (!reflog_msg)
1273+
reflog_msg = "commit (initial)";
12721274
} else if (amend) {
12731275
struct commit_list *c;
12741276
struct commit *commit;
12751277

1276-
reflog_msg = "commit (amend)";
1278+
if (!reflog_msg)
1279+
reflog_msg = "commit (amend)";
12771280
commit = lookup_commit(head_sha1);
12781281
if (!commit || parse_commit(commit))
12791282
die("could not parse HEAD commit");
@@ -1284,7 +1287,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
12841287
struct strbuf m = STRBUF_INIT;
12851288
FILE *fp;
12861289

1287-
reflog_msg = "commit (merge)";
1290+
if (!reflog_msg)
1291+
reflog_msg = "commit (merge)";
12881292
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
12891293
fp = fopen(git_path("MERGE_HEAD"), "r");
12901294
if (fp == NULL)
@@ -1307,7 +1311,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
13071311
if (allow_fast_forward)
13081312
parents = reduce_heads(parents);
13091313
} else {
1310-
reflog_msg = "commit";
1314+
if (!reflog_msg)
1315+
reflog_msg = "commit";
13111316
pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
13121317
}
13131318

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)