summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richardipsum@fastmail.co.uk>2017-02-26 13:34:13 +0000
committerRichard Ipsum <richardipsum@fastmail.co.uk>2017-02-27 23:53:12 +0000
commit1255a9ac0c424d5fbf13ce166a8b0eef000e24e6 (patch)
treeb52f0dc997f4bb14ed6ebf7ecff55d7dd508b856
parent7143145f2fcb0f7476f333f9df990b8a06cd52c0 (diff)
downloadlibgit2-1255a9ac0c424d5fbf13ce166a8b0eef000e24e6.tar.gz
Fix: make reflog include "(merge)" for merge commits
This fixes issue #4094
-rw-r--r--src/refs.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/refs.c b/src/refs.c
index 70f5519c6..0837dc4a8 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1130,6 +1130,18 @@ int git_reference__update_terminal(
return error;
}
+static const char *commit_type(const git_commit *commit)
+{
+ unsigned int count = git_commit_parentcount(commit);
+
+ if (count >= 2)
+ return " (merge)";
+ else if (count == 0)
+ return " (initial)";
+ else
+ return "";
+}
+
int git_reference__update_for_commit(
git_repository *repo,
git_reference *ref,
@@ -1146,7 +1158,7 @@ int git_reference__update_for_commit(
if ((error = git_commit_lookup(&commit, repo, id)) < 0 ||
(error = git_buf_printf(&reflog_msg, "%s%s: %s",
operation ? operation : "commit",
- git_commit_parentcount(commit) == 0 ? " (initial)" : "",
+ commit_type(commit),
git_commit_summary(commit))) < 0)
goto done;