path: root/builtin/revert.c
diff options
authorRamkumar Ramachandra <>2011-12-14 16:54:31 (GMT)
committerJunio C Hamano <>2011-12-15 21:16:52 (GMT)
commit9e1313648d4c0ee1bab0ee3d7ed22553bd5bf87c (patch)
tree019bc323b5844f3df5d3e90f2c8ed6b0ab591944 /builtin/revert.c
parent0db76962d156c196a23a98014c1585246f561a5d (diff)
revert: simplify getting commit subject in format_todo()
format_todo() calls get_message(), but uses only the subject line of the commit message. As a minor optimization, save work and unnecessary memory allocations by using find_commit_subject() instead. Also, remove the unnecessary check on cur->item->buffer: the lookup_commit_reference() call in parse_insn_line() has already made sure of this. Suggested-by: Jonathan Nieder <> Helped-by: Junio C Hamano <> Signed-off-by: Ramkumar Ramachandra <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/revert.c')
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin/revert.c b/builtin/revert.c
index 164552e..0a86fec 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -700,16 +700,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;