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
This commit is contained in:
Junio C Hamano 2018-02-15 14:55:45 -08:00
Родитель ab66fc2705 1cf823fb68
Коммит e6b4a549c3
1 изменённых файлов: 9 добавлений и 17 удалений

Просмотреть файл

@ -106,24 +106,16 @@ out:
static void print_new_head_line(struct commit *commit) static void print_new_head_line(struct commit *commit)
{ {
const char *hex, *body; struct strbuf buf = STRBUF_INIT;
const char *msg;
hex = find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV); printf(_("HEAD is now at %s"),
printf(_("HEAD is now at %s"), hex); find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
body = strstr(msg, "\n\n"); pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
if (body) { if (buf.len > 0)
const char *eol; printf(" %s", buf.buf);
size_t len; putchar('\n');
body = skip_blank_lines(body + 2); strbuf_release(&buf);
eol = strchr(body, '\n');
len = eol ? eol - body : strlen(body);
printf(" %.*s\n", (int) len, body);
}
else
printf("\n");
unuse_commit_buffer(commit, msg);
} }
static void update_index_from_diff(struct diff_queue_struct *q, static void update_index_from_diff(struct diff_queue_struct *q,