Skip to content

Commit d2cf3b2

Browse files
committed
sequencer: refactor the code to obtain a short commit name
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 899722b commit d2cf3b2

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

sequencer.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,18 @@ struct commit_message {
165165
const char *message;
166166
};
167167

168+
static const char *short_commit_name(struct commit *commit)
169+
{
170+
return find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);
171+
}
172+
168173
static int get_message(struct commit *commit, struct commit_message *out)
169174
{
170175
const char *abbrev, *subject;
171176
int subject_len;
172177

173178
out->message = logmsg_reencode(commit, NULL, get_commit_output_encoding());
174-
abbrev = find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);
179+
abbrev = short_commit_name(commit);
175180

176181
subject_len = find_commit_subject(out->message, &subject);
177182

@@ -656,8 +661,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
656661
error(command == TODO_REVERT
657662
? _("could not revert %s... %s")
658663
: _("could not apply %s... %s"),
659-
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV),
660-
msg.subject);
664+
short_commit_name(commit), msg.subject);
661665
print_advice(res == 1, opts);
662666
rerere(opts->allow_rerere_auto);
663667
goto leave;
@@ -895,9 +899,7 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
895899
subject_len = find_commit_subject(commit_buffer, &subject);
896900
strbuf_addf(&todo_list->buf, "%s %s %.*s\n",
897901
opts->action == REPLAY_PICK ? "pick" : "revert",
898-
find_unique_abbrev(commit->object.oid.hash,
899-
DEFAULT_ABBREV),
900-
subject_len, subject);
902+
short_commit_name(commit), subject_len, subject);
901903
unuse_commit_buffer(commit, commit_buffer);
902904
}
903905
return 0;

0 commit comments

Comments
 (0)