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>
Johannes Schindelin committed
Oct 21, 2016 at 14:24 UTC
3975596482b15defec2b7aff19207df18493475e
1 file changed
+7
-3
sequencer.c
+7
-3
@@ -147,13 +147,18 @@ struct commit_message {
147
const char *message;
148
};
149
150
+static const char *short_commit_name(struct commit *commit)
151
+{
152
+ return find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);
153
+}
154
+
155
static int get_message(struct commit *commit, struct commit_message *out)
156
{
157
const char *abbrev, *subject;
158
int subject_len;
159
160
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);
162
163
subject_len = find_commit_subject(out->message, &subject);
164
@@ -621,8 +626,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
626
error(opts->action == REPLAY_REVERT
627
? _("could not revert %s... %s")
628
: _("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);
630
print_advice(res == 1, opts);
631
rerere(opts->allow_rerere_auto);
632
goto leave;