Code

commit: use value of GIT_REFLOG_ACTION env variable as reflog message
[git.git] / builtin / commit.c
index c5ab683d5b66d5ad85f53d13d6df71e29cd9234d..58bad61306fb5da2a0d22a7d3827c2543f0aafcb 100644 (file)
@@ -1232,13 +1232,16 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        }
 
        /* Determine parents */
+       reflog_msg = getenv("GIT_REFLOG_ACTION");
        if (initial_commit) {
-               reflog_msg = "commit (initial)";
+               if (!reflog_msg)
+                       reflog_msg = "commit (initial)";
        } else if (amend) {
                struct commit_list *c;
                struct commit *commit;
 
-               reflog_msg = "commit (amend)";
+               if (!reflog_msg)
+                       reflog_msg = "commit (amend)";
                commit = lookup_commit(head_sha1);
                if (!commit || parse_commit(commit))
                        die("could not parse HEAD commit");
@@ -1249,7 +1252,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                struct strbuf m = STRBUF_INIT;
                FILE *fp;
 
-               reflog_msg = "commit (merge)";
+               if (!reflog_msg)
+                       reflog_msg = "commit (merge)";
                pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
                fp = fopen(git_path("MERGE_HEAD"), "r");
                if (fp == NULL)
@@ -1272,7 +1276,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                if (allow_fast_forward)
                        parents = reduce_heads(parents);
        } else {
-               reflog_msg = "commit";
+               if (!reflog_msg)
+                       reflog_msg = "commit";
                pptr = &commit_list_insert(lookup_commit(head_sha1), pptr)->next;
        }