Commit e6b4a549 authored by Junio C Hamano's avatar Junio C Hamano

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
parents ab66fc27 1cf823fb
......@@ -106,24 +106,16 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)
static void print_new_head_line(struct commit *commit)
{
const char *hex, *body;
const char *msg;
hex = find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV);
printf(_("HEAD is now at %s"), hex);
msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
body = strstr(msg, "\n\n");
if (body) {
const char *eol;
size_t len;
body = skip_blank_lines(body + 2);
eol = strchr(body, '\n');
len = eol ? eol - body : strlen(body);
printf(" %.*s\n", (int) len, body);
}
else
printf("\n");
unuse_commit_buffer(commit, msg);
struct strbuf buf = STRBUF_INIT;
printf(_("HEAD is now at %s"),
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
if (buf.len > 0)
printf(" %s", buf.buf);
putchar('\n');
strbuf_release(&buf);
}
static void update_index_from_diff(struct diff_queue_struct *q,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment