Skip to content

Commit 1255a9a

Browse files
committed
Fix: make reflog include "(merge)" for merge commits
This fixes issue libgit2#4094
1 parent 7143145 commit 1255a9a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/refs.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,18 @@ int git_reference__update_terminal(
11301130
return error;
11311131
}
11321132

1133+
static const char *commit_type(const git_commit *commit)
1134+
{
1135+
unsigned int count = git_commit_parentcount(commit);
1136+
1137+
if (count >= 2)
1138+
return " (merge)";
1139+
else if (count == 0)
1140+
return " (initial)";
1141+
else
1142+
return "";
1143+
}
1144+
11331145
int git_reference__update_for_commit(
11341146
git_repository *repo,
11351147
git_reference *ref,
@@ -1146,7 +1158,7 @@ int git_reference__update_for_commit(
11461158
if ((error = git_commit_lookup(&commit, repo, id)) < 0 ||
11471159
(error = git_buf_printf(&reflog_msg, "%s%s: %s",
11481160
operation ? operation : "commit",
1149-
git_commit_parentcount(commit) == 0 ? " (initial)" : "",
1161+
commit_type(commit),
11501162
git_commit_summary(commit))) < 0)
11511163
goto done;
11521164

0 commit comments

Comments
 (0)