mirror of
https://github.com/git/git.git
synced 2026-03-16 19:50:09 +01:00
revert: simplify getting commit subject in format_todo()
format_todo() calls get_message(), but uses only the subject line of the commit message. Save work and unnecessary memory allocations by using find_commit_subject() instead. Suggested-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
b9e6e42937
commit
e6010ee77a
@@ -680,16 +680,16 @@ static int format_todo(struct strbuf *buf, struct commit_list *todo_list,
|
||||
struct replay_opts *opts)
|
||||
{
|
||||
struct commit_list *cur = NULL;
|
||||
struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
|
||||
const char *sha1_abbrev = NULL;
|
||||
const char *action_str = opts->action == REVERT ? "revert" : "pick";
|
||||
const char *subject;
|
||||
int subject_len;
|
||||
|
||||
for (cur = todo_list; cur; cur = cur->next) {
|
||||
sha1_abbrev = find_unique_abbrev(cur->item->object.sha1, DEFAULT_ABBREV);
|
||||
if (get_message(cur->item, &msg))
|
||||
return error(_("Cannot get commit message for %s"), sha1_abbrev);
|
||||
strbuf_addf(buf, "%s %s %s\n", action_str, sha1_abbrev, msg.subject);
|
||||
free_message(&msg);
|
||||
subject_len = find_commit_subject(cur->item->buffer, &subject);
|
||||
strbuf_addf(buf, "%s %s %.*s\n", action_str, sha1_abbrev,
|
||||
subject_len, subject);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user