Skip to content

Commit e6b4a54

Browse files
committed
Merge branch 'tg/reset-hard-show-head-with-pretty'
The way "git reset --hard" reports the commit the updated HEAD points at is made consistent with the way how the commit title is generated by the other parts of the system. This matters when the title is spread across physically multiple lines. * tg/reset-hard-show-head-with-pretty: reset --hard: make use of the pretty machinery
2 parents ab66fc2 + 1cf823f commit e6b4a54

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

builtin/reset.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,16 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)
106106

107107
static void print_new_head_line(struct commit *commit)
108108
{
109-
const char *hex, *body;
110-
const char *msg;
111-
112-
hex = find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);
113-
printf(_("HEAD is now at %s"), hex);
114-
msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
115-
body = strstr(msg, "\n\n");
116-
if (body) {
117-
const char *eol;
118-
size_t len;
119-
body = skip_blank_lines(body + 2);
120-
eol = strchr(body, '\n');
121-
len = eol ? eol - body : strlen(body);
122-
printf(" %.*s\n", (int) len, body);
123-
}
124-
else
125-
printf("\n");
126-
unuse_commit_buffer(commit, msg);
109+
struct strbuf buf = STRBUF_INIT;
110+
111+
printf(_("HEAD is now at %s"),
112+
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
113+
114+
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
115+
if (buf.len > 0)
116+
printf(" %s", buf.buf);
117+
putchar('\n');
118+
strbuf_release(&buf);
127119
}
128120

129121
static void update_index_from_diff(struct diff_queue_struct *q,

0 commit comments

Comments
 (0)