summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-02-15 22:55:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-02-15 22:55:45 (GMT)
commite6b4a549c3b2189a8cbd154ee0a3dac511061842 (patch)
tree8ad4d52a67c0ad1688913cc57e140580eb1b4fba
parentab66fc2705b35833582d74a8cd90ac0cf7586f89 (diff)
parent1cf823fb68cae95fa1887e9eaa314c2b6e619e09 (diff)
downloadgit-e6b4a549c3b2189a8cbd154ee0a3dac511061842.zip
git-e6b4a549c3b2189a8cbd154ee0a3dac511061842.tar.gz
git-e6b4a549c3b2189a8cbd154ee0a3dac511061842.tar.bz2
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
-rw-r--r--builtin/reset.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/builtin/reset.c b/builtin/reset.c
index e15f595..5da0f75 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -106,24 +106,16 @@ out:
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,