Skip to content

Commit 3975596

Browse files
dschogitster
authored andcommitted
sequencer: refactor the code to obtain a short commit name
Not only does this DRY up the code (providing a better documentation what the code is about, as well as allowing to change the behavior in a single place), it also makes it substantially shorter to use the same functionality in functions to be introduced when we teach the sequencer to process interactive-rebase's git-rebase-todo file. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c024650 commit 3975596

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sequencer.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,18 @@ struct commit_message {
147147
const char *message;
148148
};
149149

150+
static const char *short_commit_name(struct commit *commit)
151+
{
152+
return find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);
153+
}
154+
150155
static int get_message(struct commit *commit, struct commit_message *out)
151156
{
152157
const char *abbrev, *subject;
153158
int subject_len;
154159

155160
out->message = logmsg_reencode(commit, NULL, get_commit_output_encoding());
156-
abbrev = find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);
161+
abbrev = short_commit_name(commit);
157162

158163
subject_len = find_commit_subject(out->message, &subject);
159164

@@ -621,8 +626,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
621626
error(opts->action == REPLAY_REVERT
622627
? _("could not revert %s... %s")
623628
: _("could not apply %s... %s"),
624-
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV),
625-
msg.subject);
629+
short_commit_name(commit), msg.subject);
626630
print_advice(res == 1, opts);
627631
rerere(opts->allow_rerere_auto);
628632
goto leave;

0 commit comments

Comments
 (0)