{"thread":{"id":"52187","subject":"[PATCH 0/8] learn the \"summary\" pretty format","startedAt":"2019-11-04T20:03:49Z","lastAt":"2019-11-20T03:16:07Z","messageCount":81,"participants":["Denton Liu","Eric Sunshine","Junio C Hamano","René Scharfe","SZEDER Gábor","Todd Zullinger"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"385420","messageId":"cover.1572897736.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":null,"subject":"[PATCH 0/8] learn the \"summary\" pretty format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:03:43Z","receivedAt":"2019-11-04T20:03:49Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"On this mailing list (and many others) the standard way to reference\nother commits with the \"summary\" format, e.g. \"f86a374 (\"pack-bitmap.c:\nfix a memleak\", 2015-03-30)\". Since it's so commonly used, let's\nstandardise it as a pretty format.\\n\n\nDenton Liu (8):\n  pretty-formats.txt: use generic terms for hash\n  revision: make get_revision_mark() return const pointer\n  revision: change abbrev_commit_given to abbrev_commit_explicit\n  pretty.c: inline initalize format_context\n  pretty.c: extract functionality to repo_format_commit_generic()\n  reflog-walk.c: don't print last newline with oneline\n  pretty: implement 'summary' format\n  SubmittingPatches: use `--pretty=summary`\n\n Documentation/SubmittingPatches    |  6 +++\n Documentation/pretty-formats.txt   | 25 ++++++----\n Documentation/pretty-options.txt   |  2 +-\n Documentation/rev-list-options.txt |  2 +-\n builtin/log.c                      | 30 ++++++++++--\n log-tree.c                         | 15 ++++--\n pretty.c                           | 74 +++++++++++++++++++++++++-----\n pretty.h                           |  1 +\n reflog-walk.c                      |  6 ++-\n revision.c                         |  7 +--\n revision.h                         |  6 +--\n t/t4205-log-pretty-formats.sh      | 52 +++++++++++++++++++++\n 12 files changed, 188 insertions(+), 38 deletions(-)\n\n-- \n2.24.0.rc2.262.g2d07a97ef5\n\n"},{"id":"385421","messageId":"09ab0c587b93ddce25888f5676e9d6ca0ac16fe4.1572897736.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1572897736.git.liu.denton@gmail.com","subject":"[PATCH 1/8] pretty-formats.txt: use generic terms for hash","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:03:46Z","receivedAt":"2019-11-04T20:03:52Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git is planning on upgrading from SHA-1 to be more hash-agnostic,\nreplace specific references to SHA-1 with more generic terminology.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex b87e2e83e6..71eef684d0 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -4,7 +4,7 @@ PRETTY FORMATS\n If the commit is a merge, and if the pretty-format\n is not 'oneline', 'email' or 'raw', an additional line is\n inserted before the 'Author:' line.  This line begins with\n-\"Merge: \" and the sha1s of ancestral commits are printed,\n+\"Merge: \" and the hashes of ancestral commits are printed,\n separated by spaces.  Note that the listed commits may not\n necessarily be the list of the *direct* parent commits if you\n have limited your view of history: for example, if you are\n@@ -20,20 +20,20 @@ built-in formats:\n \n * 'oneline'\n \n-\t  <sha1> <title line>\n+\t  <hash> <title line>\n +\n This is designed to be as compact as possible.\n \n * 'short'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \n \t      <title line>\n \n * 'medium'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Date:   <author date>\n \n@@ -43,7 +43,7 @@ This is designed to be as compact as possible.\n \n * 'full'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Commit: <committer>\n \n@@ -53,7 +53,7 @@ This is designed to be as compact as possible.\n \n * 'fuller'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author:     <author>\n \t  AuthorDate: <author date>\n \t  Commit:     <committer>\n@@ -65,7 +65,7 @@ This is designed to be as compact as possible.\n \n * 'email'\n \n-\t  From <sha1> <date>\n+\t  From <hash> <date>\n \t  From: <author>\n \t  Date: <author date>\n \t  Subject: [PATCH] <title line>\n@@ -75,7 +75,7 @@ This is designed to be as compact as possible.\n * 'raw'\n +\n The 'raw' format shows the entire commit exactly as\n-stored in the commit object.  Notably, the SHA-1s are\n+stored in the commit object.  Notably, the hashes are\n displayed in full, regardless of whether --abbrev or\n --no-abbrev are used, and 'parents' information show the\n true parent commits, without taking grafts or history\n-- \n2.24.0.rc2.262.g2d07a97ef5\n\n"},{"id":"385422","messageId":"743a91029960eb134420bd315eb0d5076a40427f.1572897736.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1572897736.git.liu.denton@gmail.com","subject":"[PATCH 2/8] revision: make get_revision_mark() return const pointer","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:03:50Z","receivedAt":"2019-11-04T20:03:54Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"get_revision_mark() used to return a `char *`, even though all of the\nstrings it was returning were string literals. Make get_revision_mark()\nreturn a `const char *` so that callers won't be tempted to modify the\nreturned string.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n revision.c | 4 ++--\n revision.h | 4 ++--\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 0e39b2b8a5..2151b119b7 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -3944,7 +3944,7 @@ struct commit *get_revision(struct rev_info *revs)\n \treturn c;\n }\n \n-char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n+const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n \tif (commit->object.flags & BOUNDARY)\n \t\treturn \"-\";\n@@ -3966,7 +3966,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit\n \n void put_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n-\tchar *mark = get_revision_mark(revs, commit);\n+\tconst char *mark = get_revision_mark(revs, commit);\n \tif (!strlen(mark))\n \t\treturn;\n \tfputs(mark, stdout);\ndiff --git a/revision.h b/revision.h\nindex 4134dc6029..addd69410b 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,\n void reset_revision_walk(void);\n int prepare_revision_walk(struct rev_info *revs);\n struct commit *get_revision(struct rev_info *revs);\n-char *get_revision_mark(const struct rev_info *revs,\n-\t\t\tconst struct commit *commit);\n+const char *get_revision_mark(const struct rev_info *revs,\n+\t\t\t      const struct commit *commit);\n void put_revision_mark(const struct rev_info *revs,\n \t\t       const struct commit *commit);\n \n-- \n2.24.0.rc2.262.g2d07a97ef5\n\n"},{"id":"385423","messageId":"f6f6b3d6710c7375db3e92f97245f8cf20231d1d.1572897736.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1572897736.git.liu.denton@gmail.com","subject":"[PATCH 3/8] revision: change abbrev_commit_given to abbrev_commit_explicit","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:03:52Z","receivedAt":"2019-11-04T20:03:57Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In a future patch, we want to know if `--[no-]abbrev-commit` arguments\nhave been explicitly provided. Since `rev_info.abbrev_commit_given` is\nonly used in one place, co-opt it to become\n`rev_info.abbrev_commit_explicit`. This information will be used in a\nfuture patch.\n\nWith this change, the semantics of the original usage (in\nthe `--pretty=raw` codepath) aren't altered.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n builtin/log.c | 2 +-\n revision.c    | 3 ++-\n revision.h    | 2 +-\n 3 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 89873d2dc2..e4df16be79 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -230,7 +230,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \t\t */\n \t\tif (!decoration_given)\n \t\t\tdecoration_style = 0;\n-\t\tif (!rev->abbrev_commit_given)\n+\t\tif (!rev->abbrev_commit_explicit)\n \t\t\trev->abbrev_commit = 0;\n \t}\n \ndiff --git a/revision.c b/revision.c\nindex 2151b119b7..02b49ab754 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -2271,9 +2271,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\t\trevs->abbrev = hexsz;\n \t} else if (!strcmp(arg, \"--abbrev-commit\")) {\n \t\trevs->abbrev_commit = 1;\n-\t\trevs->abbrev_commit_given = 1;\n+\t\trevs->abbrev_commit_explicit = 1;\n \t} else if (!strcmp(arg, \"--no-abbrev-commit\")) {\n \t\trevs->abbrev_commit = 0;\n+\t\trevs->abbrev_commit_explicit = 1;\n \t} else if (!strcmp(arg, \"--full-diff\")) {\n \t\trevs->diff = 1;\n \t\trevs->full_diff = 1;\ndiff --git a/revision.h b/revision.h\nindex addd69410b..7670f29973 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -185,7 +185,7 @@ struct rev_info {\n \t\t\tshow_signature:1,\n \t\t\tpretty_given:1,\n \t\t\tabbrev_commit:1,\n-\t\t\tabbrev_commit_given:1,\n+\t\t\tabbrev_commit_explicit:1,\n \t\t\tzero_commit:1,\n \t\t\tuse_terminator:1,\n \t\t\tmissing_newline:1,\n-- \n2.24.0.rc2.262.g2d07a97ef5\n\n"},{"id":"385424","messageId":"1551e903225bb4f7652341382d0c1cf71b9bd7d4.1572897736.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1572897736.git.liu.denton@gmail.com","subject":"[PATCH 4/8] pretty.c: inline initalize format_context","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:03:55Z","receivedAt":"2019-11-04T20:04:00Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Instead of memsetting and then initializing the fields in the struct,\nmove the initialization of `format_context` to its assignment.\n\nIn preparation for a future commit where we mechanically move lines from\nrepo_format_commit_message() into a helper function,\n`format_context.wrap_start` is not generically used so move its\nassignment closer to its use.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n pretty.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex b32f036953..6f2b0ad917 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1610,14 +1610,13 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\tconst char *format, struct strbuf *sb,\n \t\t\t\tconst struct pretty_print_context *pretty_ctx)\n {\n-\tstruct format_commit_context context;\n+\tstruct format_commit_context context = {\n+\t\t.commit = commit,\n+\t\t.pretty_ctx = pretty_ctx\n+\t};\n \tconst char *output_enc = pretty_ctx->output_encoding;\n \tconst char *utf8 = \"UTF-8\";\n \n-\tmemset(&context, 0, sizeof(context));\n-\tcontext.commit = commit;\n-\tcontext.pretty_ctx = pretty_ctx;\n-\tcontext.wrap_start = sb->len;\n \t/*\n \t * convert a commit message to UTF-8 first\n \t * as far as 'format_commit_item' assumes it in UTF-8\n@@ -1626,6 +1625,7 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\t\t       &context.commit_encoding,\n \t\t\t\t\t       utf8);\n \n+\tcontext.wrap_start = sb->len;\n \tstrbuf_expand(sb, format, format_commit_item, &context);\n \trewrap_message_tail(sb, &context, 0, 0, 0);\n \n-- \n2.24.0.rc2.262.g2d07a97ef5\n\n"},{"id":"385425","messageId":"e54b8ef8779b2cafd2aba45074f1b6680f4d7221.1572897736.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1572897736.git.liu.denton@gmail.com","subject":"[PATCH 5/8] pretty.c: extract functionality to repo_format_commit_generic()","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:03:58Z","receivedAt":"2019-11-04T20:04:04Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In a future commit, we will be reusing common functionality from\nrepo_format_commit_message(). Extract this common functionality into\nrepo_format_commit_generic() so that it can be reused in the future.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n pretty.c | 35 ++++++++++++++++++++++++++++-------\n 1 file changed, 28 insertions(+), 7 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 6f2b0ad917..a6e5fc115a 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1605,10 +1605,14 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)\n \tstrbuf_release(&dummy);\n }\n \n-void repo_format_commit_message(struct repository *r,\n-\t\t\t\tconst struct commit *commit,\n-\t\t\t\tconst char *format, struct strbuf *sb,\n-\t\t\t\tconst struct pretty_print_context *pretty_ctx)\n+static void repo_format_commit_generic(struct repository *r,\n+\t\t\t\t       const struct commit *commit,\n+\t\t\t\t       struct strbuf *sb,\n+\t\t\t\t       const struct pretty_print_context *pretty_ctx,\n+\t\t\t\t       void (*fn)(struct strbuf *,\n+\t\t\t\t\t\t  struct format_commit_context *,\n+\t\t\t\t\t\t  void *),\n+\t\t\t\t       void *data)\n {\n \tstruct format_commit_context context = {\n \t\t.commit = commit,\n@@ -1625,9 +1629,7 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\t\t       &context.commit_encoding,\n \t\t\t\t\t       utf8);\n \n-\tcontext.wrap_start = sb->len;\n-\tstrbuf_expand(sb, format, format_commit_item, &context);\n-\trewrap_message_tail(sb, &context, 0, 0, 0);\n+\tfn(sb, &context, data);\n \n \t/* then convert a commit message to an actual output encoding */\n \tif (output_enc) {\n@@ -1651,6 +1653,25 @@ void repo_format_commit_message(struct repository *r,\n \trepo_unuse_commit_buffer(r, commit, context.message);\n }\n \n+static void do_repo_format_commit_message(struct strbuf *sb,\n+\t\t\t\t\t  struct format_commit_context *context,\n+\t\t\t\t\t  void *data)\n+{\n+\tconst char *format = data;\n+\tcontext->wrap_start = sb->len;\n+\tstrbuf_expand(sb, format, format_commit_item, context);\n+\trewrap_message_tail(sb, context, 0, 0, 0);\n+}\n+\n+void repo_format_commit_message(struct repository *r,\n+\t\t\t\tconst struct commit *commit,\n+\t\t\t\tconst char *format, struct strbuf *sb,\n+\t\t\t\tconst struct pretty_print_context *pretty_ctx)\n+{\n+\trepo_format_commit_generic(r, commit, sb, pretty_ctx,\n+\t\t\t\t   do_repo_format_commit_message, (void *)format);\n+}\n+\n static void pp_header(struct pretty_print_context *pp,\n \t\t      const char *encoding,\n \t\t      const struct commit *commit,\n-- \n2.24.0.rc2.262.g2d07a97ef5\n\n"},{"id":"385426","messageId":"449c58009ae46d43ec2bd0499674c9858b706d04.1572897736.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1572897736.git.liu.denton@gmail.com","subject":"[PATCH 6/8] reflog-walk.c: don't print last newline with oneline","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:04:01Z","receivedAt":"2019-11-04T20:04:06Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In a future commit, we want to possibly be able to continue the reflog message on\nthe same line without breaking the line. As a result, when\n`oneline == 1`, strip any trailing new lines.\n\nAdd these missing newlines back in show_log().\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n log-tree.c    | 4 +++-\n reflog-walk.c | 6 +++++-\n 2 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex 923a299e70..4a7d668af6 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -661,8 +661,10 @@ void show_log(struct rev_info *opt)\n \t\t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n \t\t\t\t\t    &opt->date_mode,\n \t\t\t\t\t    opt->date_mode_explicit);\n-\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE)\n+\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n+\t\t\t\tputc('\\n', opt->diffopt.file);\n \t\t\t\treturn;\n+\t\t\t}\n \t\t}\n \t}\n \ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 3a25b27d8f..e2b4c0b290 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -285,7 +285,11 @@ void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,\n \t\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n \t\tget_reflog_selector(&selector, reflog_info, dmode, force_date, 0);\n \t\tif (oneline) {\n-\t\t\tprintf(\"%s: %s\", selector.buf, info->message);\n+\t\t\tstruct strbuf message = STRBUF_INIT;\n+\t\t\tstrbuf_addstr(&message, info->message);\n+\t\t\tstrbuf_trim_trailing_newline(&message);\n+\t\t\tprintf(\"%s: %s\", selector.buf, message.buf);\n+\t\t\tstrbuf_release(&message);\n \t\t}\n \t\telse {\n \t\t\tprintf(\"Reflog: %s (%s)\\nReflog message: %s\",\n-- \n2.24.0.rc2.262.g2d07a97ef5\n\n"},{"id":"385427","messageId":"64b6f7c9d7434ba39929220c1aebcd9a1fd0ad6e.1572897736.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1572897736.git.liu.denton@gmail.com","subject":"[PATCH 7/8] pretty: implement 'summary' format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:04:04Z","receivedAt":"2019-11-04T20:04:09Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"The standard format for referencing other commits within some projects\n(such as git.git) is the summary format. This is described in\nDocumentation/SubmittingPatches as\n\n\tIf you want to reference a previous commit in the history of a stable\n\tbranch, use the format \"abbreviated sha1 (subject, date)\",\n\twith the subject enclosed in a pair of double-quotes, like this:\n\n\t....\n\t\tCommit f86a374 (\"pack-bitmap.c: fix a memleak\", 2015-03-30)\n\t\tnoticed that ...\n\t....\n\nSince this format is so commonly used, standardize it as a pretty\nformat.\n\nThis format is implemented as a separate flow that skips most of\npretty_print_commit() and instead calls format_commit_summary(). The\nreason why this is done is because the other pretty formats expect\noutput to be generated in a specific order. Specifically, the header,\nincluding the date, is always printed before the commit message,\nincluding the subject. Reversing the order would be possible but would\ninvolve butchering pretty_print_commit() so it is implemented as a\nseparate flow.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt   |  9 ++++++\n Documentation/pretty-options.txt   |  2 +-\n Documentation/rev-list-options.txt |  2 +-\n builtin/log.c                      | 30 ++++++++++++++---\n log-tree.c                         | 11 +++++--\n pretty.c                           | 31 +++++++++++++++++-\n pretty.h                           |  1 +\n t/t4205-log-pretty-formats.sh      | 52 ++++++++++++++++++++++++++++++\n 8 files changed, 127 insertions(+), 11 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 71eef684d0..5641903b93 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -63,6 +63,15 @@ This is designed to be as compact as possible.\n \n \t       <full commit message>\n \n+* 'summary'\n+\n+\t  <abbrev hash> (\"<title line>\", <short author date>)\n++\n+This format is useful for referring to other commits when writing a new\n+commit message. Although by default, '<abbrev sha1>' is used, this can\n+be overridden with '--no-abbrev'. In addition, '<short author date>' can\n+be overridden by with '--date='.\n+\n * 'email'\n \n \t  From <hash> <date>\ndiff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\nindex e44fc8f738..0a5b206193 100644\n--- a/Documentation/pretty-options.txt\n+++ b/Documentation/pretty-options.txt\n@@ -3,7 +3,7 @@\n \n \tPretty-print the contents of the commit logs in a given format,\n \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n-\t'full', 'fuller', 'email', 'raw', 'format:<string>'\n+\t'full', 'fuller', 'summary', 'email', 'raw', 'format:<string>'\n \tand 'tformat:<string>'.  When '<format>' is none of the above,\n \tand has '%placeholder' in it, it acts as if\n \t'--pretty=tformat:<format>' were given.\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex 90ff9e2bea..76df494ed6 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -289,7 +289,7 @@ depending on a few rules:\n 4. Otherwise, show the index format.\n --\n +\n-Under `--pretty=oneline`, the commit message is\n+Under `--pretty=oneline` and `--pretty=summary`, the commit message is\n prefixed with this information on the same line.\n This option cannot be combined with `--reverse`.\n See also linkgit:git-reflog[1].\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e4df16be79..ad96a746a3 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -223,15 +223,35 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \t\tread_mailmap(rev->mailmap, NULL);\n \t}\n \n-\tif (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {\n+\tif (rev->pretty_given) {\n+\t\tswitch (rev->commit_format) {\n+\n \t\t/*\n \t\t * \"log --pretty=raw\" is special; ignore UI oriented\n \t\t * configuration variables such as decoration.\n \t\t */\n-\t\tif (!decoration_given)\n-\t\t\tdecoration_style = 0;\n-\t\tif (!rev->abbrev_commit_explicit)\n-\t\t\trev->abbrev_commit = 0;\n+\t\tcase CMIT_FMT_RAW:\n+\t\t\tif (!decoration_given)\n+\t\t\t\tdecoration_style = 0;\n+\t\t\tif (!rev->abbrev_commit_explicit)\n+\t\t\t\trev->abbrev_commit = 0;\n+\t\t\tbreak;\n+\n+\t\t/*\n+\t\t * \"log --pretty=summary\" is special; ignore UI oriented\n+\t\t * configuration variables such as decoration but keep\n+\t\t * abbreviations.\n+\t\t */\n+\t\tcase CMIT_FMT_SUMMARY:\n+\t\t\tif (!decoration_given)\n+\t\t\t\tdecoration_style = 0;\n+\t\t\tif (!rev->abbrev_commit_explicit)\n+\t\t\t\trev->abbrev_commit = 1;\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n \t}\n \n \tif (decoration_style) {\ndiff --git a/log-tree.c b/log-tree.c\nindex 4a7d668af6..433adaf0f1 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -627,7 +627,8 @@ void show_log(struct rev_info *opt)\n \t\tctx.print_email_subject = 1;\n \t} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {\n \t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), opt->diffopt.file);\n-\t\tif (opt->commit_format != CMIT_FMT_ONELINE)\n+\t\tif (opt->commit_format != CMIT_FMT_ONELINE &&\n+\t\t    opt->commit_format != CMIT_FMT_SUMMARY)\n \t\t\tfputs(\"commit \", opt->diffopt.file);\n \n \t\tif (!opt->graph)\n@@ -644,7 +645,8 @@ void show_log(struct rev_info *opt)\n \t\t\t       find_unique_abbrev(&parent->object.oid, abbrev_commit));\n \t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);\n \t\tshow_decorations(opt, commit);\n-\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n+\t\tif (opt->commit_format == CMIT_FMT_ONELINE ||\n+\t\t    opt->commit_format == CMIT_FMT_SUMMARY) {\n \t\t\tputc(' ', opt->diffopt.file);\n \t\t} else {\n \t\t\tputc('\\n', opt->diffopt.file);\n@@ -658,12 +660,15 @@ void show_log(struct rev_info *opt)\n \t\t\t * graph info here.\n \t\t\t */\n \t\t\tshow_reflog_message(opt->reflog_info,\n-\t\t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n+\t\t\t\t\t    (opt->commit_format == CMIT_FMT_ONELINE ||\n+\t\t\t\t\t     opt->commit_format == CMIT_FMT_SUMMARY),\n \t\t\t\t\t    &opt->date_mode,\n \t\t\t\t\t    opt->date_mode_explicit);\n \t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n \t\t\t\tputc('\\n', opt->diffopt.file);\n \t\t\t\treturn;\n+\t\t\t} else if (opt->commit_format == CMIT_FMT_SUMMARY) {\n+\t\t\t\tputc(' ', opt->diffopt.file);\n \t\t\t}\n \t\t}\n \t}\ndiff --git a/pretty.c b/pretty.c\nindex a6e5fc115a..8efb2486a5 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -97,7 +97,8 @@ static void setup_commit_formats(void)\n \t\t{ \"mboxrd\",\tCMIT_FMT_MBOXRD,\t0,\t0 },\n \t\t{ \"fuller\",\tCMIT_FMT_FULLER,\t0,\t8 },\n \t\t{ \"full\",\tCMIT_FMT_FULL,\t\t0,\t8 },\n-\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 }\n+\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 },\n+\t\t{ \"summary\",\tCMIT_FMT_SUMMARY,\t1,\t0 },\n \t\t/*\n \t\t * Please update $__git_log_pretty_formats in\n \t\t * git-completion.bash when you add new formats.\n@@ -1672,6 +1673,26 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\t   do_repo_format_commit_message, (void *)format);\n }\n \n+static void do_repo_format_commit_summary(struct strbuf *sb,\n+\t\t\t\t\t  struct format_commit_context *context,\n+\t\t\t\t\t  void *additional_context)\n+{\n+\tstruct ident_split ident;\n+\n+\tparse_commit_header(context);\n+\tparse_commit_message(context);\n+\n+\tstrbuf_addstr(sb, \"(\\\"\");\n+\tformat_subject(sb, context->message + context->subject_off, \" \");\n+\tif (!split_ident_line(&ident,\n+\t\t\t      context->message + context->author.off,\n+\t\t\t      context->author.len)) {\n+\t\tstrbuf_addstr(sb, \"\\\", \");\n+\t\tstrbuf_addstr(sb, show_ident_date(&ident, &context->pretty_ctx->date_mode));\n+\t}\n+\tstrbuf_addstr(sb, \")\");\n+}\n+\n static void pp_header(struct pretty_print_context *pp,\n \t\t      const char *encoding,\n \t\t      const struct commit *commit,\n@@ -1923,6 +1944,14 @@ void pretty_print_commit(struct pretty_print_context *pp,\n \t\tformat_commit_message(commit, user_format, sb, pp);\n \t\treturn;\n \t}\n+\tif (pp->fmt == CMIT_FMT_SUMMARY) {\n+\t\tif (!pp->date_mode_explicit)\n+\t\t\tpp->date_mode = *DATE_MODE(SHORT);\n+\n+\t\trepo_format_commit_generic(the_repository, commit, sb, pp,\n+\t\t\t\t\t   do_repo_format_commit_summary, NULL);\n+\t\treturn;\n+\t}\n \n \tencoding = get_log_output_encoding();\n \tmsg = reencoded = logmsg_reencode(commit, NULL, encoding);\ndiff --git a/pretty.h b/pretty.h\nindex 4ad1fc31ff..6d5b18a4f1 100644\n--- a/pretty.h\n+++ b/pretty.h\n@@ -16,6 +16,7 @@ enum cmit_fmt {\n \tCMIT_FMT_FULL,\n \tCMIT_FMT_FULLER,\n \tCMIT_FMT_ONELINE,\n+\tCMIT_FMT_SUMMARY,\n \tCMIT_FMT_EMAIL,\n \tCMIT_FMT_MBOXRD,\n \tCMIT_FMT_USERFORMAT,\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex f42a69faa2..09b1a33cf1 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -788,4 +788,56 @@ test_expect_success '%S in git log --format works with other placeholders (part\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'log --pretty=summary' '\n+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with log.date is overridden by short date' '\n+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\ttest_config log.date rfc &&\n+\tgit log --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with explicit date overrides short date' '\n+\tgit log --date=rfc --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --date=rfc --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with log.abbrevCommit is overidden' '\n+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\ttest_config log.abbrevCommit false &&\n+\tgit log --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with explicit --no-abbrev overrides abbreviated' '\n+\tgit log --date=short --pretty=\"tformat:%H (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --no-abbrev --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with log.decorate is overridden' '\n+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\ttest_config log.decorate short &&\n+\tgit log --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with explicit decorate overrides no decoration' '\n+\tgit log --date=short --pretty=\"tformat:%h%d (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --decorate=short --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with --walk-reflogs' '\n+\ttest_config log.date short &&\n+\tgit log --walk-reflogs --pretty=\"tformat:%h %gd: %gs (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --walk-reflogs --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.24.0.rc2.262.g2d07a97ef5\n\n"},{"id":"385428","messageId":"0b861a47890a3d1e193d520f4678d017aac87207.1572897736.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1572897736.git.liu.denton@gmail.com","subject":"[PATCH 8/8] SubmittingPatches: use `--pretty=summary`","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:04:07Z","receivedAt":"2019-11-04T20:04:11Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git was taught the `--pretty=summary` option, it is no longer\nnecessary to manually specify the format string to get the commit\nsummary. Teach users to use the new option while keeping the old\ninvocation around in case they have an older version of Git.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex 1a60cc1329..6969ecca45 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -153,6 +153,12 @@ with the subject enclosed in a pair of double-quotes, like this:\n The \"Copy commit summary\" command of gitk can be used to obtain this\n format, or this invocation of `git show`:\n \n+....\n+\tgit show -s --pretty=summary <commit>\n+....\n+\n+or, on an older version of Git without support for --pretty=summary:\n+\n ....\n \tgit show -s --date=short --pretty='format:%h (\"%s\", %ad)' <commit>\n ....\n-- \n2.24.0.rc2.262.g2d07a97ef5\n\n"},{"id":"385429","messageId":"CAPig+cRVgf3q6-mHeMgOThCrhseTGtYt+S6x1ikUSEKGbUTz4g@mail.gmail.com","threadId":"52187","inReplyTo":"64b6f7c9d7434ba39929220c1aebcd9a1fd0ad6e.1572897736.git.liu.denton@gmail.com","subject":"Re: [PATCH 7/8] pretty: implement 'summary' format","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-11-04T20:16:56Z","receivedAt":"2019-11-04T20:17:09Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Nov 4, 2019 at 3:04 PM Denton Liu <liu.denton@gmail.com> wrote:\n> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\n> @@ -63,6 +63,15 @@ This is designed to be as compact as possible.\n> +* 'summary'\n> +\n> +         <abbrev hash> (\"<title line>\", <short author date>)\n> ++\n> +This format is useful for referring to other commits when writing a new\n> +commit message. Although by default, '<abbrev sha1>' is used, this can\n\nWhy does this talk about \"sha1\" when patch 1/8 removed references to\nSHA-1 in favor of generic \"hashes\"?\n\n> +be overridden with '--no-abbrev'. In addition, '<short author date>' can\n> +be overridden by with '--date='.\n"},{"id":"385430","messageId":"20191104203558.GA8004@generichostname","threadId":"52187","inReplyTo":"CAPig+cRVgf3q6-mHeMgOThCrhseTGtYt+S6x1ikUSEKGbUTz4g@mail.gmail.com","subject":"Re: [PATCH 7/8] pretty: implement 'summary' format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:35:58Z","receivedAt":"2019-11-04T20:36:06Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi Eric,\n\nOn Mon, Nov 04, 2019 at 03:16:56PM -0500, Eric Sunshine wrote:\n> On Mon, Nov 4, 2019 at 3:04 PM Denton Liu <liu.denton@gmail.com> wrote:\n> > diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\n> > @@ -63,6 +63,15 @@ This is designed to be as compact as possible.\n> > +* 'summary'\n> > +\n> > +         <abbrev hash> (\"<title line>\", <short author date>)\n> > ++\n> > +This format is useful for referring to other commits when writing a new\n> > +commit message. Although by default, '<abbrev sha1>' is used, this can\n> \n> Why does this talk about \"sha1\" when patch 1/8 removed references to\n> SHA-1 in favor of generic \"hashes\"?\n\nGood catch. 1/8 modified pretty-formats.txt but this message references\nthe content in SubmittingPatches.\n\nIn a future reroll, I'll submit a similar patch as 1/8 but targeting\nSubmittingPatches instead.\n\nThanks,\n\nDenton\n\n> \n> > +be overridden with '--no-abbrev'. In addition, '<short author date>' can\n> > +be overridden by with '--date='.\n"},{"id":"385431","messageId":"CAPig+cRqYhUACkUKKzy2bCY7pZn=mZFVdxepKuiKuvwBEBJ5xA@mail.gmail.com","threadId":"52187","inReplyTo":"20191104203558.GA8004@generichostname","subject":"Re: [PATCH 7/8] pretty: implement 'summary' format","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-11-04T20:38:54Z","receivedAt":"2019-11-04T20:39:10Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Nov 4, 2019 at 3:36 PM Denton Liu <liu.denton@gmail.com> wrote:\n> On Mon, Nov 04, 2019 at 03:16:56PM -0500, Eric Sunshine wrote:\n> > On Mon, Nov 4, 2019 at 3:04 PM Denton Liu <liu.denton@gmail.com> wrote:\n> > > diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\n> > > @@ -63,6 +63,15 @@ This is designed to be as compact as possible.\n> > > +* 'summary'\n> > > +\n> > > +         <abbrev hash> (\"<title line>\", <short author date>)\n> > > ++\n> > > +This format is useful for referring to other commits when writing a new\n> > > +commit message. Although by default, '<abbrev sha1>' is used, this can\n> >\n> > Why does this talk about \"sha1\" when patch 1/8 removed references to\n> > SHA-1 in favor of generic \"hashes\"?\n>\n> Good catch. 1/8 modified pretty-formats.txt but this message references\n> the content in SubmittingPatches.\n\nI'm not sure what you mean. This change is touching\npretty-formats.txt, not SubmittingPatches.\n"},{"id":"385432","messageId":"20191104204505.GA8559@generichostname","threadId":"52187","inReplyTo":"CAPig+cRqYhUACkUKKzy2bCY7pZn=mZFVdxepKuiKuvwBEBJ5xA@mail.gmail.com","subject":"Re: [PATCH 7/8] pretty: implement 'summary' format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-04T20:45:05Z","receivedAt":"2019-11-04T20:45:10Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"On Mon, Nov 04, 2019 at 03:38:54PM -0500, Eric Sunshine wrote:\n> On Mon, Nov 4, 2019 at 3:36 PM Denton Liu <liu.denton@gmail.com> wrote:\n> > On Mon, Nov 04, 2019 at 03:16:56PM -0500, Eric Sunshine wrote:\n> > > On Mon, Nov 4, 2019 at 3:04 PM Denton Liu <liu.denton@gmail.com> wrote:\n> > > > diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\n> > > > @@ -63,6 +63,15 @@ This is designed to be as compact as possible.\n> > > > +* 'summary'\n> > > > +\n> > > > +         <abbrev hash> (\"<title line>\", <short author date>)\n> > > > ++\n> > > > +This format is useful for referring to other commits when writing a new\n> > > > +commit message. Although by default, '<abbrev sha1>' is used, this can\n> > >\n> > > Why does this talk about \"sha1\" when patch 1/8 removed references to\n> > > SHA-1 in favor of generic \"hashes\"?\n> >\n> > Good catch. 1/8 modified pretty-formats.txt but this message references\n> > the content in SubmittingPatches.\n> \n> I'm not sure what you mean. This change is touching\n> pretty-formats.txt, not SubmittingPatches.\n\nMy mistake, you were referring to the patch text which is also indeed\nincorrect. I skimmed your message too quickly and I thought you were\nreferring to the commit message which also references \"sha1\" but in the\ncontext of SubmittingPatches.\n"},{"id":"385538","messageId":"xmqqwocdtwpa.fsf@gitster-ct.c.googlers.com","threadId":"52187","inReplyTo":"449c58009ae46d43ec2bd0499674c9858b706d04.1572897736.git.liu.denton@gmail.com","subject":"Re: [PATCH 6/8] reflog-walk.c: don't print last newline with oneline","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-06T05:12:17Z","receivedAt":"2019-11-06T05:12:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denton Liu <liu.denton@gmail.com> writes:\n\n> Subject: Re: [PATCH 6/8] reflog-walk.c: don't print last newline with oneline\n\nPlease find a better phrasing that does not mislead the readers to\nthink \"eek, so now output from 'git log -g --oneline' does not get\nLF terminated?\"\n\nI think you are just changing the place where the LF is given from\nthe callee that shows a single record (and then used to show LF\nafter the record) to the caller that calls the callee (and now it\nshows LF after the call returns), in order to preserve the output,\nbut with the given proposed log message, it is not clear if that is\nwhat you meant to do (I can read from the code what _is_ going on,\nbut the log is to record what you _wanted_ to do, which can be\ndifferent).\n\n> @@ -661,8 +661,10 @@ void show_log(struct rev_info *opt)\n\nIn the pre-context before this line there is a guard to ensure that\nwe do this only when showing an entry from the reflog, so the effect\nof this hunk is \"when showing from reflog in --oneline format, show\nLF after showing a single record\" ...\n\n>  \t\t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n>  \t\t\t\t\t    &opt->date_mode,\n>  \t\t\t\t\t    opt->date_mode_explicit);\n> -\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE)\n> +\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n> +\t\t\t\tputc('\\n', opt->diffopt.file);\n>  \t\t\t\treturn;\n> +\t\t\t}\n>  \t\t}\n>  \t}\n>  \n> diff --git a/reflog-walk.c b/reflog-walk.c\n> index 3a25b27d8f..e2b4c0b290 100644\n> --- a/reflog-walk.c\n> +++ b/reflog-walk.c\n> @@ -285,7 +285,11 @@ void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,\n>  \t\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n>  \t\tget_reflog_selector(&selector, reflog_info, dmode, force_date, 0);\n>  \t\tif (oneline) {\n> -\t\t\tprintf(\"%s: %s\", selector.buf, info->message);\n> +\t\t\tstruct strbuf message = STRBUF_INIT;\n> +\t\t\tstrbuf_addstr(&message, info->message);\n> +\t\t\tstrbuf_trim_trailing_newline(&message);\n> +\t\t\tprintf(\"%s: %s\", selector.buf, message.buf);\n> +\t\t\tstrbuf_release(&message);\n\n... and this one is what gets called from the above caller; we lost\nthe final LF (if there is) from the output, that is compensated by\nthe caller.\n\nHow well do we work with the \"-z\" output format, by the way, with\nthe hardcoded '\\n' on the output codepath?\n\nMaking a new allocation feels inefficient just to omit the trailing\nnewlines.  I wonder if a helper function that takes a \"const char *\"\nand returns a \"const char *\" in that string that points at the CRLF\nor LF or NUL at its end would be warranted.  If we do not care about\nCRLF, this part would become something like...\n\n\tif (oneline) {\n\t\tconst char *endp = strchrnul(info->message, '\\n');\n\t\tprintf(\"%s: %.*s\", selector.buf,\n\t\t\t(int)(endp - info->message), info->message);\n\t}\n\nbut I didn't trace the code/data flow to see where info->message\ncomes from well enough to tell if we need to worry about CRLF.  I\nthought reflogs are always written with LF termination, though.\n\nThanks.\n"},{"id":"385767","messageId":"20191108085024.GA26530@generichostname","threadId":"52187","inReplyTo":"xmqqwocdtwpa.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH 6/8] reflog-walk.c: don't print last newline with oneline","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T08:50:24Z","receivedAt":"2019-11-08T08:50:29Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi Junio,\n\nOn Wed, Nov 06, 2019 at 02:12:17PM +0900, Junio C Hamano wrote:\n> Denton Liu <liu.denton@gmail.com> writes:\n> \n> > Subject: Re: [PATCH 6/8] reflog-walk.c: don't print last newline with oneline\n> \n> Please find a better phrasing that does not mislead the readers to\n> think \"eek, so now output from 'git log -g --oneline' does not get\n> LF terminated?\"\n> \n> I think you are just changing the place where the LF is given from\n> the callee that shows a single record (and then used to show LF\n> after the record) to the caller that calls the callee (and now it\n> shows LF after the call returns), in order to preserve the output,\n> but with the given proposed log message, it is not clear if that is\n> what you meant to do (I can read from the code what _is_ going on,\n> but the log is to record what you _wanted_ to do, which can be\n> different).\n\nYep, I'll reword the subject line.\n\n> \n> > @@ -661,8 +661,10 @@ void show_log(struct rev_info *opt)\n> \n> In the pre-context before this line there is a guard to ensure that\n> we do this only when showing an entry from the reflog, so the effect\n> of this hunk is \"when showing from reflog in --oneline format, show\n> LF after showing a single record\" ...\n> \n> >  \t\t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n> >  \t\t\t\t\t    &opt->date_mode,\n> >  \t\t\t\t\t    opt->date_mode_explicit);\n> > -\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE)\n> > +\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n> > +\t\t\t\tputc('\\n', opt->diffopt.file);\n> >  \t\t\t\treturn;\n> > +\t\t\t}\n> >  \t\t}\n> >  \t}\n> >  \n> > diff --git a/reflog-walk.c b/reflog-walk.c\n> > index 3a25b27d8f..e2b4c0b290 100644\n> > --- a/reflog-walk.c\n> > +++ b/reflog-walk.c\n> > @@ -285,7 +285,11 @@ void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,\n> >  \t\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n> >  \t\tget_reflog_selector(&selector, reflog_info, dmode, force_date, 0);\n> >  \t\tif (oneline) {\n> > -\t\t\tprintf(\"%s: %s\", selector.buf, info->message);\n> > +\t\t\tstruct strbuf message = STRBUF_INIT;\n> > +\t\t\tstrbuf_addstr(&message, info->message);\n> > +\t\t\tstrbuf_trim_trailing_newline(&message);\n> > +\t\t\tprintf(\"%s: %s\", selector.buf, message.buf);\n> > +\t\t\tstrbuf_release(&message);\n> \n> ... and this one is what gets called from the above caller; we lost\n> the final LF (if there is) from the output, that is compensated by\n> the caller.\n\nYep, thats correct.\n\n> \n> How well do we work with the \"-z\" output format, by the way, with\n> the hardcoded '\\n' on the output codepath?\n\nFrom my tests, `-z` plays well with my changes. I'll add some tests to\nbe sure, though.\n\n> \n> Making a new allocation feels inefficient just to omit the trailing\n> newlines.  I wonder if a helper function that takes a \"const char *\"\n> and returns a \"const char *\" in that string that points at the CRLF\n> or LF or NUL at its end would be warranted.  If we do not care about\n> CRLF, this part would become something like...\n> \n> \tif (oneline) {\n> \t\tconst char *endp = strchrnul(info->message, '\\n');\n> \t\tprintf(\"%s: %.*s\", selector.buf,\n> \t\t\t(int)(endp - info->message), info->message);\n> \t}\n\nYep, I think that this works. In fact, we can probably just do\n\n \tif (oneline) {\n \t\tconst char *endp = strchrnul(info->message, '\\n');\n\t\tint len = strlen(info->message);\n\t\tif (len > 0)\n\t\t\tlen--;\n \t\tprintf(\"%s: %.*s\", selector.buf,\n \t\t\tlen, info->message);\n \t}\n\nbecause...\n\n> but I didn't trace the code/data flow to see where info->message\n> comes from well enough to tell if we need to worry about CRLF.  I\n> thought reflogs are always written with LF termination, though.\n\nI think that you are right. Reflogs are always written with LF\ntermination. This can be seen in get_reflog_message():\n\n\tvoid get_reflog_message(struct strbuf *sb,\n\t\t\t\tstruct reflog_walk_info *reflog_info)\n\t{\n\t\tstruct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;\n\t\tstruct reflog_info *info;\n\t\tsize_t len;\n\n\t\tif (!commit_reflog)\n\t\t\treturn;\n\n\t\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n\t\tlen = strlen(info->message);\n\t\tif (len > 0)\n=>\t\t\tlen--; /* strip away trailing newline */\n\t\tstrbuf_add(sb, info->message, len);\n\t}\n\n> \n> Thanks.\n"},{"id":"385796","messageId":"cover.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1572897736.git.liu.denton@gmail.com","subject":"[PATCH v2 00/10] learn the \"summary\" pretty format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:12Z","receivedAt":"2019-11-08T20:08:18Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"On this mailing list (and many others) the standard way to reference\nother commits with the \"summary\" format, e.g. \"f86a374 (\"pack-bitmap.c:\nfix a memleak\", 2015-03-30)\". Since it's so commonly used, let's\nstandardise it as a pretty format.\n\nChanges since v1:\n\n* Replace more references to \"sha1\" with \"hash\"\n\n* Clean up 8/10 by losing the allocation and making the subject less\n  misleading\n\n* Add tests in 7/10 to ensure 8/10 does not change any behaviour\n\nDenton Liu (10):\n  SubmittingPatches: use generic terms for hash\n  pretty-formats.txt: use generic terms for hash\n  revision: make get_revision_mark() return const pointer\n  revision: change abbrev_commit_given to abbrev_commit_explicit\n  pretty.c: inline initalize format_context\n  pretty.c: extract functionality to repo_format_commit_generic()\n  t4205: cover `git log --reflog -z` blindspot\n  reflog-walk.c: move where the newline is added\n  pretty: implement 'summary' format\n  SubmittingPatches: use `--pretty=summary`\n\n Documentation/SubmittingPatches    |  8 ++-\n Documentation/pretty-formats.txt   | 25 ++++++---\n Documentation/pretty-options.txt   |  2 +-\n Documentation/rev-list-options.txt |  2 +-\n builtin/log.c                      | 30 ++++++++--\n log-tree.c                         | 15 +++--\n pretty.c                           | 74 ++++++++++++++++++++----\n pretty.h                           |  1 +\n reflog-walk.c                      |  8 ++-\n revision.c                         |  7 ++-\n revision.h                         |  6 +-\n t/t4205-log-pretty-formats.sh      | 90 ++++++++++++++++++++++++++++++\n 12 files changed, 227 insertions(+), 41 deletions(-)\n\nRange-diff against v1:\n -:  ---------- >  1:  b34e9aea56 SubmittingPatches: use generic terms for hash\n 1:  dc88d700b8 =  2:  922cc6d849 pretty-formats.txt: use generic terms for hash\n 2:  9d30c287fa =  3:  b31cffd5ef revision: make get_revision_mark() return const pointer\n 3:  9ea8d676f7 =  4:  b970e52b57 revision: change abbrev_commit_given to abbrev_commit_explicit\n 4:  21809581df =  5:  a2e90c78e6 pretty.c: inline initalize format_context\n 5:  7f3a3b5828 =  6:  fd2bbcd169 pretty.c: extract functionality to repo_format_commit_generic()\n -:  ---------- >  7:  b5950823ce t4205: cover `git log --reflog -z` blindspot\n 6:  004164c781 !  8:  05dc446d41 reflog-walk.c: don't print last newline with oneline\n    @@ Metadata\n     Author: Denton Liu <liu.denton@gmail.com>\n     \n      ## Commit message ##\n    -    reflog-walk.c: don't print last newline with oneline\n    +    reflog-walk.c: move where the newline is added\n     \n         In a future commit, we want to possibly be able to continue the reflog message on\n         the same line without breaking the line. As a result, when\n    @@ Commit message\n     \n         Add these missing newlines back in show_log().\n     \n    +    While we're at it, cuddle the else with the closing brace of the if to\n    +    more closely match the existing style.\n    +\n         Signed-off-by: Denton Liu <liu.denton@gmail.com>\n     \n      ## log-tree.c ##\n    @@ reflog-walk.c: void show_reflog_message(struct reflog_walk_info *reflog_info, in\n      \t\tget_reflog_selector(&selector, reflog_info, dmode, force_date, 0);\n      \t\tif (oneline) {\n     -\t\t\tprintf(\"%s: %s\", selector.buf, info->message);\n    -+\t\t\tstruct strbuf message = STRBUF_INIT;\n    -+\t\t\tstrbuf_addstr(&message, info->message);\n    -+\t\t\tstrbuf_trim_trailing_newline(&message);\n    -+\t\t\tprintf(\"%s: %s\", selector.buf, message.buf);\n    -+\t\t\tstrbuf_release(&message);\n    - \t\t}\n    - \t\telse {\n    +-\t\t}\n    +-\t\telse {\n    ++\t\t\tint len = strlen(info->message);\n    ++\t\t\tif (len > 0)\n    ++\t\t\t\tlen--; /* strip away trailing newline */\n    ++\t\t\tprintf(\"%s: %.*s\", selector.buf, len, info->message);\n    ++\t\t} else {\n      \t\t\tprintf(\"Reflog: %s (%s)\\nReflog message: %s\",\n    + \t\t\t       selector.buf, info->email, info->message);\n    + \t\t}\n 7:  1e280b968c !  9:  e74eab6d21 pretty: implement 'summary' format\n    @@ Commit message\n         Documentation/SubmittingPatches as\n     \n                 If you want to reference a previous commit in the history of a stable\n    -            branch, use the format \"abbreviated sha1 (subject, date)\",\n    +            branch, use the format \"abbreviated hash (subject, date)\",\n                 with the subject enclosed in a pair of double-quotes, like this:\n     \n                 ....\n    @@ Documentation/pretty-formats.txt: This is designed to be as compact as possible.\n     +\t  <abbrev hash> (\"<title line>\", <short author date>)\n     ++\n     +This format is useful for referring to other commits when writing a new\n    -+commit message. Although by default, '<abbrev sha1>' is used, this can\n    ++commit message. Although by default, '<abbrev hash>' is used, this can\n     +be overridden with '--no-abbrev'. In addition, '<short author date>' can\n     +be overridden by with '--date='.\n     +\n    @@ pretty.h: enum cmit_fmt {\n      \tCMIT_FMT_USERFORMAT,\n     \n      ## t/t4205-log-pretty-formats.sh ##\n    +@@ t/t4205-log-pretty-formats.sh: do\n    + \t'\n    + done\n    + \n    +-test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n    +-\t>expect &&\n    +-\trevs=\"$(git rev-list --reflog)\" &&\n    +-\tfor r in $revs\n    +-\tdo\n    +-\t\t# trim trailing newline\n    +-\t\toutput=\"$(git show -s --pretty=oneline \"$r\")\" || return 1\n    +-\t\tprintf \"%s\" \"$output\" >>expect\n    +-\t\temit_nul >>expect\n    +-\tdone &&\n    +-\tgit log -z --pretty=oneline --reflog >actual &&\n    +-\t# no trailing NUL\n    +-\ttest_cmp expect actual\n    +-'\n    ++for p in oneline summary\n    ++do\n    ++\ttest_expect_success \"NUL termination with --reflog --pretty=$p\" '\n    ++\t\t>expect &&\n    ++\t\trevs=\"$(git rev-list --reflog)\" &&\n    ++\t\tfor r in $revs\n    ++\t\tdo\n    ++\t\t\t# trim trailing newline\n    ++\t\t\toutput=\"$(git show -s --pretty='$p' \"$r\")\" || return 1\n    ++\t\t\tprintf \"%s\" \"$output\" >>expect\n    ++\t\t\temit_nul >>expect\n    ++\t\tdone &&\n    ++\t\tgit log -z --pretty='$p' --reflog >actual &&\n    ++\t\t# no trailing NUL\n    ++\t\ttest_cmp expect actual\n    ++\t'\n    ++done\n    + \n    + test_expect_success 'setup more commits' '\n    + \ttest_commit \"message one\" one one message-one &&\n     @@ t/t4205-log-pretty-formats.sh: test_expect_success '%S in git log --format works with other placeholders (part\n      \ttest_cmp expect actual\n      '\n 8:  80e7c4fc66 = 10:  3aaa7a318b SubmittingPatches: use `--pretty=summary`\n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385797","messageId":"b34e9aea563454a117b2bb027da8f02fc67698eb.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 01/10] SubmittingPatches: use generic terms for hash","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:16Z","receivedAt":"2019-11-08T20:08:20Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git is planning on upgrading from SHA-1 to be more hash-agnostic,\nreplace specific references to SHA-1 with more generic terminology.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex 1a60cc1329..bb7e33ce15 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -142,7 +142,7 @@ archive, summarize the relevant points of the discussion.\n \n [[commit-reference]]\n If you want to reference a previous commit in the history of a stable\n-branch, use the format \"abbreviated sha1 (subject, date)\",\n+branch, use the format \"abbreviated hash (subject, date)\",\n with the subject enclosed in a pair of double-quotes, like this:\n \n ....\n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385798","messageId":"922cc6d849ff07f8da8f7c405f8999f2c135c540.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 02/10] pretty-formats.txt: use generic terms for hash","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:18Z","receivedAt":"2019-11-08T20:08:23Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git is planning on upgrading from SHA-1 to be more hash-agnostic,\nreplace specific references to SHA-1 with more generic terminology.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex b87e2e83e6..71eef684d0 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -4,7 +4,7 @@ PRETTY FORMATS\n If the commit is a merge, and if the pretty-format\n is not 'oneline', 'email' or 'raw', an additional line is\n inserted before the 'Author:' line.  This line begins with\n-\"Merge: \" and the sha1s of ancestral commits are printed,\n+\"Merge: \" and the hashes of ancestral commits are printed,\n separated by spaces.  Note that the listed commits may not\n necessarily be the list of the *direct* parent commits if you\n have limited your view of history: for example, if you are\n@@ -20,20 +20,20 @@ built-in formats:\n \n * 'oneline'\n \n-\t  <sha1> <title line>\n+\t  <hash> <title line>\n +\n This is designed to be as compact as possible.\n \n * 'short'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \n \t      <title line>\n \n * 'medium'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Date:   <author date>\n \n@@ -43,7 +43,7 @@ This is designed to be as compact as possible.\n \n * 'full'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Commit: <committer>\n \n@@ -53,7 +53,7 @@ This is designed to be as compact as possible.\n \n * 'fuller'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author:     <author>\n \t  AuthorDate: <author date>\n \t  Commit:     <committer>\n@@ -65,7 +65,7 @@ This is designed to be as compact as possible.\n \n * 'email'\n \n-\t  From <sha1> <date>\n+\t  From <hash> <date>\n \t  From: <author>\n \t  Date: <author date>\n \t  Subject: [PATCH] <title line>\n@@ -75,7 +75,7 @@ This is designed to be as compact as possible.\n * 'raw'\n +\n The 'raw' format shows the entire commit exactly as\n-stored in the commit object.  Notably, the SHA-1s are\n+stored in the commit object.  Notably, the hashes are\n displayed in full, regardless of whether --abbrev or\n --no-abbrev are used, and 'parents' information show the\n true parent commits, without taking grafts or history\n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385799","messageId":"b31cffd5effc3a25c063498cfbbcb7c69d8f6e6f.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 03/10] revision: make get_revision_mark() return const pointer","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:21Z","receivedAt":"2019-11-08T20:08:28Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"get_revision_mark() used to return a `char *`, even though all of the\nstrings it was returning were string literals. Make get_revision_mark()\nreturn a `const char *` so that callers won't be tempted to modify the\nreturned string.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n revision.c | 4 ++--\n revision.h | 4 ++--\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 0e39b2b8a5..2151b119b7 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -3944,7 +3944,7 @@ struct commit *get_revision(struct rev_info *revs)\n \treturn c;\n }\n \n-char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n+const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n \tif (commit->object.flags & BOUNDARY)\n \t\treturn \"-\";\n@@ -3966,7 +3966,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit\n \n void put_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n-\tchar *mark = get_revision_mark(revs, commit);\n+\tconst char *mark = get_revision_mark(revs, commit);\n \tif (!strlen(mark))\n \t\treturn;\n \tfputs(mark, stdout);\ndiff --git a/revision.h b/revision.h\nindex 4134dc6029..addd69410b 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,\n void reset_revision_walk(void);\n int prepare_revision_walk(struct rev_info *revs);\n struct commit *get_revision(struct rev_info *revs);\n-char *get_revision_mark(const struct rev_info *revs,\n-\t\t\tconst struct commit *commit);\n+const char *get_revision_mark(const struct rev_info *revs,\n+\t\t\t      const struct commit *commit);\n void put_revision_mark(const struct rev_info *revs,\n \t\t       const struct commit *commit);\n \n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385800","messageId":"b970e52b57d2f5f743d2be038bb8deaca5982fe9.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 04/10] revision: change abbrev_commit_given to abbrev_commit_explicit","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:23Z","receivedAt":"2019-11-08T20:08:29Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In a future patch, we want to know if `--[no-]abbrev-commit` arguments\nhave been explicitly provided. Since `rev_info.abbrev_commit_given` is\nonly used in one place, co-opt it to become\n`rev_info.abbrev_commit_explicit`. This information will be used in a\nfuture patch.\n\nWith this change, the semantics of the original usage (in\nthe `--pretty=raw` codepath) aren't altered.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n builtin/log.c | 2 +-\n revision.c    | 3 ++-\n revision.h    | 2 +-\n 3 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 89873d2dc2..e4df16be79 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -230,7 +230,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \t\t */\n \t\tif (!decoration_given)\n \t\t\tdecoration_style = 0;\n-\t\tif (!rev->abbrev_commit_given)\n+\t\tif (!rev->abbrev_commit_explicit)\n \t\t\trev->abbrev_commit = 0;\n \t}\n \ndiff --git a/revision.c b/revision.c\nindex 2151b119b7..02b49ab754 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -2271,9 +2271,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\t\trevs->abbrev = hexsz;\n \t} else if (!strcmp(arg, \"--abbrev-commit\")) {\n \t\trevs->abbrev_commit = 1;\n-\t\trevs->abbrev_commit_given = 1;\n+\t\trevs->abbrev_commit_explicit = 1;\n \t} else if (!strcmp(arg, \"--no-abbrev-commit\")) {\n \t\trevs->abbrev_commit = 0;\n+\t\trevs->abbrev_commit_explicit = 1;\n \t} else if (!strcmp(arg, \"--full-diff\")) {\n \t\trevs->diff = 1;\n \t\trevs->full_diff = 1;\ndiff --git a/revision.h b/revision.h\nindex addd69410b..7670f29973 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -185,7 +185,7 @@ struct rev_info {\n \t\t\tshow_signature:1,\n \t\t\tpretty_given:1,\n \t\t\tabbrev_commit:1,\n-\t\t\tabbrev_commit_given:1,\n+\t\t\tabbrev_commit_explicit:1,\n \t\t\tzero_commit:1,\n \t\t\tuse_terminator:1,\n \t\t\tmissing_newline:1,\n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385801","messageId":"fd2bbcd16972b9f41bff995eda3c5a1b87fe98a6.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 06/10] pretty.c: extract functionality to repo_format_commit_generic()","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:28Z","receivedAt":"2019-11-08T20:08:32Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In a future commit, we will be reusing common functionality from\nrepo_format_commit_message(). Extract this common functionality into\nrepo_format_commit_generic() so that it can be reused in the future.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n pretty.c | 35 ++++++++++++++++++++++++++++-------\n 1 file changed, 28 insertions(+), 7 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 6f2b0ad917..a6e5fc115a 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1605,10 +1605,14 @@ void userformat_find_requirements(const char *fmt, struct userformat_want *w)\n \tstrbuf_release(&dummy);\n }\n \n-void repo_format_commit_message(struct repository *r,\n-\t\t\t\tconst struct commit *commit,\n-\t\t\t\tconst char *format, struct strbuf *sb,\n-\t\t\t\tconst struct pretty_print_context *pretty_ctx)\n+static void repo_format_commit_generic(struct repository *r,\n+\t\t\t\t       const struct commit *commit,\n+\t\t\t\t       struct strbuf *sb,\n+\t\t\t\t       const struct pretty_print_context *pretty_ctx,\n+\t\t\t\t       void (*fn)(struct strbuf *,\n+\t\t\t\t\t\t  struct format_commit_context *,\n+\t\t\t\t\t\t  void *),\n+\t\t\t\t       void *data)\n {\n \tstruct format_commit_context context = {\n \t\t.commit = commit,\n@@ -1625,9 +1629,7 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\t\t       &context.commit_encoding,\n \t\t\t\t\t       utf8);\n \n-\tcontext.wrap_start = sb->len;\n-\tstrbuf_expand(sb, format, format_commit_item, &context);\n-\trewrap_message_tail(sb, &context, 0, 0, 0);\n+\tfn(sb, &context, data);\n \n \t/* then convert a commit message to an actual output encoding */\n \tif (output_enc) {\n@@ -1651,6 +1653,25 @@ void repo_format_commit_message(struct repository *r,\n \trepo_unuse_commit_buffer(r, commit, context.message);\n }\n \n+static void do_repo_format_commit_message(struct strbuf *sb,\n+\t\t\t\t\t  struct format_commit_context *context,\n+\t\t\t\t\t  void *data)\n+{\n+\tconst char *format = data;\n+\tcontext->wrap_start = sb->len;\n+\tstrbuf_expand(sb, format, format_commit_item, context);\n+\trewrap_message_tail(sb, context, 0, 0, 0);\n+}\n+\n+void repo_format_commit_message(struct repository *r,\n+\t\t\t\tconst struct commit *commit,\n+\t\t\t\tconst char *format, struct strbuf *sb,\n+\t\t\t\tconst struct pretty_print_context *pretty_ctx)\n+{\n+\trepo_format_commit_generic(r, commit, sb, pretty_ctx,\n+\t\t\t\t   do_repo_format_commit_message, (void *)format);\n+}\n+\n static void pp_header(struct pretty_print_context *pp,\n \t\t      const char *encoding,\n \t\t      const struct commit *commit,\n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385802","messageId":"a2e90c78e64633824000da41fb0b72afb8f1ab52.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 05/10] pretty.c: inline initalize format_context","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:25Z","receivedAt":"2019-11-08T20:08:32Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Instead of memsetting and then initializing the fields in the struct,\nmove the initialization of `format_context` to its assignment.\n\nIn preparation for a future commit where we mechanically move lines from\nrepo_format_commit_message() into a helper function,\n`format_context.wrap_start` is not generically used so move its\nassignment closer to its use.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n pretty.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex b32f036953..6f2b0ad917 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1610,14 +1610,13 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\tconst char *format, struct strbuf *sb,\n \t\t\t\tconst struct pretty_print_context *pretty_ctx)\n {\n-\tstruct format_commit_context context;\n+\tstruct format_commit_context context = {\n+\t\t.commit = commit,\n+\t\t.pretty_ctx = pretty_ctx\n+\t};\n \tconst char *output_enc = pretty_ctx->output_encoding;\n \tconst char *utf8 = \"UTF-8\";\n \n-\tmemset(&context, 0, sizeof(context));\n-\tcontext.commit = commit;\n-\tcontext.pretty_ctx = pretty_ctx;\n-\tcontext.wrap_start = sb->len;\n \t/*\n \t * convert a commit message to UTF-8 first\n \t * as far as 'format_commit_item' assumes it in UTF-8\n@@ -1626,6 +1625,7 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\t\t       &context.commit_encoding,\n \t\t\t\t\t       utf8);\n \n+\tcontext.wrap_start = sb->len;\n \tstrbuf_expand(sb, format, format_commit_item, &context);\n \trewrap_message_tail(sb, &context, 0, 0, 0);\n \n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385803","messageId":"b5950823ce90dd2476f002ed0370b7e0099a4d85.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 07/10] t4205: cover `git log --reflog -z` blindspot","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:30Z","receivedAt":"2019-11-08T20:08:35Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"The test suite does not include any tests where `--reflog` and `-z` are\nused together in `git log`. Cover this blindspot. Note that the\n`--pretty=oneline` case is written separately because it follows a\nslightly different codepath.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n t/t4205-log-pretty-formats.sh | 35 +++++++++++++++++++++++++++++++++++\n 1 file changed, 35 insertions(+)\n\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex f42a69faa2..d35650cae7 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -134,6 +134,41 @@ test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' '\n \ttest_cmp expected actual\n '\n \n+emit_nul () {\n+\techo | tr '\\n' '\\000'\n+}\n+\n+for p in short medium full fuller email raw\n+do\n+\ttest_expect_success \"NUL termination with --reflog --pretty=$p\" '\n+\t\t>expect &&\n+\t\trevs=\"$(git rev-list --reflog)\" &&\n+\t\tfor r in $revs\n+\t\tdo\n+\t\t\tgit show -s \"$r\" --pretty='$p' >>expect || return 1\n+\t\t\temit_nul >>expect\n+\t\tdone &&\n+\t\tgit log -z --reflog --pretty='$p' >actual &&\n+\t\temit_nul >>actual &&\n+\t\ttest_cmp expect actual\n+\t'\n+done\n+\n+test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n+\t>expect &&\n+\trevs=\"$(git rev-list --reflog)\" &&\n+\tfor r in $revs\n+\tdo\n+\t\t# trim trailing newline\n+\t\toutput=\"$(git show -s --pretty=oneline \"$r\")\" || return 1\n+\t\tprintf \"%s\" \"$output\" >>expect\n+\t\temit_nul >>expect\n+\tdone &&\n+\tgit log -z --pretty=oneline --reflog >actual &&\n+\t# no trailing NUL\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'setup more commits' '\n \ttest_commit \"message one\" one one message-one &&\n \ttest_commit \"message two\" two two message-two &&\n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385804","messageId":"05dc446d417c28512c0d8a25bd8e62b9d7fb529e.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 08/10] reflog-walk.c: move where the newline is added","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:32Z","receivedAt":"2019-11-08T20:08:36Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In a future commit, we want to possibly be able to continue the reflog message on\nthe same line without breaking the line. As a result, when\n`oneline == 1`, strip any trailing new lines.\n\nAdd these missing newlines back in show_log().\n\nWhile we're at it, cuddle the else with the closing brace of the if to\nmore closely match the existing style.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n log-tree.c    | 4 +++-\n reflog-walk.c | 8 +++++---\n 2 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex 923a299e70..4a7d668af6 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -661,8 +661,10 @@ void show_log(struct rev_info *opt)\n \t\t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n \t\t\t\t\t    &opt->date_mode,\n \t\t\t\t\t    opt->date_mode_explicit);\n-\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE)\n+\t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n+\t\t\t\tputc('\\n', opt->diffopt.file);\n \t\t\t\treturn;\n+\t\t\t}\n \t\t}\n \t}\n \ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 3a25b27d8f..6b6bd18e6c 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -285,9 +285,11 @@ void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,\n \t\tinfo = &commit_reflog->reflogs->items[commit_reflog->recno+1];\n \t\tget_reflog_selector(&selector, reflog_info, dmode, force_date, 0);\n \t\tif (oneline) {\n-\t\t\tprintf(\"%s: %s\", selector.buf, info->message);\n-\t\t}\n-\t\telse {\n+\t\t\tint len = strlen(info->message);\n+\t\t\tif (len > 0)\n+\t\t\t\tlen--; /* strip away trailing newline */\n+\t\t\tprintf(\"%s: %.*s\", selector.buf, len, info->message);\n+\t\t} else {\n \t\t\tprintf(\"Reflog: %s (%s)\\nReflog message: %s\",\n \t\t\t       selector.buf, info->email, info->message);\n \t\t}\n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385805","messageId":"e74eab6d21f655698ef8b6e1286b44ea070a7af7.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 09/10] pretty: implement 'summary' format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:34Z","receivedAt":"2019-11-08T20:08:39Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"The standard format for referencing other commits within some projects\n(such as git.git) is the summary format. This is described in\nDocumentation/SubmittingPatches as\n\n\tIf you want to reference a previous commit in the history of a stable\n\tbranch, use the format \"abbreviated hash (subject, date)\",\n\twith the subject enclosed in a pair of double-quotes, like this:\n\n\t....\n\t\tCommit f86a374 (\"pack-bitmap.c: fix a memleak\", 2015-03-30)\n\t\tnoticed that ...\n\t....\n\nSince this format is so commonly used, standardize it as a pretty\nformat.\n\nThis format is implemented as a separate flow that skips most of\npretty_print_commit() and instead calls format_commit_summary(). The\nreason why this is done is because the other pretty formats expect\noutput to be generated in a specific order. Specifically, the header,\nincluding the date, is always printed before the commit message,\nincluding the subject. Reversing the order would be possible but would\ninvolve butchering pretty_print_commit() so it is implemented as a\nseparate flow.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt   |  9 ++++\n Documentation/pretty-options.txt   |  2 +-\n Documentation/rev-list-options.txt |  2 +-\n builtin/log.c                      | 30 +++++++++--\n log-tree.c                         | 11 ++--\n pretty.c                           | 31 ++++++++++-\n pretty.h                           |  1 +\n t/t4205-log-pretty-formats.sh      | 83 +++++++++++++++++++++++++-----\n 8 files changed, 144 insertions(+), 25 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 71eef684d0..f9c1296d7c 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -63,6 +63,15 @@ This is designed to be as compact as possible.\n \n \t       <full commit message>\n \n+* 'summary'\n+\n+\t  <abbrev hash> (\"<title line>\", <short author date>)\n++\n+This format is useful for referring to other commits when writing a new\n+commit message. Although by default, '<abbrev hash>' is used, this can\n+be overridden with '--no-abbrev'. In addition, '<short author date>' can\n+be overridden by with '--date='.\n+\n * 'email'\n \n \t  From <hash> <date>\ndiff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\nindex e44fc8f738..0a5b206193 100644\n--- a/Documentation/pretty-options.txt\n+++ b/Documentation/pretty-options.txt\n@@ -3,7 +3,7 @@\n \n \tPretty-print the contents of the commit logs in a given format,\n \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n-\t'full', 'fuller', 'email', 'raw', 'format:<string>'\n+\t'full', 'fuller', 'summary', 'email', 'raw', 'format:<string>'\n \tand 'tformat:<string>'.  When '<format>' is none of the above,\n \tand has '%placeholder' in it, it acts as if\n \t'--pretty=tformat:<format>' were given.\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex 90ff9e2bea..76df494ed6 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -289,7 +289,7 @@ depending on a few rules:\n 4. Otherwise, show the index format.\n --\n +\n-Under `--pretty=oneline`, the commit message is\n+Under `--pretty=oneline` and `--pretty=summary`, the commit message is\n prefixed with this information on the same line.\n This option cannot be combined with `--reverse`.\n See also linkgit:git-reflog[1].\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e4df16be79..ad96a746a3 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -223,15 +223,35 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \t\tread_mailmap(rev->mailmap, NULL);\n \t}\n \n-\tif (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {\n+\tif (rev->pretty_given) {\n+\t\tswitch (rev->commit_format) {\n+\n \t\t/*\n \t\t * \"log --pretty=raw\" is special; ignore UI oriented\n \t\t * configuration variables such as decoration.\n \t\t */\n-\t\tif (!decoration_given)\n-\t\t\tdecoration_style = 0;\n-\t\tif (!rev->abbrev_commit_explicit)\n-\t\t\trev->abbrev_commit = 0;\n+\t\tcase CMIT_FMT_RAW:\n+\t\t\tif (!decoration_given)\n+\t\t\t\tdecoration_style = 0;\n+\t\t\tif (!rev->abbrev_commit_explicit)\n+\t\t\t\trev->abbrev_commit = 0;\n+\t\t\tbreak;\n+\n+\t\t/*\n+\t\t * \"log --pretty=summary\" is special; ignore UI oriented\n+\t\t * configuration variables such as decoration but keep\n+\t\t * abbreviations.\n+\t\t */\n+\t\tcase CMIT_FMT_SUMMARY:\n+\t\t\tif (!decoration_given)\n+\t\t\t\tdecoration_style = 0;\n+\t\t\tif (!rev->abbrev_commit_explicit)\n+\t\t\t\trev->abbrev_commit = 1;\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n \t}\n \n \tif (decoration_style) {\ndiff --git a/log-tree.c b/log-tree.c\nindex 4a7d668af6..433adaf0f1 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -627,7 +627,8 @@ void show_log(struct rev_info *opt)\n \t\tctx.print_email_subject = 1;\n \t} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {\n \t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), opt->diffopt.file);\n-\t\tif (opt->commit_format != CMIT_FMT_ONELINE)\n+\t\tif (opt->commit_format != CMIT_FMT_ONELINE &&\n+\t\t    opt->commit_format != CMIT_FMT_SUMMARY)\n \t\t\tfputs(\"commit \", opt->diffopt.file);\n \n \t\tif (!opt->graph)\n@@ -644,7 +645,8 @@ void show_log(struct rev_info *opt)\n \t\t\t       find_unique_abbrev(&parent->object.oid, abbrev_commit));\n \t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);\n \t\tshow_decorations(opt, commit);\n-\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n+\t\tif (opt->commit_format == CMIT_FMT_ONELINE ||\n+\t\t    opt->commit_format == CMIT_FMT_SUMMARY) {\n \t\t\tputc(' ', opt->diffopt.file);\n \t\t} else {\n \t\t\tputc('\\n', opt->diffopt.file);\n@@ -658,12 +660,15 @@ void show_log(struct rev_info *opt)\n \t\t\t * graph info here.\n \t\t\t */\n \t\t\tshow_reflog_message(opt->reflog_info,\n-\t\t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n+\t\t\t\t\t    (opt->commit_format == CMIT_FMT_ONELINE ||\n+\t\t\t\t\t     opt->commit_format == CMIT_FMT_SUMMARY),\n \t\t\t\t\t    &opt->date_mode,\n \t\t\t\t\t    opt->date_mode_explicit);\n \t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n \t\t\t\tputc('\\n', opt->diffopt.file);\n \t\t\t\treturn;\n+\t\t\t} else if (opt->commit_format == CMIT_FMT_SUMMARY) {\n+\t\t\t\tputc(' ', opt->diffopt.file);\n \t\t\t}\n \t\t}\n \t}\ndiff --git a/pretty.c b/pretty.c\nindex a6e5fc115a..8efb2486a5 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -97,7 +97,8 @@ static void setup_commit_formats(void)\n \t\t{ \"mboxrd\",\tCMIT_FMT_MBOXRD,\t0,\t0 },\n \t\t{ \"fuller\",\tCMIT_FMT_FULLER,\t0,\t8 },\n \t\t{ \"full\",\tCMIT_FMT_FULL,\t\t0,\t8 },\n-\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 }\n+\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 },\n+\t\t{ \"summary\",\tCMIT_FMT_SUMMARY,\t1,\t0 },\n \t\t/*\n \t\t * Please update $__git_log_pretty_formats in\n \t\t * git-completion.bash when you add new formats.\n@@ -1672,6 +1673,26 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\t   do_repo_format_commit_message, (void *)format);\n }\n \n+static void do_repo_format_commit_summary(struct strbuf *sb,\n+\t\t\t\t\t  struct format_commit_context *context,\n+\t\t\t\t\t  void *additional_context)\n+{\n+\tstruct ident_split ident;\n+\n+\tparse_commit_header(context);\n+\tparse_commit_message(context);\n+\n+\tstrbuf_addstr(sb, \"(\\\"\");\n+\tformat_subject(sb, context->message + context->subject_off, \" \");\n+\tif (!split_ident_line(&ident,\n+\t\t\t      context->message + context->author.off,\n+\t\t\t      context->author.len)) {\n+\t\tstrbuf_addstr(sb, \"\\\", \");\n+\t\tstrbuf_addstr(sb, show_ident_date(&ident, &context->pretty_ctx->date_mode));\n+\t}\n+\tstrbuf_addstr(sb, \")\");\n+}\n+\n static void pp_header(struct pretty_print_context *pp,\n \t\t      const char *encoding,\n \t\t      const struct commit *commit,\n@@ -1923,6 +1944,14 @@ void pretty_print_commit(struct pretty_print_context *pp,\n \t\tformat_commit_message(commit, user_format, sb, pp);\n \t\treturn;\n \t}\n+\tif (pp->fmt == CMIT_FMT_SUMMARY) {\n+\t\tif (!pp->date_mode_explicit)\n+\t\t\tpp->date_mode = *DATE_MODE(SHORT);\n+\n+\t\trepo_format_commit_generic(the_repository, commit, sb, pp,\n+\t\t\t\t\t   do_repo_format_commit_summary, NULL);\n+\t\treturn;\n+\t}\n \n \tencoding = get_log_output_encoding();\n \tmsg = reencoded = logmsg_reencode(commit, NULL, encoding);\ndiff --git a/pretty.h b/pretty.h\nindex 4ad1fc31ff..6d5b18a4f1 100644\n--- a/pretty.h\n+++ b/pretty.h\n@@ -16,6 +16,7 @@ enum cmit_fmt {\n \tCMIT_FMT_FULL,\n \tCMIT_FMT_FULLER,\n \tCMIT_FMT_ONELINE,\n+\tCMIT_FMT_SUMMARY,\n \tCMIT_FMT_EMAIL,\n \tCMIT_FMT_MBOXRD,\n \tCMIT_FMT_USERFORMAT,\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex d35650cae7..fcfd66faf9 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -154,20 +154,23 @@ do\n \t'\n done\n \n-test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n-\t>expect &&\n-\trevs=\"$(git rev-list --reflog)\" &&\n-\tfor r in $revs\n-\tdo\n-\t\t# trim trailing newline\n-\t\toutput=\"$(git show -s --pretty=oneline \"$r\")\" || return 1\n-\t\tprintf \"%s\" \"$output\" >>expect\n-\t\temit_nul >>expect\n-\tdone &&\n-\tgit log -z --pretty=oneline --reflog >actual &&\n-\t# no trailing NUL\n-\ttest_cmp expect actual\n-'\n+for p in oneline summary\n+do\n+\ttest_expect_success \"NUL termination with --reflog --pretty=$p\" '\n+\t\t>expect &&\n+\t\trevs=\"$(git rev-list --reflog)\" &&\n+\t\tfor r in $revs\n+\t\tdo\n+\t\t\t# trim trailing newline\n+\t\t\toutput=\"$(git show -s --pretty='$p' \"$r\")\" || return 1\n+\t\t\tprintf \"%s\" \"$output\" >>expect\n+\t\t\temit_nul >>expect\n+\t\tdone &&\n+\t\tgit log -z --pretty='$p' --reflog >actual &&\n+\t\t# no trailing NUL\n+\t\ttest_cmp expect actual\n+\t'\n+done\n \n test_expect_success 'setup more commits' '\n \ttest_commit \"message one\" one one message-one &&\n@@ -823,4 +826,56 @@ test_expect_success '%S in git log --format works with other placeholders (part\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'log --pretty=summary' '\n+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with log.date is overridden by short date' '\n+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\ttest_config log.date rfc &&\n+\tgit log --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with explicit date overrides short date' '\n+\tgit log --date=rfc --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --date=rfc --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with log.abbrevCommit is overidden' '\n+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\ttest_config log.abbrevCommit false &&\n+\tgit log --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with explicit --no-abbrev overrides abbreviated' '\n+\tgit log --date=short --pretty=\"tformat:%H (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --no-abbrev --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with log.decorate is overridden' '\n+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n+\ttest_config log.decorate short &&\n+\tgit log --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with explicit decorate overrides no decoration' '\n+\tgit log --date=short --pretty=\"tformat:%h%d (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --decorate=short --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=summary with --walk-reflogs' '\n+\ttest_config log.date short &&\n+\tgit log --walk-reflogs --pretty=\"tformat:%h %gd: %gs (\\\"%s\\\", %ad)\" >expect &&\n+\tgit log --walk-reflogs --pretty=summary >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385806","messageId":"3aaa7a318b50fc296afdf5be98fbb9a714e23bd2.1573241590.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v2 10/10] SubmittingPatches: use `--pretty=summary`","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T20:08:37Z","receivedAt":"2019-11-08T20:08:41Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git was taught the `--pretty=summary` option, it is no longer\nnecessary to manually specify the format string to get the commit\nsummary. Teach users to use the new option while keeping the old\ninvocation around in case they have an older version of Git.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex bb7e33ce15..849d27663e 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -153,6 +153,12 @@ with the subject enclosed in a pair of double-quotes, like this:\n The \"Copy commit summary\" command of gitk can be used to obtain this\n format, or this invocation of `git show`:\n \n+....\n+\tgit show -s --pretty=summary <commit>\n+....\n+\n+or, on an older version of Git without support for --pretty=summary:\n+\n ....\n \tgit show -s --date=short --pretty='format:%h (\"%s\", %ad)' <commit>\n ....\n-- \n2.24.0.298.g3e88fbd976\n\n"},{"id":"385809","messageId":"CAPig+cQDMSwP5-D-=LgjBPH2kJK16Fv4c619Pg6OTU95CQ9sgw@mail.gmail.com","threadId":"52187","inReplyTo":"b5950823ce90dd2476f002ed0370b7e0099a4d85.1573241590.git.liu.denton@gmail.com","subject":"Re: [PATCH v2 07/10] t4205: cover `git log --reflog -z` blindspot","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-11-08T20:36:25Z","receivedAt":"2019-11-08T20:36:39Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Nov 8, 2019 at 3:08 PM Denton Liu <liu.denton@gmail.com> wrote:\n> The test suite does not include any tests where `--reflog` and `-z` are\n> used together in `git log`. Cover this blindspot. Note that the\n> `--pretty=oneline` case is written separately because it follows a\n> slightly different codepath.\n>\n> Signed-off-by: Denton Liu <liu.denton@gmail.com>\n> ---\n> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\n> @@ -134,6 +134,41 @@ test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' '\n> +emit_nul () {\n> +       echo | tr '\\n' '\\000'\n> +}\n\nA simple:\n\n    printf \"\\0\"\n\nwould be simpler, and I don't think you even need to introduce a shell\nfunction to encapsulate it, as it's quite clear at a glance what it\ndoes.\n\n> +for p in short medium full fuller email raw\n> +do\n> +       test_expect_success \"NUL termination with --reflog --pretty=$p\" '\n> +               >expect &&\n\nYou can drop this line...\n\n> +               revs=\"$(git rev-list --reflog)\" &&\n> +               for r in $revs\n> +               do\n> +                       git show -s \"$r\" --pretty='$p' >>expect || return 1\n> +                       emit_nul >>expect\n\n...and simplify all this capturing into 'expect'...\n\n> +               done &&\n\n... by just redirecting the output of the for-loop itself:\n\n    for r in $(git rev-list --reflog)\n    do\n        git show -s --pretty=\"$p\" \"$r\" &&\n        printf \"\\0\" || return 1\n    done >expect &&\n\nFor completeness, the above example also drops the unnecessary 'revs'\nvariable, uses double quotes rather than single when interpolating $p,\nand makes the loop early-exit a bit more idiomatic.\n\n> +               git log -z --reflog --pretty='$p' >actual &&\n> +               emit_nul >>actual &&\n\nLikewise, you can capture 'actual' in its entirety:\n\n    {\n        git log -z --reflog --pretty=\"$p\" &&\n        printf \"\\0\"\n    } >actual &&\n\n> +               test_cmp expect actual\n> +       '\n> +done\n> +\n> +test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n> +       >expect &&\n> +       revs=\"$(git rev-list --reflog)\" &&\n> +       for r in $revs\n> +       do\n> +               # trim trailing newline\n> +               output=\"$(git show -s --pretty=oneline \"$r\")\" || return 1\n> +               printf \"%s\" \"$output\" >>expect\n> +               emit_nul >>expect\n> +       done &&\n\nReplacing the newline with NUL could be done more simply and\nidiomatically (with regard to other test scripts) by passing the\noutput of \"git show\" through the lf_to_nul() function from\ntest-lib-functions.sh. Something like this should do it:\n\n    for r in $(git rev-list --reflog)\n    do\n        git show -s --pretty=oneline \"$r\" >raw &&\n        cat raw | lf_to_nul || return 1\n    done >expect &&\n\n> +       git log -z --pretty=oneline --reflog >actual &&\n> +       # no trailing NUL\n\nTo what is this comment referring?\n\n> +       test_cmp expect actual\n> +'\n"},{"id":"385810","messageId":"CAPig+cSQ5PYZYrbqZYoBWLzohw419iSTsEfysjRf_JyxNENRkw@mail.gmail.com","threadId":"52187","inReplyTo":"e74eab6d21f655698ef8b6e1286b44ea070a7af7.1573241590.git.liu.denton@gmail.com","subject":"Re: [PATCH v2 09/10] pretty: implement 'summary' format","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-11-08T20:46:07Z","receivedAt":"2019-11-08T20:46:21Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Nov 8, 2019 at 3:08 PM Denton Liu <liu.denton@gmail.com> wrote:\n> Signed-off-by: Denton Liu <liu.denton@gmail.com>\n> ---\n> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\n> @@ -154,20 +154,23 @@ do\n> -test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n> -       >expect &&\n> -       revs=\"$(git rev-list --reflog)\" &&\n> -       [...]\n> -       test_cmp expect actual\n> -'\n> +for p in oneline summary\n> +do\n> +       test_expect_success \"NUL termination with --reflog --pretty=$p\" '\n> +               >expect &&\n> +               revs=\"$(git rev-list --reflog)\" &&\n> +               [...]\n> +               test_cmp expect actual\n> +       '\n> +done\n\nThis patch would be less noisy (by eliminating the indentation change)\nif you wrapped this test in a for-loop back in 7/10 where it was\nintroduced, with the intention of adding more items to the 'for' list.\nSo, in 7/10, you'd have this:\n\n    for p in online\n    do\n        test_expect_success \"NUL termination with --reflog --pretty=$p\" '\n            ...\n        '\n    done\n\nand this patch, 9/10, would just make the minor change:\n\n    -for p in oneline\n    +for p in oneline summary\n\nHaving a for-loop with only a single item is a minor-ugly which pays\noff with less noise in subsequent patch(es), thus easing review\nburden.\n"},{"id":"385815","messageId":"20191108214711.GA27310@generichostname","threadId":"52187","inReplyTo":"CAPig+cQDMSwP5-D-=LgjBPH2kJK16Fv4c619Pg6OTU95CQ9sgw@mail.gmail.com","subject":"Re: [PATCH v2 07/10] t4205: cover `git log --reflog -z` blindspot","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-08T21:47:11Z","receivedAt":"2019-11-08T21:47:18Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi Eric,\n\nOn Fri, Nov 08, 2019 at 03:36:25PM -0500, Eric Sunshine wrote:\n\n[...]\n\n>     for r in $(git rev-list --reflog)\n>     do\n>         git show -s --pretty=\"$p\" \"$r\" &&\n>         printf \"\\0\" || return 1\n>     done >expect &&\n> \n> For completeness, the above example also drops the unnecessary 'revs'\n> variable, uses double quotes rather than single when interpolating $p,\n> and makes the loop early-exit a bit more idiomatic.\n\nThe reason why I pulled out `revs` was because putting the rev-list\nwithin the for-loop would cause its exit code to be lost if it ever\nfailed. Since I've been cleaning up test scripts to not lose exit codes\nfrom git commands, I figured it'd be a bad idea to introduce an instance\nhere ;)\n\nThanks for the other two suggestions, though. I didn't know that you\ncould write it like that.\n\n> > +       git log -z --pretty=oneline --reflog >actual &&\n> > +       # no trailing NUL\n> \n> To what is this comment referring?\n\nI wanted to point out how in the oneline case, the trailing NUL is\nalready included, unlike in the multiple cases, so we don't need to\noutput another one.\n\nI'll rewrite this as\n\n\t# the trailing NUL is already produced so we don't need to\n\t# output another one\n\nThanks for your feedback,\n\nDenton\n"},{"id":"385817","messageId":"CAPig+cQ3FrxUGiFXooaiZ+po0qK6tBOda5apCs4=H0mdWxAKOg@mail.gmail.com","threadId":"52187","inReplyTo":"20191108214711.GA27310@generichostname","subject":"Re: [PATCH v2 07/10] t4205: cover `git log --reflog -z` blindspot","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-11-08T21:58:40Z","receivedAt":"2019-11-08T21:58:54Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Nov 8, 2019 at 4:47 PM Denton Liu <liu.denton@gmail.com> wrote:\n> On Fri, Nov 08, 2019 at 03:36:25PM -0500, Eric Sunshine wrote:\n> > For completeness, the above example also drops the unnecessary 'revs'\n> > variable, uses double quotes rather than single when interpolating $p,\n> > and makes the loop early-exit a bit more idiomatic.\n>\n> The reason why I pulled out `revs` was because putting the rev-list\n> within the for-loop would cause its exit code to be lost if it ever\n> failed. Since I've been cleaning up test scripts to not lose exit codes\n> from git commands, I figured it'd be a bad idea to introduce an instance\n> here ;)\n\nMake sense. Ignore that suggestion of mine.\n\n> > > +       git log -z --pretty=oneline --reflog >actual &&\n> > > +       # no trailing NUL\n> >\n> > To what is this comment referring?\n>\n> I wanted to point out how in the oneline case, the trailing NUL is\n> already included, unlike in the multiple cases, so we don't need to\n> output another one.\n>\n> I'll rewrite this as\n>\n>         # the trailing NUL is already produced so we don't need to\n>         # output another one\n\nThat will be clearer. It might be even clearer if that comment comes\nbefore the \"git log -z\" invocation rather than after (though that's\nsubjective). Thanks.\n"},{"id":"385825","messageId":"08afdbcd-5972-05f9-ec8c-b12bd29d9030@web.de","threadId":"52187","inReplyTo":"e74eab6d21f655698ef8b6e1286b44ea070a7af7.1573241590.git.liu.denton@gmail.com","subject":"Re: [PATCH v2 09/10] pretty: implement 'summary' format","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-11-09T06:38:13Z","receivedAt":"2019-11-09T06:38:29Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 08.11.19 um 21:08 schrieb Denton Liu:\n> The standard format for referencing other commits within some projects\n> (such as git.git) is the summary format. This is described in\n> Documentation/SubmittingPatches as\n>\n> \tIf you want to reference a previous commit in the history of a stable\n> \tbranch, use the format \"abbreviated hash (subject, date)\",\n> \twith the subject enclosed in a pair of double-quotes, like this:\n>\n> \t....\n> \t\tCommit f86a374 (\"pack-bitmap.c: fix a memleak\", 2015-03-30)\n> \t\tnoticed that ...\n> \t....\n>\n> Since this format is so commonly used, standardize it as a pretty\n> format.\n>\n> This format is implemented as a separate flow that skips most of\n> pretty_print_commit() and instead calls format_commit_summary(). The\n> reason why this is done is because the other pretty formats expect\n> output to be generated in a specific order. Specifically, the header,\n> including the date, is always printed before the commit message,\n> including the subject. Reversing the order would be possible but would\n> involve butchering pretty_print_commit() so it is implemented as a\n> separate flow.\n>\n> Signed-off-by: Denton Liu <liu.denton@gmail.com>\n> ---\n>  Documentation/pretty-formats.txt   |  9 ++++\n>  Documentation/pretty-options.txt   |  2 +-\n>  Documentation/rev-list-options.txt |  2 +-\n>  builtin/log.c                      | 30 +++++++++--\n>  log-tree.c                         | 11 ++--\n>  pretty.c                           | 31 ++++++++++-\n>  pretty.h                           |  1 +\n>  t/t4205-log-pretty-formats.sh      | 83 +++++++++++++++++++++++++-----\n>  8 files changed, 144 insertions(+), 25 deletions(-)\n\nHmm, that's quite a lot of code to add to the formatting code with its\nrepeated special-case checks.  Why not implement it as a built-in user\nformat, like making it an alias for something like this?\n\n   git log --format='%C(auto)%h (\"%s\", %as)'\n\nWe don't have %as, yet, but making --date=short available as a\nplaceholder would be a good idea anyway (patch below).\n\n\n-- >8 --\nSubject: [PATCH] pretty: provide short date format\n\nAdd the placeholders %as and %cs to format author date and committer\ndate, respectively, without the time part, like --date=short does, i.e.\nlike YYYY-MM-DD.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n Documentation/pretty-formats.txt | 2 ++\n pretty.c                         | 3 +++\n t/t4205-log-pretty-formats.sh    | 6 ++++++\n 3 files changed, 11 insertions(+)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex b87e2e83e6..f80eaab439 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -169,6 +169,7 @@ The placeholders are:\n '%at':: author date, UNIX timestamp\n '%ai':: author date, ISO 8601-like format\n '%aI':: author date, strict ISO 8601 format\n+'%as':: author date, short format (`YYYY-MM-DD`)\n '%cn':: committer name\n '%cN':: committer name (respecting .mailmap, see\n \tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n@@ -181,6 +182,7 @@ The placeholders are:\n '%ct':: committer date, UNIX timestamp\n '%ci':: committer date, ISO 8601-like format\n '%cI':: committer date, strict ISO 8601 format\n+'%cs':: committer date, short format (`YYYY-MM-DD`)\n '%d':: ref names, like the --decorate option of linkgit:git-log[1]\n '%D':: ref names without the \" (\", \")\" wrapping.\n '%S':: ref name given on the command line by which the commit was reached\ndiff --git a/pretty.c b/pretty.c\nindex b32f036953..76920c91dd 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -731,6 +731,9 @@ static size_t format_person_part(struct strbuf *sb, char part,\n \tcase 'I':\t/* date, ISO 8601 strict */\n \t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(ISO8601_STRICT)));\n \t\treturn placeholder_len;\n+\tcase 's':\n+\t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(SHORT)));\n+\t\treturn placeholder_len;\n \t}\n\n skip:\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex f42a69faa2..4980ed4c6f 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -503,6 +503,12 @@ test_expect_success 'ISO and ISO-strict date formats display the same values' '\n \ttest_cmp expected actual\n '\n\n+test_expect_success 'short date' '\n+\tgit log --format=%ad%n%cd --date=short >expected &&\n+\tgit log --format=%as%n%cs >actual &&\n+\ttest_cmp expected actual\n+'\n+\n # get new digests (with no abbreviations)\n test_expect_success 'set up log decoration tests' '\n \thead1=$(git rev-parse --verify HEAD~0) &&\n--\n2.24.0\n"},{"id":"385826","messageId":"f66f8fbe-af46-f38e-87df-fc688110610a@web.de","threadId":"52187","inReplyTo":"e74eab6d21f655698ef8b6e1286b44ea070a7af7.1573241590.git.liu.denton@gmail.com","subject":"Re: [PATCH v2 09/10] pretty: implement 'summary' format","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-11-09T06:38:51Z","receivedAt":"2019-11-09T06:38:58Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 08.11.19 um 21:08 schrieb Denton Liu:\n> The standard format for referencing other commits within some projects\n> (such as git.git) is the summary format. This is described in\n> Documentation/SubmittingPatches as\n>\n> \tIf you want to reference a previous commit in the history of a stable\n> \tbranch, use the format \"abbreviated hash (subject, date)\",\n> \twith the subject enclosed in a pair of double-quotes, like this:\n>\n> \t....\n> \t\tCommit f86a374 (\"pack-bitmap.c: fix a memleak\", 2015-03-30)\n> \t\tnoticed that ...\n> \t....\n>\n> Since this format is so commonly used, standardize it as a pretty\n> format.\n\nIf the title contains a double quote then we get results like these:\n\n   26b455f21e (\"hashmap_put takes \"struct hashmap_entry *\"\", 2019-10-06)\n   01991cee86 (\"config/alias.txt: change \" and ' to `\", 2019-06-05)\n\nI noticed the lack of quoting in the code and was worried about the\noutput being confusing or unclean, but after staring at the examples\nabove for a while I find that it's not that bad.  It's reversible by\nremoving the outer quotes.  So perhaps we can keep it like this.\n\nRené\n"},{"id":"385839","messageId":"xmqqftiwl02i.fsf@gitster-ct.c.googlers.com","threadId":"52187","inReplyTo":"08afdbcd-5972-05f9-ec8c-b12bd29d9030@web.de","subject":"Re: [PATCH v2 09/10] pretty: implement 'summary' format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-10T06:25:41Z","receivedAt":"2019-11-10T06:25:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> Hmm, that's quite a lot of code to add to the formatting code with its\n> repeated special-case checks.  Why not implement it as a built-in user\n> format, like making it an alias for something like this?\n>\n>    git log --format='%C(auto)%h (\"%s\", %as)'\n>\n> We don't have %as, yet, but making --date=short available as a\n> placeholder would be a good idea anyway (patch below).\n\nYes!  Implementing the 'summary' internally as merely an alias to a\ncanned user format does sound like the right approach.\n\nFurther, instead of inventing %as, I think you could just use %ad\nthere, and when 'summary' uses that canned user format, flip the\ndefault date format to short.\n\nThat way, \"git show -s --pretty=summary --date=iso\" would be\navailable to those who like the format.\n\nThanks.\n"},{"id":"385954","messageId":"20191111234710.GA23111@generichostname","threadId":"52187","inReplyTo":"xmqqftiwl02i.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v2 09/10] pretty: implement 'summary' format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-11T23:47:10Z","receivedAt":"2019-11-11T23:47:15Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi all,\n\nOn Sun, Nov 10, 2019 at 03:25:41PM +0900, Junio C Hamano wrote:\n> René Scharfe <l.s.r@web.de> writes:\n> \n> > Hmm, that's quite a lot of code to add to the formatting code with its\n> > repeated special-case checks.  Why not implement it as a built-in user\n> > format, like making it an alias for something like this?\n> >\n> >    git log --format='%C(auto)%h (\"%s\", %as)'\n> >\n> > We don't have %as, yet, but making --date=short available as a\n> > placeholder would be a good idea anyway (patch below).\n> \n> Yes!  Implementing the 'summary' internally as merely an alias to a\n> canned user format does sound like the right approach.\n\nWe don't have any canned user formats currently, do we? I'm trying to\nfigure out where to insert the code to do this.\n\nIs the idea to just insert a row in the builtin_formats[] table in\nsetup_commit_formats() with the `user_format` field populated?\n\n> \n> Further, instead of inventing %as, I think you could just use %ad\n> there, and when 'summary' uses that canned user format, flip the\n> default date format to short.\n> \n> That way, \"git show -s --pretty=summary --date=iso\" would be\n> available to those who like the format.\n\nIf we do implement it as a canned format, then we lose support for\ndisplaying `--no-abbrev`, `--walk-reflogs`, `--decorate`. Would we be\nokay with this?\n\nThanks,\n\nDenton\n\n> \n> Thanks.\n"},{"id":"386147","messageId":"20191114003757.GR4348@szeder.dev","threadId":"52187","inReplyTo":"20191111234710.GA23111@generichostname","subject":"Re: [PATCH v2 09/10] pretty: implement 'summary' format","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-11-14T00:37:57Z","receivedAt":"2019-11-14T00:38:05Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Nov 11, 2019 at 03:47:10PM -0800, Denton Liu wrote:\n> On Sun, Nov 10, 2019 at 03:25:41PM +0900, Junio C Hamano wrote:\n> > René Scharfe <l.s.r@web.de> writes:\n> > \n> > > Hmm, that's quite a lot of code to add to the formatting code with its\n> > > repeated special-case checks.  Why not implement it as a built-in user\n> > > format, like making it an alias for something like this?\n> > >\n> > >    git log --format='%C(auto)%h (\"%s\", %as)'\n> > >\n> > > We don't have %as, yet, but making --date=short available as a\n> > > placeholder would be a good idea anyway (patch below).\n> > \n> > Yes!  Implementing the 'summary' internally as merely an alias to a\n> > canned user format does sound like the right approach.\n> \n> We don't have any canned user formats currently, do we? I'm trying to\n> figure out where to insert the code to do this.\n> \n> Is the idea to just insert a row in the builtin_formats[] table in\n> setup_commit_formats() with the `user_format` field populated?\n\nYeah, it's as simple as adding:\n\n  { \"reference\",  CMIT_FMT_USERFORMAT,    1,      0, 0, \"%C(auto)%h (%s, %as)\" }\n\nWorks like a charm, I've been using it for a few years now:\n\n  https://github.com/szeder/git/commit/3604d0c28e7e2da5415986468994ef71a972e4ed\n\nbut never seriously considered for submission, because I didn't want\nto argue about removing the double-quotes around the subject, and\ncouldn't be bothered to check the corner cases (e.g. what if a user\nsets a pretty format alias with the same name in the configuration?).\n\n"},{"id":"386149","messageId":"20191114011048.GS4348@szeder.dev","threadId":"52187","inReplyTo":"e74eab6d21f655698ef8b6e1286b44ea070a7af7.1573241590.git.liu.denton@gmail.com","subject":"Re: [PATCH v2 09/10] pretty: implement 'summary' format","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-11-14T01:10:48Z","receivedAt":"2019-11-14T01:10:54Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Nov 08, 2019 at 12:08:34PM -0800, Denton Liu wrote:\n> The standard format for referencing other commits within some projects\n> (such as git.git) is the summary format. This is described in\n> Documentation/SubmittingPatches as\n> \n> \tIf you want to reference a previous commit in the history of a stable\n> \tbranch, use the format \"abbreviated hash (subject, date)\",\n> \twith the subject enclosed in a pair of double-quotes, like this:\n> \n> \t....\n> \t\tCommit f86a374 (\"pack-bitmap.c: fix a memleak\", 2015-03-30)\n> \t\tnoticed that ...\n> \t....\n> \n> Since this format is so commonly used, standardize it as a pretty\n> format.\n\nSubmittingPatches is simply wrong: our de-facto standard format for\nreferencing other commits does not enclose the subject in a pair of\ndouble-quotes:\n\n  $ git log v2.24.0 |grep -E '[0-9a-f]{7} \\(\"' |wc -l\n  785\n  $ git log v2.24.0 |grep -E '[0-9a-f]{7} \\([^\"]' |wc -l\n  2276\n\nThose double-quotes don't add any value to the references, but they\nresult in weird looking references for 1083 of our commits whose\nsubject lines happen to end with double-quotes, e.g.:\n\n  f23a465132 (\"hashmap_get{,_from_hash} return \"struct hashmap_entry *\"\", 2019-10-06)\n\nand without those unnecessary pair of double-quotes we would have\n~3000 more commits whose summary would fit on a single line.\n\n"},{"id":"386157","messageId":"xmqqy2wj89dv.fsf@gitster-ct.c.googlers.com","threadId":"52187","inReplyTo":"20191114003757.GR4348@szeder.dev","subject":"Re: [PATCH v2 09/10] pretty: implement 'summary' format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-14T02:44:12Z","receivedAt":"2019-11-14T02:44:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder.dev@gmail.com> writes:\n\n> Yeah, it's as simple as adding:\n>\n>   { \"reference\",  CMIT_FMT_USERFORMAT,    1,      0, 0, \"%C(auto)%h (%s, %as)\" }\n>\n> Works like a charm, I've been using it for a few years now:\n>\n>   https://github.com/szeder/git/commit/3604d0c28e7e2da5415986468994ef71a972e4ed\n\nThe word \"reference\" does sound more to the point for the feature\nthan \"summary\", and it is nice to see that the required change is\nessentially a single liner ;-)\n\n> but never seriously considered for submission, because I didn't want\n> to argue about removing the double-quotes around the subject, and\n\nI personally do not care whether the title is naked or inside a\ndq-pair, as that part is purely for human consumption.  Being for\nhuman consumption, I guess we can argue that the shorter the better,\nso we may want to standardise the recommendation we give in our\ntutorials and such.\n\n> couldn't be bothered to check the corner cases (e.g. what if a user\n> sets a pretty format alias with the same name in the configuration?).\n\nIt would be already possible to collide with built-in names, like\n\"short\", with or without your addition, wouldn't it?  Then that is\nnot an issue you would need to be worried about, right?\n\nThanks.\n"},{"id":"386201","messageId":"cover.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573241590.git.liu.denton@gmail.com","subject":"[PATCH v3 00/10] learn the \"reference\" pretty format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:04Z","receivedAt":"2019-11-14T20:47:10Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi all,\n\nThanks for the feedback from the last round. I've implemented it as a\ncanned user-format which reduces the amount of code we need to touch.\nThanks for the advice!\n\n\nOn this mailing list (and many others) the standard way to reference\nother commits with the \"reference\" format, e.g. \"f86a374 (pack-bitmap.c:\nfix a memleak, 2015-03-30)\". Since it's so commonly used, let's\nstandardise it as a pretty format.\n\nPatches 5-7 were cleanup patches that were critical in earlier\niterations of the series but no longer are critical for the rest of the\npatchset. Nonetheless, let's include them since they improve the quality\nof the codebase.\n\nChanges since v2:\n\n* Rename from \"summary\" to \"reference\"\n\n* Implement the feature as a canned userformat\n\n* Implement the %*s (short date) format string element\n\n* Remove the enclosing dqs around the subject\n\nChanges since v1:\n\n* Replace more references to \"sha1\" with \"hash\"\n\n* Clean up 8/10 by losing the allocation and making the subject less\n  misleading\n\n* Add tests in 7/10 to ensure 8/10 does not change any behaviour\n\nDenton Liu (9):\n  SubmittingPatches: use generic terms for hash\n  pretty-formats.txt: use generic terms for hash\n  SubmittingPatches: remove dq from commit reference\n  completion: complete `tformat:` pretty format\n  revision: make get_revision_mark() return const pointer\n  pretty.c: inline initalize format_context\n  t4205: cover `git log --reflog -z` blindspot\n  pretty: implement 'reference' format\n  SubmittingPatches: use `--pretty=reference`\n\nRené Scharfe (1):\n  pretty: provide short date format\n\n Documentation/SubmittingPatches        | 16 ++++--\n Documentation/pretty-formats.txt       | 28 +++++++---\n Documentation/pretty-options.txt       |  2 +-\n Documentation/rev-list-options.txt     |  4 +-\n contrib/completion/git-completion.bash |  2 +-\n pretty.c                               | 17 +++---\n revision.c                             |  4 +-\n revision.h                             |  4 +-\n t/t4205-log-pretty-formats.sh          | 72 ++++++++++++++++++++++++++\n 9 files changed, 123 insertions(+), 26 deletions(-)\n\nRange-diff against v2:\n 1:  38a55e978f =  1:  5a9e19b37e SubmittingPatches: use generic terms for hash\n 2:  9080b0db1f =  2:  4f2a9bef32 pretty-formats.txt: use generic terms for hash\n -:  ---------- >  3:  277d2b2506 SubmittingPatches: remove dq from commit reference\n -:  ---------- >  4:  442394eca8 completion: complete `tformat:` pretty format\n 3:  1abab57072 =  5:  ca01bfa085 revision: make get_revision_mark() return const pointer\n 4:  50ee13202c <  -:  ---------- revision: change abbrev_commit_given to abbrev_commit_explicit\n 5:  45f0ceb476 !  6:  301e3adcdc pretty.c: inline initalize format_context\n    @@ Commit message\n         Instead of memsetting and then initializing the fields in the struct,\n         move the initialization of `format_context` to its assignment.\n     \n    -    In preparation for a future commit where we mechanically move lines from\n    -    repo_format_commit_message() into a helper function,\n    -    `format_context.wrap_start` is not generically used so move its\n    -    assignment closer to its use.\n    -\n         Signed-off-by: Denton Liu <liu.denton@gmail.com>\n     \n      ## pretty.c ##\n    @@ pretty.c: void repo_format_commit_message(struct repository *r,\n     -\tstruct format_commit_context context;\n     +\tstruct format_commit_context context = {\n     +\t\t.commit = commit,\n    -+\t\t.pretty_ctx = pretty_ctx\n    ++\t\t.pretty_ctx = pretty_ctx,\n    ++\t\t.wrap_start = sb->len\n     +\t};\n      \tconst char *output_enc = pretty_ctx->output_encoding;\n      \tconst char *utf8 = \"UTF-8\";\n    @@ pretty.c: void repo_format_commit_message(struct repository *r,\n      \t/*\n      \t * convert a commit message to UTF-8 first\n      \t * as far as 'format_commit_item' assumes it in UTF-8\n    -@@ pretty.c: void repo_format_commit_message(struct repository *r,\n    - \t\t\t\t\t       &context.commit_encoding,\n    - \t\t\t\t\t       utf8);\n    - \n    -+\tcontext.wrap_start = sb->len;\n    - \tstrbuf_expand(sb, format, format_commit_item, &context);\n    - \trewrap_message_tail(sb, &context, 0, 0, 0);\n    - \n 6:  e036a1a86d <  -:  ---------- pretty.c: extract functionality to repo_format_commit_generic()\n 7:  7de6fe3282 !  7:  b1256c52ba t4205: cover `git log --reflog -z` blindspot\n    @@ t/t4205-log-pretty-formats.sh: test_expect_failure C_LOCALE_OUTPUT 'NUL terminat\n      \ttest_cmp expected actual\n      '\n      \n    -+emit_nul () {\n    -+\techo | tr '\\n' '\\000'\n    -+}\n    -+\n     +for p in short medium full fuller email raw\n     +do\n     +\ttest_expect_success \"NUL termination with --reflog --pretty=$p\" '\n    -+\t\t>expect &&\n     +\t\trevs=\"$(git rev-list --reflog)\" &&\n     +\t\tfor r in $revs\n     +\t\tdo\n    -+\t\t\tgit show -s \"$r\" --pretty='$p' >>expect || return 1\n    -+\t\t\temit_nul >>expect\n    -+\t\tdone &&\n    -+\t\tgit log -z --reflog --pretty='$p' >actual &&\n    -+\t\temit_nul >>actual &&\n    ++\t\t\tgit show -s \"$r\" --pretty=\"$p\" &&\n    ++\t\t\tprintf \"\\0\" || return 1\n    ++\t\tdone >expect &&\n    ++\t\t{\n    ++\t\t\tgit log -z --reflog --pretty=\"$p\" &&\n    ++\t\t\tprintf \"\\0\"\n    ++\t\t} >actual &&\n     +\t\ttest_cmp expect actual\n     +\t'\n     +done\n     +\n     +test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n    -+\t>expect &&\n     +\trevs=\"$(git rev-list --reflog)\" &&\n     +\tfor r in $revs\n     +\tdo\n    -+\t\t# trim trailing newline\n    -+\t\toutput=\"$(git show -s --pretty=oneline \"$r\")\" || return 1\n    -+\t\tprintf \"%s\" \"$output\" >>expect\n    -+\t\temit_nul >>expect\n    -+\tdone &&\n    ++\t\tgit show -s --pretty=oneline \"$r\" >raw &&\n    ++\t\tcat raw | lf_to_nul || exit 1\n    ++\tdone >expect &&\n    ++\t# the trailing NUL is already produced so we do not need to\n    ++\t# output another one\n     +\tgit log -z --pretty=oneline --reflog >actual &&\n    -+\t# no trailing NUL\n     +\ttest_cmp expect actual\n     +'\n     +\n 8:  3bda0f0ad7 <  -:  ---------- reflog-walk.c: move where the newline is added\n -:  ---------- >  8:  fe5cb165ae pretty: provide short date format\n 9:  28c4f7f517 !  9:  470a2b0f4f pretty: implement 'summary' format\n    @@ Metadata\n     Author: Denton Liu <liu.denton@gmail.com>\n     \n      ## Commit message ##\n    -    pretty: implement 'summary' format\n    +    pretty: implement 'reference' format\n     \n         The standard format for referencing other commits within some projects\n    -    (such as git.git) is the summary format. This is described in\n    +    (such as git.git) is the reference format. This is described in\n         Documentation/SubmittingPatches as\n     \n                 If you want to reference a previous commit in the history of a stable\n    -            branch, use the format \"abbreviated hash (subject, date)\",\n    -            with the subject enclosed in a pair of double-quotes, like this:\n    +            branch, use the format \"abbreviated hash (subject, date)\", like this:\n     \n                 ....\n    -                    Commit f86a374 (\"pack-bitmap.c: fix a memleak\", 2015-03-30)\n    +                    Commit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)\n                         noticed that ...\n                 ....\n     \n         Since this format is so commonly used, standardize it as a pretty\n         format.\n     \n    -    This format is implemented as a separate flow that skips most of\n    -    pretty_print_commit() and instead calls format_commit_summary(). The\n    -    reason why this is done is because the other pretty formats expect\n    -    output to be generated in a specific order. Specifically, the header,\n    -    including the date, is always printed before the commit message,\n    -    including the subject. Reversing the order would be possible but would\n    -    involve butchering pretty_print_commit() so it is implemented as a\n    -    separate flow.\n    +    The tests that are implemented essentially show that the format-string\n    +    does not change in response to various log options. This is useful\n    +    because, for future developers, it shows that we've considered the\n    +    limitations of the \"canned format-string\" approach and we are fine with\n    +    them.\n     \n    +    Based-on-a-patch-by: SZEDER Gábor <szeder.dev@gmail.com>\n         Signed-off-by: Denton Liu <liu.denton@gmail.com>\n     \n      ## Documentation/pretty-formats.txt ##\n    @@ Documentation/pretty-formats.txt: This is designed to be as compact as possible.\n      \n      \t       <full commit message>\n      \n    -+* 'summary'\n    ++* 'reference'\n     +\n    -+\t  <abbrev hash> (\"<title line>\", <short author date>)\n    ++\t  <abbrev hash> (<title line>, <short author date>)\n     ++\n     +This format is useful for referring to other commits when writing a new\n    -+commit message. Although by default, '<abbrev hash>' is used, this can\n    -+be overridden with '--no-abbrev'. In addition, '<short author date>' can\n    -+be overridden by with '--date='.\n    ++commit message. It uses the following canned user format:\n    ++`%C(auto)%h (%s, %as)`. This means it will not respect options that\n    ++change the output format such as `--date` `--no-abbrev-commit`, and\n    ++`--walk-reflogs`.\n     +\n      * 'email'\n      \n    @@ Documentation/pretty-options.txt\n      \tPretty-print the contents of the commit logs in a given format,\n      \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n     -\t'full', 'fuller', 'email', 'raw', 'format:<string>'\n    -+\t'full', 'fuller', 'summary', 'email', 'raw', 'format:<string>'\n    ++\t'full', 'fuller', 'reference', 'email', 'raw', 'format:<string>'\n      \tand 'tformat:<string>'.  When '<format>' is none of the above,\n      \tand has '%placeholder' in it, it acts as if\n      \t'--pretty=tformat:<format>' were given.\n     \n      ## Documentation/rev-list-options.txt ##\n    -@@ Documentation/rev-list-options.txt: depending on a few rules:\n    - 4. Otherwise, show the index format.\n    - --\n    +@@ Documentation/rev-list-options.txt: list.\n    + \texclude (that is, '{caret}commit', 'commit1..commit2',\n    + \tand 'commit1\\...commit2' notations cannot be used).\n      +\n    --Under `--pretty=oneline`, the commit message is\n    -+Under `--pretty=oneline` and `--pretty=summary`, the commit message is\n    +-With `--pretty` format other than `oneline` (for obvious reasons),\n    ++With `--pretty` format other than `oneline` and `reference` (for obvious reasons),\n    + this causes the output to have two extra lines of information\n    + taken from the reflog.  The reflog designator in the output may be shown\n    + as `ref@{Nth}` (where `Nth` is the reverse-chronological index in the\n    +@@ Documentation/rev-list-options.txt: Under `--pretty=oneline`, the commit message is\n      prefixed with this information on the same line.\n      This option cannot be combined with `--reverse`.\n      See also linkgit:git-reflog[1].\n    +++\n    ++Under `--pretty=summary`, this information will not be shown at all.\n    + \n    + --merge::\n    + \tAfter a failed merge, show refs that touch files having a\n     \n    - ## builtin/log.c ##\n    -@@ builtin/log.c: static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n    - \t\tread_mailmap(rev->mailmap, NULL);\n    - \t}\n    + ## contrib/completion/git-completion.bash ##\n    +@@ contrib/completion/git-completion.bash: __git_log_shortlog_options=\"\n    + \t--all-match --invert-grep\n    + \"\n      \n    --\tif (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {\n    -+\tif (rev->pretty_given) {\n    -+\t\tswitch (rev->commit_format) {\n    -+\n    - \t\t/*\n    - \t\t * \"log --pretty=raw\" is special; ignore UI oriented\n    - \t\t * configuration variables such as decoration.\n    - \t\t */\n    --\t\tif (!decoration_given)\n    --\t\t\tdecoration_style = 0;\n    --\t\tif (!rev->abbrev_commit_explicit)\n    --\t\t\trev->abbrev_commit = 0;\n    -+\t\tcase CMIT_FMT_RAW:\n    -+\t\t\tif (!decoration_given)\n    -+\t\t\t\tdecoration_style = 0;\n    -+\t\t\tif (!rev->abbrev_commit_explicit)\n    -+\t\t\t\trev->abbrev_commit = 0;\n    -+\t\t\tbreak;\n    -+\n    -+\t\t/*\n    -+\t\t * \"log --pretty=summary\" is special; ignore UI oriented\n    -+\t\t * configuration variables such as decoration but keep\n    -+\t\t * abbreviations.\n    -+\t\t */\n    -+\t\tcase CMIT_FMT_SUMMARY:\n    -+\t\t\tif (!decoration_given)\n    -+\t\t\t\tdecoration_style = 0;\n    -+\t\t\tif (!rev->abbrev_commit_explicit)\n    -+\t\t\t\trev->abbrev_commit = 1;\n    -+\t\t\tbreak;\n    -+\n    -+\t\tdefault:\n    -+\t\t\tbreak;\n    -+\t\t}\n    - \t}\n    +-__git_log_pretty_formats=\"oneline short medium full fuller email raw format: tformat: mboxrd\"\n    ++__git_log_pretty_formats=\"oneline short medium full fuller reference email raw format: tformat: mboxrd\"\n    + __git_log_date_formats=\"relative iso8601 iso8601-strict rfc2822 short local default raw unix format:\"\n      \n    - \tif (decoration_style) {\n    -\n    - ## log-tree.c ##\n    -@@ log-tree.c: void show_log(struct rev_info *opt)\n    - \t\tctx.print_email_subject = 1;\n    - \t} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {\n    - \t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), opt->diffopt.file);\n    --\t\tif (opt->commit_format != CMIT_FMT_ONELINE)\n    -+\t\tif (opt->commit_format != CMIT_FMT_ONELINE &&\n    -+\t\t    opt->commit_format != CMIT_FMT_SUMMARY)\n    - \t\t\tfputs(\"commit \", opt->diffopt.file);\n    - \n    - \t\tif (!opt->graph)\n    -@@ log-tree.c: void show_log(struct rev_info *opt)\n    - \t\t\t       find_unique_abbrev(&parent->object.oid, abbrev_commit));\n    - \t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);\n    - \t\tshow_decorations(opt, commit);\n    --\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n    -+\t\tif (opt->commit_format == CMIT_FMT_ONELINE ||\n    -+\t\t    opt->commit_format == CMIT_FMT_SUMMARY) {\n    - \t\t\tputc(' ', opt->diffopt.file);\n    - \t\t} else {\n    - \t\t\tputc('\\n', opt->diffopt.file);\n    -@@ log-tree.c: void show_log(struct rev_info *opt)\n    - \t\t\t * graph info here.\n    - \t\t\t */\n    - \t\t\tshow_reflog_message(opt->reflog_info,\n    --\t\t\t\t\t    opt->commit_format == CMIT_FMT_ONELINE,\n    -+\t\t\t\t\t    (opt->commit_format == CMIT_FMT_ONELINE ||\n    -+\t\t\t\t\t     opt->commit_format == CMIT_FMT_SUMMARY),\n    - \t\t\t\t\t    &opt->date_mode,\n    - \t\t\t\t\t    opt->date_mode_explicit);\n    - \t\t\tif (opt->commit_format == CMIT_FMT_ONELINE) {\n    - \t\t\t\tputc('\\n', opt->diffopt.file);\n    - \t\t\t\treturn;\n    -+\t\t\t} else if (opt->commit_format == CMIT_FMT_SUMMARY) {\n    -+\t\t\t\tputc(' ', opt->diffopt.file);\n    - \t\t\t}\n    - \t\t}\n    - \t}\n    + _git_log ()\n     \n      ## pretty.c ##\n     @@ pretty.c: static void setup_commit_formats(void)\n    @@ pretty.c: static void setup_commit_formats(void)\n      \t\t{ \"full\",\tCMIT_FMT_FULL,\t\t0,\t8 },\n     -\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 }\n     +\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 },\n    -+\t\t{ \"summary\",\tCMIT_FMT_SUMMARY,\t1,\t0 },\n    ++\t\t{ \"reference\",\tCMIT_FMT_USERFORMAT,\t1,\t0,\n    ++\t\t\t0, \"%C(auto)%h (%s, %as)\" },\n      \t\t/*\n      \t\t * Please update $__git_log_pretty_formats in\n      \t\t * git-completion.bash when you add new formats.\n    -@@ pretty.c: void repo_format_commit_message(struct repository *r,\n    - \t\t\t\t   do_repo_format_commit_message, (void *)format);\n    - }\n    - \n    -+static void do_repo_format_commit_summary(struct strbuf *sb,\n    -+\t\t\t\t\t  struct format_commit_context *context,\n    -+\t\t\t\t\t  void *additional_context)\n    -+{\n    -+\tstruct ident_split ident;\n    -+\n    -+\tparse_commit_header(context);\n    -+\tparse_commit_message(context);\n    -+\n    -+\tstrbuf_addstr(sb, \"(\\\"\");\n    -+\tformat_subject(sb, context->message + context->subject_off, \" \");\n    -+\tif (!split_ident_line(&ident,\n    -+\t\t\t      context->message + context->author.off,\n    -+\t\t\t      context->author.len)) {\n    -+\t\tstrbuf_addstr(sb, \"\\\", \");\n    -+\t\tstrbuf_addstr(sb, show_ident_date(&ident, &context->pretty_ctx->date_mode));\n    -+\t}\n    -+\tstrbuf_addstr(sb, \")\");\n    -+}\n    -+\n    - static void pp_header(struct pretty_print_context *pp,\n    - \t\t      const char *encoding,\n    - \t\t      const struct commit *commit,\n    -@@ pretty.c: void pretty_print_commit(struct pretty_print_context *pp,\n    - \t\tformat_commit_message(commit, user_format, sb, pp);\n    - \t\treturn;\n    - \t}\n    -+\tif (pp->fmt == CMIT_FMT_SUMMARY) {\n    -+\t\tif (!pp->date_mode_explicit)\n    -+\t\t\tpp->date_mode = *DATE_MODE(SHORT);\n    -+\n    -+\t\trepo_format_commit_generic(the_repository, commit, sb, pp,\n    -+\t\t\t\t\t   do_repo_format_commit_summary, NULL);\n    -+\t\treturn;\n    -+\t}\n    - \n    - \tencoding = get_log_output_encoding();\n    - \tmsg = reencoded = logmsg_reencode(commit, NULL, encoding);\n    -\n    - ## pretty.h ##\n    -@@ pretty.h: enum cmit_fmt {\n    - \tCMIT_FMT_FULL,\n    - \tCMIT_FMT_FULLER,\n    - \tCMIT_FMT_ONELINE,\n    -+\tCMIT_FMT_SUMMARY,\n    - \tCMIT_FMT_EMAIL,\n    - \tCMIT_FMT_MBOXRD,\n    - \tCMIT_FMT_USERFORMAT,\n     \n      ## t/t4205-log-pretty-formats.sh ##\n    -@@ t/t4205-log-pretty-formats.sh: do\n    - \t'\n    - done\n    - \n    --test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n    --\t>expect &&\n    --\trevs=\"$(git rev-list --reflog)\" &&\n    --\tfor r in $revs\n    --\tdo\n    --\t\t# trim trailing newline\n    --\t\toutput=\"$(git show -s --pretty=oneline \"$r\")\" || return 1\n    --\t\tprintf \"%s\" \"$output\" >>expect\n    --\t\temit_nul >>expect\n    --\tdone &&\n    --\tgit log -z --pretty=oneline --reflog >actual &&\n    --\t# no trailing NUL\n    --\ttest_cmp expect actual\n    --'\n    -+for p in oneline summary\n    -+do\n    -+\ttest_expect_success \"NUL termination with --reflog --pretty=$p\" '\n    -+\t\t>expect &&\n    -+\t\trevs=\"$(git rev-list --reflog)\" &&\n    -+\t\tfor r in $revs\n    -+\t\tdo\n    -+\t\t\t# trim trailing newline\n    -+\t\t\toutput=\"$(git show -s --pretty='$p' \"$r\")\" || return 1\n    -+\t\t\tprintf \"%s\" \"$output\" >>expect\n    -+\t\t\temit_nul >>expect\n    -+\t\tdone &&\n    -+\t\tgit log -z --pretty='$p' --reflog >actual &&\n    -+\t\t# no trailing NUL\n    -+\t\ttest_cmp expect actual\n    -+\t'\n    -+done\n    - \n    - test_expect_success 'setup more commits' '\n    - \ttest_commit \"message one\" one one message-one &&\n     @@ t/t4205-log-pretty-formats.sh: test_expect_success '%S in git log --format works with other placeholders (part\n      \ttest_cmp expect actual\n      '\n      \n    -+test_expect_success 'log --pretty=summary' '\n    -+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n    -+\tgit log --pretty=summary >actual &&\n    ++test_expect_success 'log --pretty=reference' '\n    ++\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n    ++\tgit log --pretty=reference >actual &&\n     +\ttest_cmp expect actual\n     +'\n     +\n    -+test_expect_success 'log --pretty=summary with log.date is overridden by short date' '\n    -+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n    -+\ttest_config log.date rfc &&\n    -+\tgit log --pretty=summary >actual &&\n    ++test_expect_success 'log --pretty=reference always uses short date' '\n    ++\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n    ++\tgit log --date=rfc --pretty=reference >actual &&\n     +\ttest_cmp expect actual\n     +'\n     +\n    -+test_expect_success 'log --pretty=summary with explicit date overrides short date' '\n    -+\tgit log --date=rfc --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n    -+\tgit log --date=rfc --pretty=summary >actual &&\n    ++test_expect_success 'log --pretty=reference is never unabbreviated' '\n    ++\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n    ++\tgit log --no-abbrev-commit --pretty=reference >actual &&\n     +\ttest_cmp expect actual\n     +'\n     +\n    -+test_expect_success 'log --pretty=summary with log.abbrevCommit is overidden' '\n    -+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n    -+\ttest_config log.abbrevCommit false &&\n    -+\tgit log --pretty=summary >actual &&\n    ++test_expect_success 'log --pretty=reference is never decorated' '\n    ++\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n    ++\tgit log --decorate=short --pretty=reference >actual &&\n     +\ttest_cmp expect actual\n     +'\n     +\n    -+test_expect_success 'log --pretty=summary with explicit --no-abbrev overrides abbreviated' '\n    -+\tgit log --date=short --pretty=\"tformat:%H (\\\"%s\\\", %ad)\" >expect &&\n    -+\tgit log --no-abbrev --pretty=summary >actual &&\n    ++test_expect_success 'log --pretty=reference does not output reflog info' '\n    ++\tgit log --walk-reflogs --pretty=\"tformat:%h (%s, %as)\" >expect &&\n    ++\tgit log --walk-reflogs --pretty=reference >actual &&\n     +\ttest_cmp expect actual\n     +'\n     +\n    -+test_expect_success 'log --pretty=summary with log.decorate is overridden' '\n    -+\tgit log --date=short --pretty=\"tformat:%h (\\\"%s\\\", %ad)\" >expect &&\n    -+\ttest_config log.decorate short &&\n    -+\tgit log --pretty=summary >actual &&\n    -+\ttest_cmp expect actual\n    -+'\n    -+\n    -+test_expect_success 'log --pretty=summary with explicit decorate overrides no decoration' '\n    -+\tgit log --date=short --pretty=\"tformat:%h%d (\\\"%s\\\", %ad)\" >expect &&\n    -+\tgit log --decorate=short --pretty=summary >actual &&\n    -+\ttest_cmp expect actual\n    -+'\n    -+\n    -+test_expect_success 'log --pretty=summary with --walk-reflogs' '\n    -+\ttest_config log.date short &&\n    -+\tgit log --walk-reflogs --pretty=\"tformat:%h %gd: %gs (\\\"%s\\\", %ad)\" >expect &&\n    -+\tgit log --walk-reflogs --pretty=summary >actual &&\n    ++test_expect_success 'log --pretty=reference is colored appropriately' '\n    ++\tgit log --color=always --pretty=\"tformat:%C(auto)%h (%s, %as)\" >expect &&\n    ++\tgit log --color=always --pretty=reference >actual &&\n     +\ttest_cmp expect actual\n     +'\n     +\n10:  a6638f0c7c ! 10:  5f80e4633d SubmittingPatches: use `--pretty=summary`\n    @@ Metadata\n     Author: Denton Liu <liu.denton@gmail.com>\n     \n      ## Commit message ##\n    -    SubmittingPatches: use `--pretty=summary`\n    +    SubmittingPatches: use `--pretty=reference`\n     \n    -    Since Git was taught the `--pretty=summary` option, it is no longer\n    +    Since Git was taught the `--pretty=reference` option, it is no longer\n         necessary to manually specify the format string to get the commit\n    -    summary. Teach users to use the new option while keeping the old\n    +    reference. Teach users to use the new option while keeping the old\n         invocation around in case they have an older version of Git.\n     \n         Signed-off-by: Denton Liu <liu.denton@gmail.com>\n     \n      ## Documentation/SubmittingPatches ##\n    -@@ Documentation/SubmittingPatches: with the subject enclosed in a pair of double-quotes, like this:\n    - The \"Copy commit summary\" command of gitk can be used to obtain this\n    - format, or this invocation of `git show`:\n    +@@ Documentation/SubmittingPatches: The \"Copy commit summary\" command of gitk can be used to obtain this\n    + format (with the subject enclosed in a pair of double-quotes), or this\n    + invocation of `git show`:\n      \n     +....\n    -+\tgit show -s --pretty=summary <commit>\n    ++\tgit show -s --pretty=reference <commit>\n     +....\n     +\n    -+or, on an older version of Git without support for --pretty=summary:\n    ++or, on an older version of Git without support for --pretty=reference:\n     +\n      ....\n    - \tgit show -s --date=short --pretty='format:%h (\"%s\", %ad)' <commit>\n    + \tgit show -s --date=short --pretty='format:%h (%s, %ad)' <commit>\n      ....\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386202","messageId":"5a9e19b37ea77660a2f3900f98fe24c2569af76d.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 01/10] SubmittingPatches: use generic terms for hash","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:07Z","receivedAt":"2019-11-14T20:47:12Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git is planning on upgrading from SHA-1 to be more hash-agnostic,\nreplace specific references to SHA-1 with more generic terminology.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex 1a60cc1329..bb7e33ce15 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -142,7 +142,7 @@ archive, summarize the relevant points of the discussion.\n \n [[commit-reference]]\n If you want to reference a previous commit in the history of a stable\n-branch, use the format \"abbreviated sha1 (subject, date)\",\n+branch, use the format \"abbreviated hash (subject, date)\",\n with the subject enclosed in a pair of double-quotes, like this:\n \n ....\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386203","messageId":"4f2a9bef3238a4fe58b5f1e0cb96809669f27882.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 02/10] pretty-formats.txt: use generic terms for hash","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:10Z","receivedAt":"2019-11-14T20:47:14Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git is planning on upgrading from SHA-1 to be more hash-agnostic,\nreplace specific references to SHA-1 with more generic terminology.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 31c6e8d2b8..4cefa64eeb 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -4,7 +4,7 @@ PRETTY FORMATS\n If the commit is a merge, and if the pretty-format\n is not 'oneline', 'email' or 'raw', an additional line is\n inserted before the 'Author:' line.  This line begins with\n-\"Merge: \" and the sha1s of ancestral commits are printed,\n+\"Merge: \" and the hashes of ancestral commits are printed,\n separated by spaces.  Note that the listed commits may not\n necessarily be the list of the *direct* parent commits if you\n have limited your view of history: for example, if you are\n@@ -20,20 +20,20 @@ built-in formats:\n \n * 'oneline'\n \n-\t  <sha1> <title line>\n+\t  <hash> <title line>\n +\n This is designed to be as compact as possible.\n \n * 'short'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \n \t      <title line>\n \n * 'medium'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Date:   <author date>\n \n@@ -43,7 +43,7 @@ This is designed to be as compact as possible.\n \n * 'full'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Commit: <committer>\n \n@@ -53,7 +53,7 @@ This is designed to be as compact as possible.\n \n * 'fuller'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author:     <author>\n \t  AuthorDate: <author date>\n \t  Commit:     <committer>\n@@ -65,7 +65,7 @@ This is designed to be as compact as possible.\n \n * 'email'\n \n-\t  From <sha1> <date>\n+\t  From <hash> <date>\n \t  From: <author>\n \t  Date: <author date>\n \t  Subject: [PATCH] <title line>\n@@ -75,7 +75,7 @@ This is designed to be as compact as possible.\n * 'raw'\n +\n The 'raw' format shows the entire commit exactly as\n-stored in the commit object.  Notably, the SHA-1s are\n+stored in the commit object.  Notably, the hashes are\n displayed in full, regardless of whether --abbrev or\n --no-abbrev are used, and 'parents' information show the\n true parent commits, without taking grafts or history\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386204","messageId":"277d2b2506da5c67044dc684adaba3ec5e0640eb.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 03/10] SubmittingPatches: remove dq from commit reference","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:12Z","receivedAt":"2019-11-14T20:47:16Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Quoting SZEDER Gábor[1],\n\n\tSubmittingPatches is simply wrong: our de-facto standard format for\n\treferencing other commits does not enclose the subject in a pair of\n\tdouble-quotes:\n\n\t  $ git log v2.24.0 |grep -E '[0-9a-f]{7} \\(\"' |wc -l\n\t  785\n\t  $ git log v2.24.0 |grep -E '[0-9a-f]{7} \\([^\"]' |wc -l\n\t  2276\n\n\tThose double-quotes don't add any value to the references, but they\n\tresult in weird looking references for 1083 of our commits whose\n\tsubject lines happen to end with double-quotes, e.g.:\n\n\t  f23a465132 (\"hashmap_get{,_from_hash} return \"struct hashmap_entry *\"\", 2019-10-06)\n\n\tand without those unnecessary pair of double-quotes we would have\n\t~3000 more commits whose summary would fit on a single line.\n\nRemove references to the enclosing double-quotes from SubmittingPatches\nsince our de-facto standard for referencing commits does not actually\nuse them.\n\n[1]: cf. <20191114011048.GS4348@szeder.dev>\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex bb7e33ce15..7860dd2568 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -142,19 +142,19 @@ archive, summarize the relevant points of the discussion.\n \n [[commit-reference]]\n If you want to reference a previous commit in the history of a stable\n-branch, use the format \"abbreviated hash (subject, date)\",\n-with the subject enclosed in a pair of double-quotes, like this:\n+branch, use the format \"abbreviated hash (subject, date)\", like this:\n \n ....\n-\tCommit f86a374 (\"pack-bitmap.c: fix a memleak\", 2015-03-30)\n+\tCommit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)\n \tnoticed that ...\n ....\n \n The \"Copy commit summary\" command of gitk can be used to obtain this\n-format, or this invocation of `git show`:\n+format (with the subject enclosed in a pair of double-quotes), or this\n+invocation of `git show`:\n \n ....\n-\tgit show -s --date=short --pretty='format:%h (\"%s\", %ad)' <commit>\n+\tgit show -s --date=short --pretty='format:%h (%s, %ad)' <commit>\n ....\n \n [[git-tools]]\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386205","messageId":"442394eca88e6e355f435135ddc9a1349d121250.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 04/10] completion: complete `tformat:` pretty format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:14Z","receivedAt":"2019-11-14T20:47:19Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Signed-off-by: Denton Liu <liu.denton@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 00fbe6c03d..557d0373c3 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1749,7 +1749,7 @@ __git_log_shortlog_options=\"\n \t--all-match --invert-grep\n \"\n \n-__git_log_pretty_formats=\"oneline short medium full fuller email raw format: mboxrd\"\n+__git_log_pretty_formats=\"oneline short medium full fuller email raw format: tformat: mboxrd\"\n __git_log_date_formats=\"relative iso8601 iso8601-strict rfc2822 short local default raw unix format:\"\n \n _git_log ()\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386206","messageId":"ca01bfa0858a225d8181da9502aac33bf6ee7b5a.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 05/10] revision: make get_revision_mark() return const pointer","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:16Z","receivedAt":"2019-11-14T20:47:21Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"get_revision_mark() used to return a `char *`, even though all of the\nstrings it was returning were string literals. Make get_revision_mark()\nreturn a `const char *` so that callers won't be tempted to modify the\nreturned string.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n revision.c | 4 ++--\n revision.h | 4 ++--\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 0e39b2b8a5..2151b119b7 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -3944,7 +3944,7 @@ struct commit *get_revision(struct rev_info *revs)\n \treturn c;\n }\n \n-char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n+const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n \tif (commit->object.flags & BOUNDARY)\n \t\treturn \"-\";\n@@ -3966,7 +3966,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit\n \n void put_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n-\tchar *mark = get_revision_mark(revs, commit);\n+\tconst char *mark = get_revision_mark(revs, commit);\n \tif (!strlen(mark))\n \t\treturn;\n \tfputs(mark, stdout);\ndiff --git a/revision.h b/revision.h\nindex 4134dc6029..addd69410b 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,\n void reset_revision_walk(void);\n int prepare_revision_walk(struct rev_info *revs);\n struct commit *get_revision(struct rev_info *revs);\n-char *get_revision_mark(const struct rev_info *revs,\n-\t\t\tconst struct commit *commit);\n+const char *get_revision_mark(const struct rev_info *revs,\n+\t\t\t      const struct commit *commit);\n void put_revision_mark(const struct rev_info *revs,\n \t\t       const struct commit *commit);\n \n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386207","messageId":"301e3adcdcf77b993bd3cbe934a2336536d1d580.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 06/10] pretty.c: inline initalize format_context","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:19Z","receivedAt":"2019-11-14T20:47:24Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Instead of memsetting and then initializing the fields in the struct,\nmove the initialization of `format_context` to its assignment.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n pretty.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 93eb6e8370..4d633f14fa 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1617,14 +1617,14 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\tconst char *format, struct strbuf *sb,\n \t\t\t\tconst struct pretty_print_context *pretty_ctx)\n {\n-\tstruct format_commit_context context;\n+\tstruct format_commit_context context = {\n+\t\t.commit = commit,\n+\t\t.pretty_ctx = pretty_ctx,\n+\t\t.wrap_start = sb->len\n+\t};\n \tconst char *output_enc = pretty_ctx->output_encoding;\n \tconst char *utf8 = \"UTF-8\";\n \n-\tmemset(&context, 0, sizeof(context));\n-\tcontext.commit = commit;\n-\tcontext.pretty_ctx = pretty_ctx;\n-\tcontext.wrap_start = sb->len;\n \t/*\n \t * convert a commit message to UTF-8 first\n \t * as far as 'format_commit_item' assumes it in UTF-8\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386208","messageId":"b1256c52bae1f6658ddaec90150abfdcc87ce9c3.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 07/10] t4205: cover `git log --reflog -z` blindspot","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:21Z","receivedAt":"2019-11-14T20:47:27Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"The test suite does not include any tests where `--reflog` and `-z` are\nused together in `git log`. Cover this blindspot. Note that the\n`--pretty=oneline` case is written separately because it follows a\nslightly different codepath.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n t/t4205-log-pretty-formats.sh | 30 ++++++++++++++++++++++++++++++\n 1 file changed, 30 insertions(+)\n\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex f42a69faa2..0335b428b1 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -134,6 +134,36 @@ test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' '\n \ttest_cmp expected actual\n '\n \n+for p in short medium full fuller email raw\n+do\n+\ttest_expect_success \"NUL termination with --reflog --pretty=$p\" '\n+\t\trevs=\"$(git rev-list --reflog)\" &&\n+\t\tfor r in $revs\n+\t\tdo\n+\t\t\tgit show -s \"$r\" --pretty=\"$p\" &&\n+\t\t\tprintf \"\\0\" || return 1\n+\t\tdone >expect &&\n+\t\t{\n+\t\t\tgit log -z --reflog --pretty=\"$p\" &&\n+\t\t\tprintf \"\\0\"\n+\t\t} >actual &&\n+\t\ttest_cmp expect actual\n+\t'\n+done\n+\n+test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n+\trevs=\"$(git rev-list --reflog)\" &&\n+\tfor r in $revs\n+\tdo\n+\t\tgit show -s --pretty=oneline \"$r\" >raw &&\n+\t\tcat raw | lf_to_nul || exit 1\n+\tdone >expect &&\n+\t# the trailing NUL is already produced so we do not need to\n+\t# output another one\n+\tgit log -z --pretty=oneline --reflog >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'setup more commits' '\n \ttest_commit \"message one\" one one message-one &&\n \ttest_commit \"message two\" two two message-two &&\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386209","messageId":"fe5cb165ae9550673bcc61057672381c4f524e46.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 08/10] pretty: provide short date format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:23Z","receivedAt":"2019-11-14T20:47:28Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"From: René Scharfe <l.s.r@web.de>\n\nAdd the placeholders %as and %cs to format author date and committer\ndate, respectively, without the time part, like --date=short does, i.e.\nlike YYYY-MM-DD.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt | 2 ++\n pretty.c                         | 3 +++\n t/t4205-log-pretty-formats.sh    | 6 ++++++\n 3 files changed, 11 insertions(+)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 4cefa64eeb..11979301ff 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -172,6 +172,7 @@ The placeholders are:\n '%at':: author date, UNIX timestamp\n '%ai':: author date, ISO 8601-like format\n '%aI':: author date, strict ISO 8601 format\n+'%as':: author date, short format (`YYYY-MM-DD`)\n '%cn':: committer name\n '%cN':: committer name (respecting .mailmap, see\n \tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n@@ -187,6 +188,7 @@ The placeholders are:\n '%ct':: committer date, UNIX timestamp\n '%ci':: committer date, ISO 8601-like format\n '%cI':: committer date, strict ISO 8601 format\n+'%cs':: committer date, short format (`YYYY-MM-DD`)\n '%d':: ref names, like the --decorate option of linkgit:git-log[1]\n '%D':: ref names without the \" (\", \")\" wrapping.\n '%S':: ref name given on the command line by which the commit was reached\ndiff --git a/pretty.c b/pretty.c\nindex 4d633f14fa..4d7f5e9aab 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -738,6 +738,9 @@ static size_t format_person_part(struct strbuf *sb, char part,\n \tcase 'I':\t/* date, ISO 8601 strict */\n \t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(ISO8601_STRICT)));\n \t\treturn placeholder_len;\n+\tcase 's':\n+\t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(SHORT)));\n+\t\treturn placeholder_len;\n \t}\n \n skip:\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex 0335b428b1..da9cacffea 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -533,6 +533,12 @@ test_expect_success 'ISO and ISO-strict date formats display the same values' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'short date' '\n+\tgit log --format=%ad%n%cd --date=short >expected &&\n+\tgit log --format=%as%n%cs >actual &&\n+\ttest_cmp expected actual\n+'\n+\n # get new digests (with no abbreviations)\n test_expect_success 'set up log decoration tests' '\n \thead1=$(git rev-parse --verify HEAD~0) &&\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386210","messageId":"5f80e4633dcd37e6559e079d7bd679bc398da3e2.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 10/10] SubmittingPatches: use `--pretty=reference`","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:28Z","receivedAt":"2019-11-14T20:47:31Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git was taught the `--pretty=reference` option, it is no longer\nnecessary to manually specify the format string to get the commit\nreference. Teach users to use the new option while keeping the old\ninvocation around in case they have an older version of Git.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex 7860dd2568..4515cab519 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -153,6 +153,12 @@ The \"Copy commit summary\" command of gitk can be used to obtain this\n format (with the subject enclosed in a pair of double-quotes), or this\n invocation of `git show`:\n \n+....\n+\tgit show -s --pretty=reference <commit>\n+....\n+\n+or, on an older version of Git without support for --pretty=reference:\n+\n ....\n \tgit show -s --date=short --pretty='format:%h (%s, %ad)' <commit>\n ....\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386211","messageId":"470a2b0f4fd450af1d9c9d27ec0f0c91ea59117f.1573764280.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v3 09/10] pretty: implement 'reference' format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-14T20:47:26Z","receivedAt":"2019-11-14T20:47:32Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"The standard format for referencing other commits within some projects\n(such as git.git) is the reference format. This is described in\nDocumentation/SubmittingPatches as\n\n\tIf you want to reference a previous commit in the history of a stable\n\tbranch, use the format \"abbreviated hash (subject, date)\", like this:\n\n\t....\n\t\tCommit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)\n\t\tnoticed that ...\n\t....\n\nSince this format is so commonly used, standardize it as a pretty\nformat.\n\nThe tests that are implemented essentially show that the format-string\ndoes not change in response to various log options. This is useful\nbecause, for future developers, it shows that we've considered the\nlimitations of the \"canned format-string\" approach and we are fine with\nthem.\n\nBased-on-a-patch-by: SZEDER Gábor <szeder.dev@gmail.com>\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt       | 10 +++++++\n Documentation/pretty-options.txt       |  2 +-\n Documentation/rev-list-options.txt     |  4 ++-\n contrib/completion/git-completion.bash |  2 +-\n pretty.c                               |  4 ++-\n t/t4205-log-pretty-formats.sh          | 36 ++++++++++++++++++++++++++\n 6 files changed, 54 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 11979301ff..ee1a945bae 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -63,6 +63,16 @@ This is designed to be as compact as possible.\n \n \t       <full commit message>\n \n+* 'reference'\n+\n+\t  <abbrev hash> (<title line>, <short author date>)\n++\n+This format is useful for referring to other commits when writing a new\n+commit message. It uses the following canned user format:\n+`%C(auto)%h (%s, %as)`. This means it will not respect options that\n+change the output format such as `--date` `--no-abbrev-commit`, and\n+`--walk-reflogs`.\n+\n * 'email'\n \n \t  From <hash> <date>\ndiff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\nindex e44fc8f738..a59426eefd 100644\n--- a/Documentation/pretty-options.txt\n+++ b/Documentation/pretty-options.txt\n@@ -3,7 +3,7 @@\n \n \tPretty-print the contents of the commit logs in a given format,\n \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n-\t'full', 'fuller', 'email', 'raw', 'format:<string>'\n+\t'full', 'fuller', 'reference', 'email', 'raw', 'format:<string>'\n \tand 'tformat:<string>'.  When '<format>' is none of the above,\n \tand has '%placeholder' in it, it acts as if\n \t'--pretty=tformat:<format>' were given.\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex 90ff9e2bea..91edeaf6d5 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -269,7 +269,7 @@ list.\n \texclude (that is, '{caret}commit', 'commit1..commit2',\n \tand 'commit1\\...commit2' notations cannot be used).\n +\n-With `--pretty` format other than `oneline` (for obvious reasons),\n+With `--pretty` format other than `oneline` and `reference` (for obvious reasons),\n this causes the output to have two extra lines of information\n taken from the reflog.  The reflog designator in the output may be shown\n as `ref@{Nth}` (where `Nth` is the reverse-chronological index in the\n@@ -293,6 +293,8 @@ Under `--pretty=oneline`, the commit message is\n prefixed with this information on the same line.\n This option cannot be combined with `--reverse`.\n See also linkgit:git-reflog[1].\n++\n+Under `--pretty=summary`, this information will not be shown at all.\n \n --merge::\n \tAfter a failed merge, show refs that touch files having a\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 557d0373c3..007e6a06d6 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1749,7 +1749,7 @@ __git_log_shortlog_options=\"\n \t--all-match --invert-grep\n \"\n \n-__git_log_pretty_formats=\"oneline short medium full fuller email raw format: tformat: mboxrd\"\n+__git_log_pretty_formats=\"oneline short medium full fuller reference email raw format: tformat: mboxrd\"\n __git_log_date_formats=\"relative iso8601 iso8601-strict rfc2822 short local default raw unix format:\"\n \n _git_log ()\ndiff --git a/pretty.c b/pretty.c\nindex 4d7f5e9aab..88a3bc621d 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -97,7 +97,9 @@ static void setup_commit_formats(void)\n \t\t{ \"mboxrd\",\tCMIT_FMT_MBOXRD,\t0,\t0 },\n \t\t{ \"fuller\",\tCMIT_FMT_FULLER,\t0,\t8 },\n \t\t{ \"full\",\tCMIT_FMT_FULL,\t\t0,\t8 },\n-\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 }\n+\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 },\n+\t\t{ \"reference\",\tCMIT_FMT_USERFORMAT,\t1,\t0,\n+\t\t\t0, \"%C(auto)%h (%s, %as)\" },\n \t\t/*\n \t\t * Please update $__git_log_pretty_formats in\n \t\t * git-completion.bash when you add new formats.\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex da9cacffea..9a9a18f104 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -824,4 +824,40 @@ test_expect_success '%S in git log --format works with other placeholders (part\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'log --pretty=reference' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference always uses short date' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --date=rfc --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference is never unabbreviated' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --no-abbrev-commit --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference is never decorated' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --decorate=short --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference does not output reflog info' '\n+\tgit log --walk-reflogs --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --walk-reflogs --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference is colored appropriately' '\n+\tgit log --color=always --pretty=\"tformat:%C(auto)%h (%s, %as)\" >expect &&\n+\tgit log --color=always --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.24.0.346.gee0de6d492\n\n"},{"id":"386245","messageId":"20191115033325.GC3898@pobox.com","threadId":"52187","inReplyTo":"470a2b0f4fd450af1d9c9d27ec0f0c91ea59117f.1573764280.git.liu.denton@gmail.com","subject":"Re: [PATCH v3 09/10] pretty: implement 'reference' format","fromName":"Todd Zullinger","fromEmail":"tmz@pobox.com","sentAt":"2019-11-15T03:33:25Z","receivedAt":"2019-11-15T03:33:35Z","isPatch":true,"sender":{"key":"tmz@pobox.com","avatar":"https://avatars.githubusercontent.com/u/806319?v=4"},"body":"Denton Liu wrote:\n> index 90ff9e2bea..91edeaf6d5 100644\n> --- a/Documentation/rev-list-options.txt\n> +++ b/Documentation/rev-list-options.txt\n> @@ -269,7 +269,7 @@ list.\n>  \texclude (that is, '{caret}commit', 'commit1..commit2',\n>  \tand 'commit1\\...commit2' notations cannot be used).\n>  +\n> -With `--pretty` format other than `oneline` (for obvious reasons),\n> +With `--pretty` format other than `oneline` and `reference` (for obvious reasons),\n>  this causes the output to have two extra lines of information\n>  taken from the reflog.  The reflog designator in the output may be shown\n>  as `ref@{Nth}` (where `Nth` is the reverse-chronological index in the\n> @@ -293,6 +293,8 @@ Under `--pretty=oneline`, the commit message is\n>  prefixed with this information on the same line.\n>  This option cannot be combined with `--reverse`.\n>  See also linkgit:git-reflog[1].\n> ++\n> +Under `--pretty=summary`, this information will not be shown at all.\n\nI think the line above wants s/summary/reference.\n\n-- \nTodd\n"},{"id":"386260","messageId":"xmqqbltd7juo.fsf@gitster-ct.c.googlers.com","threadId":"52187","inReplyTo":"470a2b0f4fd450af1d9c9d27ec0f0c91ea59117f.1573764280.git.liu.denton@gmail.com","subject":"Re: [PATCH v3 09/10] pretty: implement 'reference' format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-15T06:07:59Z","receivedAt":"2019-11-15T06:08:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denton Liu <liu.denton@gmail.com> writes:\n\n> +* 'reference'\n> +\n> +\t  <abbrev hash> (<title line>, <short author date>)\n\ns/title line/title/ as you definitely do *not* want a line with a\ntitle on it (and nothing else) in this context.\n\n> +This format is useful for referring to other commits when writing a new\n> +commit message. It uses the following canned user format:\n> +`%C(auto)%h (%s, %as)`. This means it will not respect options that\n> +change the output format such as `--date` `--no-abbrev-commit`, and\n> +`--walk-reflogs`.\n\nIgnoring of the '--date' may want to be eventually fixed, but for an\ninitial cut, using %as in the canned format is a good approach for\nexpediency.\n\nI thought that %h can be told to give arbitrary long hash with\n--abbrev=<n>, up to n==40 (or the number of bytes the hash of your\nchoice has), so I am not sure if `--no-abbrev-commit` is worth\nmentioning.  I do not think I understand what you wanted to do by\nusing `--walk-reflogs` with the format at all, either.\n\nThanks.\n\n"},{"id":"386261","messageId":"CAPig+cR1Fbk0esmTRiTS8Zn-PAVPtEJ5HmaaDkT-EZA5f=KOfg@mail.gmail.com","threadId":"52187","inReplyTo":"470a2b0f4fd450af1d9c9d27ec0f0c91ea59117f.1573764280.git.liu.denton@gmail.com","subject":"Re: [PATCH v3 09/10] pretty: implement 'reference' format","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-11-15T08:07:07Z","receivedAt":"2019-11-15T08:07:22Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Nov 14, 2019 at 3:47 PM Denton Liu <liu.denton@gmail.com> wrote:\n> [...]\n> Since this format is so commonly used, standardize it as a pretty\n> format.\n> [...]\n> Signed-off-by: Denton Liu <liu.denton@gmail.com>\n> ---\n> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\n> @@ -63,6 +63,16 @@ This is designed to be as compact as possible.\n> +This format is useful for referring to other commits when writing a new\n> +commit message. It uses the following canned user format:\n> +`%C(auto)%h (%s, %as)`. This means it will not respect options that\n> +change the output format such as `--date` `--no-abbrev-commit`, and\n> +`--walk-reflogs`.\n\nMissing comma between `--date` and `--no-abbrev-commit`.\n"},{"id":"386314","messageId":"20191115131803.GU4348@szeder.dev","threadId":"52187","inReplyTo":"xmqqbltd7juo.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 09/10] pretty: implement 'reference' format","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-11-15T13:18:03Z","receivedAt":"2019-11-15T13:18:10Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Nov 15, 2019 at 03:07:59PM +0900, Junio C Hamano wrote:\n> Denton Liu <liu.denton@gmail.com> writes:\n> \n> > +* 'reference'\n> > +\n> > +\t  <abbrev hash> (<title line>, <short author date>)\n> \n> s/title line/title/ as you definitely do *not* want a line with a\n> title on it (and nothing else) in this context.\n\nWell, we just followed suit of the descriptions of other pretty\nformats, and they all say \"<title line>\".\n\nOn a related note, the description of the '%s' format specifier in the\nsame document is \"subject\", not \"title\".  Perhaps they should be made\nconsistent, but I'm not sure.  I like that '%s' means \"subject\",\nbecause the first letter matches, but some man pages (commit,\nformat-patch, am) make difference between a subject and a title.\n\n"},{"id":"386353","messageId":"xmqqr228619w.fsf@gitster-ct.c.googlers.com","threadId":"52187","inReplyTo":"20191115131803.GU4348@szeder.dev","subject":"Re: [PATCH v3 09/10] pretty: implement 'reference' format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-16T01:46:51Z","receivedAt":"2019-11-16T01:46:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder.dev@gmail.com> writes:\n\n> On Fri, Nov 15, 2019 at 03:07:59PM +0900, Junio C Hamano wrote:\n>> Denton Liu <liu.denton@gmail.com> writes:\n>> \n>> > +* 'reference'\n>> > +\n>> > +\t  <abbrev hash> (<title line>, <short author date>)\n>> \n>> s/title line/title/ as you definitely do *not* want a line with a\n>> title on it (and nothing else) in this context.\n>\n> Well, we just followed suit of the descriptions of other pretty\n> formats, and they all say \"<title line>\".\n>\n> On a related note, the description of the '%s' format specifier in the\n> same document is \"subject\", not \"title\".  Perhaps they should be made\n> consistent, but I'm not sure.  I like that '%s' means \"subject\",\n> because the first letter matches, but some man pages (commit,\n> format-patch, am) make difference between a subject and a title.\n\nYeah, I think these are used more or less interchangeably, and we\nmay want to clarify the distinction.  Between the two, <title> is a\nmore appropriate \"context neutral\" name for the thing, i.e. one line\n(technically, one paragraph) summary of what the commit is about.\nWhere <subject> becomes more relevant is when a commit is expressed\nas a piece of patch e-mail, where <title> is used on the \"Subject: \"\nheader.\n\nThanks.\n"},{"id":"386427","messageId":"xmqqa78u3qot.fsf@gitster-ct.c.googlers.com","threadId":"52187","inReplyTo":"xmqqbltd7juo.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 09/10] pretty: implement 'reference' format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-18T01:42:58Z","receivedAt":"2019-11-18T01:43:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Denton Liu <liu.denton@gmail.com> writes:\n>\n>> +* 'reference'\n>> +\n>> +\t  <abbrev hash> (<title line>, <short author date>)\n>\n> s/title line/title/ as you definitely do *not* want a line with a\n> title on it (and nothing else) in this context.\n>\n>> +This format is useful for referring to other commits when writing a new\n>> +commit message. It uses the following canned user format:\n>> +`%C(auto)%h (%s, %as)`. This means it will not respect options that\n>> +change the output format such as `--date` `--no-abbrev-commit`, and\n>> +`--walk-reflogs`.\n>\n> Ignoring of the '--date' may want to be eventually fixed, but for an\n> initial cut, using %as in the canned format is a good approach for\n> expediency.\n> ...\n> ...  I do not think I understand what you wanted to do by\n> using `--walk-reflogs` with the format at all, either.\n\nOK, I re-read the patch text and I understand what you wanted to\nsay.  The mention of --walk-reflogs in the new description is\ngrossly misleading.\n\n   $ git log --pretty=ref --walk-reflogs @{now}\n\nwould work perfectly fine.  It is an instruction that tells \"git\nlog\" not to follow the commit ancestry from the commit that sits at\nthe current branch right now, but instead follow the history of what\ncommits used to sit at the tip of the current branch.\n\n\"--pretty=format:<anything>\" overrides only the side effect of\n\"--walk-reflogs\" that modifies traditional built-in formats.  But\nthe above makes it sound as if use of \"--pretty=ref\" somehow makes\nour commands to ignore the entire effect of any option that has side\neffect of changing the output format, which is not true.\n\nThe `--date` and `--decorate` options would be a good example of\noptions \"that change the output format\".  If you want to mention the\neffect of this option on the `--walk-reflogs` option correctly, the\nexplanation must make sure that only the output aspect is affected.\n\nPerhaps like this\n\n\tThis format is used to refer another commit in a commit\n\tmessage as \"<short hash> (<title>, <author date>)\" and is\n\tthe same as `--pretty=format:%C(auto)%h (%s, %as)`.  As with\n\tany `format:` with format placeholders, its output is not\n\taffected by other options like `--decorate` and\n\t`--walk-reflogs`.\n\nI guess?\n\nWe would want to fix it in such a way that it uses %ad instead of\n%as, but internally tweak the default date format to short unless\nthe --date option is given.\n\nThanks.\n"},{"id":"386428","messageId":"xmqq5zji3qm0.fsf@gitster-ct.c.googlers.com","threadId":"52187","inReplyTo":"xmqqr228619w.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 09/10] pretty: implement 'reference' format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-18T01:44:39Z","receivedAt":"2019-11-18T01:44:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> SZEDER Gábor <szeder.dev@gmail.com> writes:\n>\n>> On Fri, Nov 15, 2019 at 03:07:59PM +0900, Junio C Hamano wrote:\n>>> Denton Liu <liu.denton@gmail.com> writes:\n>>> \n>>> > +* 'reference'\n>>> > +\n>>> > +\t  <abbrev hash> (<title line>, <short author date>)\n>>> \n>>> s/title line/title/ as you definitely do *not* want a line with a\n>>> title on it (and nothing else) in this context.\n>>\n>> Well, we just followed suit of the descriptions of other pretty\n>> formats, and they all say \"<title line>\".\n\nSorry I failed to respond to this point.  I think it is OK to leave\nit <title line> in this series, then.  Updating them need to be done\nfor all at once together with other formats.\n\nThanks.\n"},{"id":"386476","messageId":"cover.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1573764280.git.liu.denton@gmail.com","subject":"[PATCH v4 00/11] learn the \"reference\" pretty format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:06Z","receivedAt":"2019-11-19T00:21:12Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"On this mailing list (and many others) the standard way to reference\nother commits with the \"reference\" format, e.g. \"f86a374 (pack-bitmap.c:\nfix a memleak, 2015-03-30)\". Since it's so commonly used, let's\nstandardise it as a pretty format.\n\nPatches 5-7 were cleanup patches that were critical in earlier\niterations of the series but no longer are critical for the rest of the\npatchset. Nonetheless, let's include them since they improve the quality\nof the codebase.\n\nChanges since v3:\n\n* Change one reference from \"summary\" to \"reference\"\n\n* Clarify --pretty=reference documentation\n\n* Add a squashable patch at the end to implement overridable --date\n\nChanges since v2:\n\n* Rename from \"summary\" to \"reference\"\n\n* Implement the feature as a canned userformat\n\n* Implement the %*s (short date) format string element\n\n* Remove the enclosing dqs around the subject\n\nChanges since v1:\n\n* Replace more references to \"sha1\" with \"hash\"\n\n* Clean up 8/10 by losing the allocation and making the subject less\n  misleading\n\n* Add tests in 7/10 to ensure 8/10 does not change any behaviour\n\nDenton Liu (10):\n  SubmittingPatches: use generic terms for hash\n  pretty-formats.txt: use generic terms for hash\n  SubmittingPatches: remove dq from commit reference\n  completion: complete `tformat:` pretty format\n  revision: make get_revision_mark() return const pointer\n  pretty.c: inline initalize format_context\n  t4205: cover `git log --reflog -z` blindspot\n  pretty: implement 'reference' format\n  SubmittingPatches: use `--pretty=reference`\n  squash! pretty: implement 'reference' format\n\nRené Scharfe (1):\n  pretty: provide short date format\n\n Documentation/SubmittingPatches        | 16 ++++--\n Documentation/pretty-formats.txt       | 29 +++++++---\n Documentation/pretty-options.txt       |  2 +-\n Documentation/rev-list-options.txt     |  4 +-\n contrib/completion/git-completion.bash |  2 +-\n pretty.c                               | 23 ++++++--\n revision.c                             |  4 +-\n revision.h                             |  4 +-\n t/t4205-log-pretty-formats.sh          | 79 ++++++++++++++++++++++++++\n 9 files changed, 137 insertions(+), 26 deletions(-)\n\nRange-diff against v3:\n 1:  d0f0b86f5f =  1:  3b9b72feec SubmittingPatches: use generic terms for hash\n 2:  aabd7574d2 =  2:  2cc7cc6e75 pretty-formats.txt: use generic terms for hash\n 3:  ef0adc260d =  3:  61e1a25f93 SubmittingPatches: remove dq from commit reference\n 4:  d7e4dc9154 =  4:  5d9fd9d632 completion: complete `tformat:` pretty format\n 5:  cc219ec513 =  5:  bfb216954b revision: make get_revision_mark() return const pointer\n 6:  883517ee65 =  6:  34e1b6a7ac pretty.c: inline initalize format_context\n 7:  b35b287635 =  7:  78e4d75d2b t4205: cover `git log --reflog -z` blindspot\n 8:  b0ac175d6f =  8:  9d4dfcc115 pretty: provide short date format\n 9:  a4b87ad271 !  9:  5042161d73 pretty: implement 'reference' format\n    @@ Documentation/pretty-formats.txt: This is designed to be as compact as possible.\n     +\n     +\t  <abbrev hash> (<title line>, <short author date>)\n     ++\n    -+This format is useful for referring to other commits when writing a new\n    -+commit message. It uses the following canned user format:\n    -+`%C(auto)%h (%s, %as)`. This means it will not respect options that\n    -+change the output format such as `--date` `--no-abbrev-commit`, and\n    -+`--walk-reflogs`.\n    ++This format is used to refer to another commit in a commit message and\n    ++is the same as `--pretty='format:%C(auto)%h (%s, %as)'`.  As with any\n    ++`format:` with format placeholders, its output is not affected by other\n    ++options like `--decorate` and `--walk-reflogs`.\n     +\n      * 'email'\n      \n    @@ Documentation/rev-list-options.txt: Under `--pretty=oneline`, the commit message\n      This option cannot be combined with `--reverse`.\n      See also linkgit:git-reflog[1].\n     ++\n    -+Under `--pretty=summary`, this information will not be shown at all.\n    ++Under `--pretty=reference`, this information will not be shown at all.\n      \n      --merge::\n      \tAfter a failed merge, show refs that touch files having a\n10:  04d24cbf4b = 10:  888c496991 SubmittingPatches: use `--pretty=reference`\n -:  ---------- > 11:  580aa7c88c squash! pretty: implement 'reference' format\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386477","messageId":"3b9b72feec82ecce2bd279219957c22393e18408.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 01/11] SubmittingPatches: use generic terms for hash","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:09Z","receivedAt":"2019-11-19T00:21:14Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git is planning on upgrading from SHA-1 to be more hash-agnostic,\nreplace specific references to SHA-1 with more generic terminology.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex 1a60cc1329..bb7e33ce15 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -142,7 +142,7 @@ archive, summarize the relevant points of the discussion.\n \n [[commit-reference]]\n If you want to reference a previous commit in the history of a stable\n-branch, use the format \"abbreviated sha1 (subject, date)\",\n+branch, use the format \"abbreviated hash (subject, date)\",\n with the subject enclosed in a pair of double-quotes, like this:\n \n ....\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386478","messageId":"2cc7cc6e75cfaa4dc62f95027bc1192b973a5c69.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 02/11] pretty-formats.txt: use generic terms for hash","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:12Z","receivedAt":"2019-11-19T00:21:17Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git is planning on upgrading from SHA-1 to be more hash-agnostic,\nreplace specific references to SHA-1 with more generic terminology.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 31c6e8d2b8..4cefa64eeb 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -4,7 +4,7 @@ PRETTY FORMATS\n If the commit is a merge, and if the pretty-format\n is not 'oneline', 'email' or 'raw', an additional line is\n inserted before the 'Author:' line.  This line begins with\n-\"Merge: \" and the sha1s of ancestral commits are printed,\n+\"Merge: \" and the hashes of ancestral commits are printed,\n separated by spaces.  Note that the listed commits may not\n necessarily be the list of the *direct* parent commits if you\n have limited your view of history: for example, if you are\n@@ -20,20 +20,20 @@ built-in formats:\n \n * 'oneline'\n \n-\t  <sha1> <title line>\n+\t  <hash> <title line>\n +\n This is designed to be as compact as possible.\n \n * 'short'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \n \t      <title line>\n \n * 'medium'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Date:   <author date>\n \n@@ -43,7 +43,7 @@ This is designed to be as compact as possible.\n \n * 'full'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Commit: <committer>\n \n@@ -53,7 +53,7 @@ This is designed to be as compact as possible.\n \n * 'fuller'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author:     <author>\n \t  AuthorDate: <author date>\n \t  Commit:     <committer>\n@@ -65,7 +65,7 @@ This is designed to be as compact as possible.\n \n * 'email'\n \n-\t  From <sha1> <date>\n+\t  From <hash> <date>\n \t  From: <author>\n \t  Date: <author date>\n \t  Subject: [PATCH] <title line>\n@@ -75,7 +75,7 @@ This is designed to be as compact as possible.\n * 'raw'\n +\n The 'raw' format shows the entire commit exactly as\n-stored in the commit object.  Notably, the SHA-1s are\n+stored in the commit object.  Notably, the hashes are\n displayed in full, regardless of whether --abbrev or\n --no-abbrev are used, and 'parents' information show the\n true parent commits, without taking grafts or history\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386479","messageId":"61e1a25f93577ca755f0f8b4de6ce9ea00a7ab31.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 03/11] SubmittingPatches: remove dq from commit reference","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:15Z","receivedAt":"2019-11-19T00:21:19Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Quoting SZEDER Gábor[1],\n\n\tSubmittingPatches is simply wrong: our de-facto standard format for\n\treferencing other commits does not enclose the subject in a pair of\n\tdouble-quotes:\n\n\t  $ git log v2.24.0 |grep -E '[0-9a-f]{7} \\(\"' |wc -l\n\t  785\n\t  $ git log v2.24.0 |grep -E '[0-9a-f]{7} \\([^\"]' |wc -l\n\t  2276\n\n\tThose double-quotes don't add any value to the references, but they\n\tresult in weird looking references for 1083 of our commits whose\n\tsubject lines happen to end with double-quotes, e.g.:\n\n\t  f23a465132 (\"hashmap_get{,_from_hash} return \"struct hashmap_entry *\"\", 2019-10-06)\n\n\tand without those unnecessary pair of double-quotes we would have\n\t~3000 more commits whose summary would fit on a single line.\n\nRemove references to the enclosing double-quotes from SubmittingPatches\nsince our de-facto standard for referencing commits does not actually\nuse them.\n\n[1]: cf. <20191114011048.GS4348@szeder.dev>\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex bb7e33ce15..7860dd2568 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -142,19 +142,19 @@ archive, summarize the relevant points of the discussion.\n \n [[commit-reference]]\n If you want to reference a previous commit in the history of a stable\n-branch, use the format \"abbreviated hash (subject, date)\",\n-with the subject enclosed in a pair of double-quotes, like this:\n+branch, use the format \"abbreviated hash (subject, date)\", like this:\n \n ....\n-\tCommit f86a374 (\"pack-bitmap.c: fix a memleak\", 2015-03-30)\n+\tCommit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)\n \tnoticed that ...\n ....\n \n The \"Copy commit summary\" command of gitk can be used to obtain this\n-format, or this invocation of `git show`:\n+format (with the subject enclosed in a pair of double-quotes), or this\n+invocation of `git show`:\n \n ....\n-\tgit show -s --date=short --pretty='format:%h (\"%s\", %ad)' <commit>\n+\tgit show -s --date=short --pretty='format:%h (%s, %ad)' <commit>\n ....\n \n [[git-tools]]\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386480","messageId":"5d9fd9d632f03afdf612d03763225f07fdf9316d.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 04/11] completion: complete `tformat:` pretty format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:17Z","receivedAt":"2019-11-19T00:21:21Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Signed-off-by: Denton Liu <liu.denton@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 00fbe6c03d..557d0373c3 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1749,7 +1749,7 @@ __git_log_shortlog_options=\"\n \t--all-match --invert-grep\n \"\n \n-__git_log_pretty_formats=\"oneline short medium full fuller email raw format: mboxrd\"\n+__git_log_pretty_formats=\"oneline short medium full fuller email raw format: tformat: mboxrd\"\n __git_log_date_formats=\"relative iso8601 iso8601-strict rfc2822 short local default raw unix format:\"\n \n _git_log ()\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386481","messageId":"bfb216954bebea92aa5363a07bfad0f70fed102b.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 05/11] revision: make get_revision_mark() return const pointer","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:19Z","receivedAt":"2019-11-19T00:21:24Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"get_revision_mark() used to return a `char *`, even though all of the\nstrings it was returning were string literals. Make get_revision_mark()\nreturn a `const char *` so that callers won't be tempted to modify the\nreturned string.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n revision.c | 4 ++--\n revision.h | 4 ++--\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 0e39b2b8a5..2151b119b7 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -3944,7 +3944,7 @@ struct commit *get_revision(struct rev_info *revs)\n \treturn c;\n }\n \n-char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n+const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n \tif (commit->object.flags & BOUNDARY)\n \t\treturn \"-\";\n@@ -3966,7 +3966,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit\n \n void put_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n-\tchar *mark = get_revision_mark(revs, commit);\n+\tconst char *mark = get_revision_mark(revs, commit);\n \tif (!strlen(mark))\n \t\treturn;\n \tfputs(mark, stdout);\ndiff --git a/revision.h b/revision.h\nindex 4134dc6029..addd69410b 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,\n void reset_revision_walk(void);\n int prepare_revision_walk(struct rev_info *revs);\n struct commit *get_revision(struct rev_info *revs);\n-char *get_revision_mark(const struct rev_info *revs,\n-\t\t\tconst struct commit *commit);\n+const char *get_revision_mark(const struct rev_info *revs,\n+\t\t\t      const struct commit *commit);\n void put_revision_mark(const struct rev_info *revs,\n \t\t       const struct commit *commit);\n \n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386482","messageId":"34e1b6a7ac8e1f6f678bee35e9356dead5f45e0b.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 06/11] pretty.c: inline initalize format_context","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:22Z","receivedAt":"2019-11-19T00:21:27Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Instead of memsetting and then initializing the fields in the struct,\nmove the initialization of `format_context` to its assignment.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n pretty.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 93eb6e8370..4d633f14fa 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1617,14 +1617,14 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\tconst char *format, struct strbuf *sb,\n \t\t\t\tconst struct pretty_print_context *pretty_ctx)\n {\n-\tstruct format_commit_context context;\n+\tstruct format_commit_context context = {\n+\t\t.commit = commit,\n+\t\t.pretty_ctx = pretty_ctx,\n+\t\t.wrap_start = sb->len\n+\t};\n \tconst char *output_enc = pretty_ctx->output_encoding;\n \tconst char *utf8 = \"UTF-8\";\n \n-\tmemset(&context, 0, sizeof(context));\n-\tcontext.commit = commit;\n-\tcontext.pretty_ctx = pretty_ctx;\n-\tcontext.wrap_start = sb->len;\n \t/*\n \t * convert a commit message to UTF-8 first\n \t * as far as 'format_commit_item' assumes it in UTF-8\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386483","messageId":"78e4d75d2b1c22c7340f3794c88ab7b294402d5b.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 07/11] t4205: cover `git log --reflog -z` blindspot","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:25Z","receivedAt":"2019-11-19T00:21:30Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"The test suite does not include any tests where `--reflog` and `-z` are\nused together in `git log`. Cover this blindspot. Note that the\n`--pretty=oneline` case is written separately because it follows a\nslightly different codepath.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n t/t4205-log-pretty-formats.sh | 30 ++++++++++++++++++++++++++++++\n 1 file changed, 30 insertions(+)\n\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex f42a69faa2..0335b428b1 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -134,6 +134,36 @@ test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' '\n \ttest_cmp expected actual\n '\n \n+for p in short medium full fuller email raw\n+do\n+\ttest_expect_success \"NUL termination with --reflog --pretty=$p\" '\n+\t\trevs=\"$(git rev-list --reflog)\" &&\n+\t\tfor r in $revs\n+\t\tdo\n+\t\t\tgit show -s \"$r\" --pretty=\"$p\" &&\n+\t\t\tprintf \"\\0\" || return 1\n+\t\tdone >expect &&\n+\t\t{\n+\t\t\tgit log -z --reflog --pretty=\"$p\" &&\n+\t\t\tprintf \"\\0\"\n+\t\t} >actual &&\n+\t\ttest_cmp expect actual\n+\t'\n+done\n+\n+test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n+\trevs=\"$(git rev-list --reflog)\" &&\n+\tfor r in $revs\n+\tdo\n+\t\tgit show -s --pretty=oneline \"$r\" >raw &&\n+\t\tcat raw | lf_to_nul || exit 1\n+\tdone >expect &&\n+\t# the trailing NUL is already produced so we do not need to\n+\t# output another one\n+\tgit log -z --pretty=oneline --reflog >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'setup more commits' '\n \ttest_commit \"message one\" one one message-one &&\n \ttest_commit \"message two\" two two message-two &&\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386484","messageId":"9d4dfcc11542a31432d19c4607eb616869e6089e.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 08/11] pretty: provide short date format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:28Z","receivedAt":"2019-11-19T00:21:33Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"From: René Scharfe <l.s.r@web.de>\n\nAdd the placeholders %as and %cs to format author date and committer\ndate, respectively, without the time part, like --date=short does, i.e.\nlike YYYY-MM-DD.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt | 2 ++\n pretty.c                         | 3 +++\n t/t4205-log-pretty-formats.sh    | 6 ++++++\n 3 files changed, 11 insertions(+)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 4cefa64eeb..11979301ff 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -172,6 +172,7 @@ The placeholders are:\n '%at':: author date, UNIX timestamp\n '%ai':: author date, ISO 8601-like format\n '%aI':: author date, strict ISO 8601 format\n+'%as':: author date, short format (`YYYY-MM-DD`)\n '%cn':: committer name\n '%cN':: committer name (respecting .mailmap, see\n \tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n@@ -187,6 +188,7 @@ The placeholders are:\n '%ct':: committer date, UNIX timestamp\n '%ci':: committer date, ISO 8601-like format\n '%cI':: committer date, strict ISO 8601 format\n+'%cs':: committer date, short format (`YYYY-MM-DD`)\n '%d':: ref names, like the --decorate option of linkgit:git-log[1]\n '%D':: ref names without the \" (\", \")\" wrapping.\n '%S':: ref name given on the command line by which the commit was reached\ndiff --git a/pretty.c b/pretty.c\nindex 4d633f14fa..4d7f5e9aab 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -738,6 +738,9 @@ static size_t format_person_part(struct strbuf *sb, char part,\n \tcase 'I':\t/* date, ISO 8601 strict */\n \t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(ISO8601_STRICT)));\n \t\treturn placeholder_len;\n+\tcase 's':\n+\t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(SHORT)));\n+\t\treturn placeholder_len;\n \t}\n \n skip:\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex 0335b428b1..da9cacffea 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -533,6 +533,12 @@ test_expect_success 'ISO and ISO-strict date formats display the same values' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'short date' '\n+\tgit log --format=%ad%n%cd --date=short >expected &&\n+\tgit log --format=%as%n%cs >actual &&\n+\ttest_cmp expected actual\n+'\n+\n # get new digests (with no abbreviations)\n test_expect_success 'set up log decoration tests' '\n \thead1=$(git rev-parse --verify HEAD~0) &&\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386485","messageId":"5042161d738215dda2966566e53a3097ed8d457f.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 09/11] pretty: implement 'reference' format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:30Z","receivedAt":"2019-11-19T00:21:35Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"The standard format for referencing other commits within some projects\n(such as git.git) is the reference format. This is described in\nDocumentation/SubmittingPatches as\n\n\tIf you want to reference a previous commit in the history of a stable\n\tbranch, use the format \"abbreviated hash (subject, date)\", like this:\n\n\t....\n\t\tCommit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)\n\t\tnoticed that ...\n\t....\n\nSince this format is so commonly used, standardize it as a pretty\nformat.\n\nThe tests that are implemented essentially show that the format-string\ndoes not change in response to various log options. This is useful\nbecause, for future developers, it shows that we've considered the\nlimitations of the \"canned format-string\" approach and we are fine with\nthem.\n\nBased-on-a-patch-by: SZEDER Gábor <szeder.dev@gmail.com>\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt       |  9 +++++++\n Documentation/pretty-options.txt       |  2 +-\n Documentation/rev-list-options.txt     |  4 ++-\n contrib/completion/git-completion.bash |  2 +-\n pretty.c                               |  4 ++-\n t/t4205-log-pretty-formats.sh          | 36 ++++++++++++++++++++++++++\n 6 files changed, 53 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 11979301ff..ccd0921123 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -63,6 +63,15 @@ This is designed to be as compact as possible.\n \n \t       <full commit message>\n \n+* 'reference'\n+\n+\t  <abbrev hash> (<title line>, <short author date>)\n++\n+This format is used to refer to another commit in a commit message and\n+is the same as `--pretty='format:%C(auto)%h (%s, %as)'`.  As with any\n+`format:` with format placeholders, its output is not affected by other\n+options like `--decorate` and `--walk-reflogs`.\n+\n * 'email'\n \n \t  From <hash> <date>\ndiff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\nindex e44fc8f738..a59426eefd 100644\n--- a/Documentation/pretty-options.txt\n+++ b/Documentation/pretty-options.txt\n@@ -3,7 +3,7 @@\n \n \tPretty-print the contents of the commit logs in a given format,\n \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n-\t'full', 'fuller', 'email', 'raw', 'format:<string>'\n+\t'full', 'fuller', 'reference', 'email', 'raw', 'format:<string>'\n \tand 'tformat:<string>'.  When '<format>' is none of the above,\n \tand has '%placeholder' in it, it acts as if\n \t'--pretty=tformat:<format>' were given.\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex 90ff9e2bea..dfa83bddee 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -269,7 +269,7 @@ list.\n \texclude (that is, '{caret}commit', 'commit1..commit2',\n \tand 'commit1\\...commit2' notations cannot be used).\n +\n-With `--pretty` format other than `oneline` (for obvious reasons),\n+With `--pretty` format other than `oneline` and `reference` (for obvious reasons),\n this causes the output to have two extra lines of information\n taken from the reflog.  The reflog designator in the output may be shown\n as `ref@{Nth}` (where `Nth` is the reverse-chronological index in the\n@@ -293,6 +293,8 @@ Under `--pretty=oneline`, the commit message is\n prefixed with this information on the same line.\n This option cannot be combined with `--reverse`.\n See also linkgit:git-reflog[1].\n++\n+Under `--pretty=reference`, this information will not be shown at all.\n \n --merge::\n \tAfter a failed merge, show refs that touch files having a\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 557d0373c3..007e6a06d6 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1749,7 +1749,7 @@ __git_log_shortlog_options=\"\n \t--all-match --invert-grep\n \"\n \n-__git_log_pretty_formats=\"oneline short medium full fuller email raw format: tformat: mboxrd\"\n+__git_log_pretty_formats=\"oneline short medium full fuller reference email raw format: tformat: mboxrd\"\n __git_log_date_formats=\"relative iso8601 iso8601-strict rfc2822 short local default raw unix format:\"\n \n _git_log ()\ndiff --git a/pretty.c b/pretty.c\nindex 4d7f5e9aab..88a3bc621d 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -97,7 +97,9 @@ static void setup_commit_formats(void)\n \t\t{ \"mboxrd\",\tCMIT_FMT_MBOXRD,\t0,\t0 },\n \t\t{ \"fuller\",\tCMIT_FMT_FULLER,\t0,\t8 },\n \t\t{ \"full\",\tCMIT_FMT_FULL,\t\t0,\t8 },\n-\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 }\n+\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 },\n+\t\t{ \"reference\",\tCMIT_FMT_USERFORMAT,\t1,\t0,\n+\t\t\t0, \"%C(auto)%h (%s, %as)\" },\n \t\t/*\n \t\t * Please update $__git_log_pretty_formats in\n \t\t * git-completion.bash when you add new formats.\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex da9cacffea..9a9a18f104 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -824,4 +824,40 @@ test_expect_success '%S in git log --format works with other placeholders (part\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'log --pretty=reference' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference always uses short date' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --date=rfc --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference is never unabbreviated' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --no-abbrev-commit --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference is never decorated' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --decorate=short --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference does not output reflog info' '\n+\tgit log --walk-reflogs --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --walk-reflogs --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference is colored appropriately' '\n+\tgit log --color=always --pretty=\"tformat:%C(auto)%h (%s, %as)\" >expect &&\n+\tgit log --color=always --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386486","messageId":"888c496991642e63049ed84e84ba7af3c53311ee.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 10/11] SubmittingPatches: use `--pretty=reference`","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:33Z","receivedAt":"2019-11-19T00:21:37Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git was taught the `--pretty=reference` option, it is no longer\nnecessary to manually specify the format string to get the commit\nreference. Teach users to use the new option while keeping the old\ninvocation around in case they have an older version of Git.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex 7860dd2568..4515cab519 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -153,6 +153,12 @@ The \"Copy commit summary\" command of gitk can be used to obtain this\n format (with the subject enclosed in a pair of double-quotes), or this\n invocation of `git show`:\n \n+....\n+\tgit show -s --pretty=reference <commit>\n+....\n+\n+or, on an older version of Git without support for --pretty=reference:\n+\n ....\n \tgit show -s --date=short --pretty='format:%h (%s, %ad)' <commit>\n ....\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386487","messageId":"580aa7c88c0b18d752f9aa951166a2c82dbcd031.1574122784.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v4 11/11] squash! pretty: implement 'reference' format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T00:21:35Z","receivedAt":"2019-11-19T00:22:30Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Note that we explicitly special-case `--pretty=reference` to use\n`DATE_SHORT` by default in get_commit_format(). Although this isn't a\nvery elegant way of doing this, it has to be done this way because we\nimplement `--pretty=reference` as a user-format and, after this\nfunction, it is treated as a normal user-format. This is the only part\nof the pretty codepath where we can actually tell that we are dealing\nwith a \"special\" format so we have to do it here.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n\nNotes:\n    This patch implements the overridable `--date` for `--pretty=reference`.\n    The only reason I'm hesitant about squashing this in is, as described\n    above, that this patch isn't very elegant. I'd welcome suggestions on\n    how to possibly make it more elegant.\n    \n    Also, if we squash this in, we could drop the \"pretty: provide short\n    date format\" patch. We'd only need to update the test cases to stop\n    using `%as`. Thoughts on that?\n\n Documentation/pretty-formats.txt | 8 +++++---\n pretty.c                         | 8 +++++++-\n t/t4205-log-pretty-formats.sh    | 9 ++++++++-\n 3 files changed, 20 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex ccd0921123..1a7212ce5a 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -68,9 +68,11 @@ This is designed to be as compact as possible.\n \t  <abbrev hash> (<title line>, <short author date>)\n +\n This format is used to refer to another commit in a commit message and\n-is the same as `--pretty='format:%C(auto)%h (%s, %as)'`.  As with any\n-`format:` with format placeholders, its output is not affected by other\n-options like `--decorate` and `--walk-reflogs`.\n+is the same as `--pretty='format:%C(auto)%h (%s, %ad)'`.  By default,\n+the date is formatted with `--date=short` unless another `--date` option\n+is explicitly specified.  As with any `format:` with format\n+placeholders, its output is not affected by other options like\n+`--decorate` and `--walk-reflogs`.\n \n * 'email'\n \ndiff --git a/pretty.c b/pretty.c\nindex 88a3bc621d..8bb4b1d67f 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -99,7 +99,7 @@ static void setup_commit_formats(void)\n \t\t{ \"full\",\tCMIT_FMT_FULL,\t\t0,\t8 },\n \t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 },\n \t\t{ \"reference\",\tCMIT_FMT_USERFORMAT,\t1,\t0,\n-\t\t\t0, \"%C(auto)%h (%s, %as)\" },\n+\t\t\t0, \"%C(auto)%h (%s, %ad)\" },\n \t\t/*\n \t\t * Please update $__git_log_pretty_formats in\n \t\t * git-completion.bash when you add new formats.\n@@ -187,6 +187,12 @@ void get_commit_format(const char *arg, struct rev_info *rev)\n \t\tsave_user_format(rev, commit_format->user_format,\n \t\t\t\t commit_format->is_tformat);\n \t}\n+\t/*\n+\t * --pretty=reference is special; it should use the short date format\n+\t * unless otherwise specified\n+\t */\n+\tif (!rev->date_mode_explicit && !strcmp(arg, \"reference\"))\n+\t\trev->date_mode.type = DATE_SHORT;\n }\n \n /*\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex 9a9a18f104..a8ef3784cf 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -830,8 +830,15 @@ test_expect_success 'log --pretty=reference' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'log --pretty=reference always uses short date' '\n+test_expect_success 'log --pretty=reference with log.date is overridden by short date' '\n \tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\ttest_config log.date rfc &&\n+\tgit log --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference with explicit date overrides short date' '\n+\tgit log --date=rfc --pretty=\"tformat:%h (%s, %ad)\" >expect &&\n \tgit log --date=rfc --pretty=reference >actual &&\n \ttest_cmp expect actual\n '\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386502","messageId":"xmqq7e3wzhlx.fsf@gitster-ct.c.googlers.com","threadId":"52187","inReplyTo":"580aa7c88c0b18d752f9aa951166a2c82dbcd031.1574122784.git.liu.denton@gmail.com","subject":"Re: [PATCH v4 11/11] squash! pretty: implement 'reference' format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-19T03:10:18Z","receivedAt":"2019-11-19T03:10:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denton Liu <liu.denton@gmail.com> writes:\n\n> Note that we explicitly special-case `--pretty=reference` to use\n> `DATE_SHORT` by default in get_commit_format(). Although this isn't a\n> very elegant way of doing this, it has to be done this way because we\n> implement `--pretty=reference` as a user-format and, after this\n> function, it is treated as a normal user-format. This is the only part\n> of the pretty codepath where we can actually tell that we are dealing\n> with a \"special\" format so we have to do it here.\n\nI was hoping that by extending cmt_fmt_map horizontally, we can\ncause the date mode (and other things in the future) to optionally\ndefault to the format specific value, without hardcoding the string\nconstant in the code.  After all, that (i.e. not having to hardcode\nper-format specific constants) is the original point of using\ntable(s) to describe the customization.\n\n"},{"id":"386583","messageId":"cover.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574122784.git.liu.denton@gmail.com","subject":"[PATCH v5 00/11] learn the \"reference\" pretty format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:00Z","receivedAt":"2019-11-20T00:51:06Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"On this mailing list (and many others) the standard way to reference\nother commits with the \"reference\" format, e.g. \"f86a374 (pack-bitmap.c:\nfix a memleak, 2015-03-30)\". Since it's so commonly used, let's\nstandardise it as a pretty format.\n\nPatches 5-7 were cleanup patches that were critical in earlier\niterations of the series but no longer are critical for the rest of the\npatchset. Nonetheless, let's include them since they improve the quality\nof the codebase.\n\nChanges since v4:\n\n* Add a column in `struct cmt_fmt_map` to handle the default short date\n  of `--pretty=reference`\n\nChanges since v3:\n\n* Change one reference from \"summary\" to \"reference\"\n\n* Clarify --pretty=reference documentation\n\n* Add a squashable patch at the end to implement overridable --date\n\nChanges since v2:\n\n* Rename from \"summary\" to \"reference\"\n\n* Implement the feature as a canned userformat\n\n* Implement the %*s (short date) format string element\n\n* Remove the enclosing dqs around the subject\n\nChanges since v1:\n\n* Replace more references to \"sha1\" with \"hash\"\n\n* Clean up 8/10 by losing the allocation and making the subject less\n  misleading\n\n* Add tests in 7/10 to ensure 8/10 does not change any behaviour\n\nDenton Liu (10):\n  SubmittingPatches: use generic terms for hash\n  pretty-formats.txt: use generic terms for hash\n  SubmittingPatches: remove dq from commit reference\n  completion: complete `tformat:` pretty format\n  revision: make get_revision_mark() return const pointer\n  pretty.c: inline initalize format_context\n  t4205: cover `git log --reflog -z` blindspot\n  pretty: add struct cmt_fmt_map::default_date_mode_type\n  pretty: implement 'reference' format\n  SubmittingPatches: use `--pretty=reference`\n\nRené Scharfe (1):\n  pretty: provide short date format\n\n Documentation/SubmittingPatches        | 16 ++++--\n Documentation/pretty-formats.txt       | 29 +++++++---\n Documentation/pretty-options.txt       |  2 +-\n Documentation/rev-list-options.txt     |  4 +-\n contrib/completion/git-completion.bash |  2 +-\n pretty.c                               | 20 +++++--\n revision.c                             |  4 +-\n revision.h                             |  4 +-\n t/t4205-log-pretty-formats.sh          | 79 ++++++++++++++++++++++++++\n 9 files changed, 134 insertions(+), 26 deletions(-)\n\nRange-diff against v4:\n 1:  616cda0b4d =  1:  616cda0b4d SubmittingPatches: use generic terms for hash\n 2:  badd3d4275 =  2:  badd3d4275 pretty-formats.txt: use generic terms for hash\n 3:  ff818446ad =  3:  ff818446ad SubmittingPatches: remove dq from commit reference\n 4:  2baa7f8d3d =  4:  2baa7f8d3d completion: complete `tformat:` pretty format\n 5:  ac23c4ec45 =  5:  ac23c4ec45 revision: make get_revision_mark() return const pointer\n 6:  fa375f8271 =  6:  fa375f8271 pretty.c: inline initalize format_context\n 7:  1519677b30 =  7:  1519677b30 t4205: cover `git log --reflog -z` blindspot\n 8:  6c41491c3e =  8:  6c41491c3e pretty: provide short date format\n -:  ---------- >  9:  ec05907b62 pretty: add struct cmt_fmt_map::default_date_mode_type\n 9:  7b0cf7a39f ! 10:  5264c44fab pretty: implement 'reference' format\n    @@ Documentation/pretty-formats.txt: This is designed to be as compact as possible.\n     +\t  <abbrev hash> (<title line>, <short author date>)\n     ++\n     +This format is used to refer to another commit in a commit message and\n    -+is the same as `--pretty='format:%C(auto)%h (%s, %as)'`.  As with any\n    -+`format:` with format placeholders, its output is not affected by other\n    -+options like `--decorate` and `--walk-reflogs`.\n    ++is the same as `--pretty='format:%C(auto)%h (%s, %ad)'`.  By default,\n    ++the date is formatted with `--date=short` unless another `--date` option\n    ++is explicitly specified.  As with any `format:` with format\n    ++placeholders, its output is not affected by other options like\n    ++`--decorate` and `--walk-reflogs`.\n     +\n      * 'email'\n      \n    @@ pretty.c: static void setup_commit_formats(void)\n     -\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 }\n     +\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 },\n     +\t\t{ \"reference\",\tCMIT_FMT_USERFORMAT,\t1,\t0,\n    -+\t\t\t0, \"%C(auto)%h (%s, %as)\" },\n    ++\t\t\t0, DATE_SHORT, \"%C(auto)%h (%s, %ad)\" },\n      \t\t/*\n      \t\t * Please update $__git_log_pretty_formats in\n      \t\t * git-completion.bash when you add new formats.\n    @@ t/t4205-log-pretty-formats.sh: test_expect_success '%S in git log --format works\n     +\ttest_cmp expect actual\n     +'\n     +\n    -+test_expect_success 'log --pretty=reference always uses short date' '\n    ++test_expect_success 'log --pretty=reference with log.date is overridden by short date' '\n     +\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n    ++\ttest_config log.date rfc &&\n    ++\tgit log --pretty=reference >actual &&\n    ++\ttest_cmp expect actual\n    ++'\n    ++\n    ++test_expect_success 'log --pretty=reference with explicit date overrides short date' '\n    ++\tgit log --date=rfc --pretty=\"tformat:%h (%s, %ad)\" >expect &&\n     +\tgit log --date=rfc --pretty=reference >actual &&\n     +\ttest_cmp expect actual\n     +'\n10:  746481042a = 11:  1281927cb3 SubmittingPatches: use `--pretty=reference`\n11:  9d50c069f7 <  -:  ---------- squash! pretty: implement 'reference' format\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386584","messageId":"616cda0b4db9d95bfdef9f6546ca014b901bbaf2.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 01/11] SubmittingPatches: use generic terms for hash","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:03Z","receivedAt":"2019-11-20T00:51:08Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git is planning on upgrading from SHA-1 to be more hash-agnostic,\nreplace specific references to SHA-1 with more generic terminology.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/SubmittingPatches | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex 6d589e118c..5a00329d5a 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -142,7 +142,7 @@ archive, summarize the relevant points of the discussion.\n \n [[commit-reference]]\n If you want to reference a previous commit in the history of a stable\n-branch, use the format \"abbreviated sha1 (subject, date)\",\n+branch, use the format \"abbreviated hash (subject, date)\",\n with the subject enclosed in a pair of double-quotes, like this:\n \n ....\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386585","messageId":"badd3d4275b1a235c95f671ca3f46fd7bee6bfec.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 02/11] pretty-formats.txt: use generic terms for hash","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:06Z","receivedAt":"2019-11-20T00:51:10Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git is planning on upgrading from SHA-1 to be more hash-agnostic,\nreplace specific references to SHA-1 with more generic terminology.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/pretty-formats.txt | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 079598307a..fdccfe5b03 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -4,7 +4,7 @@ PRETTY FORMATS\n If the commit is a merge, and if the pretty-format\n is not 'oneline', 'email' or 'raw', an additional line is\n inserted before the 'Author:' line.  This line begins with\n-\"Merge: \" and the sha1s of ancestral commits are printed,\n+\"Merge: \" and the hashes of ancestral commits are printed,\n separated by spaces.  Note that the listed commits may not\n necessarily be the list of the *direct* parent commits if you\n have limited your view of history: for example, if you are\n@@ -20,20 +20,20 @@ built-in formats:\n \n * 'oneline'\n \n-\t  <sha1> <title line>\n+\t  <hash> <title line>\n +\n This is designed to be as compact as possible.\n \n * 'short'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \n \t      <title line>\n \n * 'medium'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Date:   <author date>\n \n@@ -43,7 +43,7 @@ This is designed to be as compact as possible.\n \n * 'full'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author: <author>\n \t  Commit: <committer>\n \n@@ -53,7 +53,7 @@ This is designed to be as compact as possible.\n \n * 'fuller'\n \n-\t  commit <sha1>\n+\t  commit <hash>\n \t  Author:     <author>\n \t  AuthorDate: <author date>\n \t  Commit:     <committer>\n@@ -65,7 +65,7 @@ This is designed to be as compact as possible.\n \n * 'email'\n \n-\t  From <sha1> <date>\n+\t  From <hash> <date>\n \t  From: <author>\n \t  Date: <author date>\n \t  Subject: [PATCH] <title line>\n@@ -75,7 +75,7 @@ This is designed to be as compact as possible.\n * 'raw'\n +\n The 'raw' format shows the entire commit exactly as\n-stored in the commit object.  Notably, the SHA-1s are\n+stored in the commit object.  Notably, the hashes are\n displayed in full, regardless of whether --abbrev or\n --no-abbrev are used, and 'parents' information show the\n true parent commits, without taking grafts or history\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386586","messageId":"ff818446add361304fcd7a70eed300c407a408b3.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 03/11] SubmittingPatches: remove dq from commit reference","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:08Z","receivedAt":"2019-11-20T00:51:13Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Quoting SZEDER Gábor[1],\n\n\tSubmittingPatches is simply wrong: our de-facto standard format for\n\treferencing other commits does not enclose the subject in a pair of\n\tdouble-quotes:\n\n\t  $ git log v2.24.0 |grep -E '[0-9a-f]{7} \\(\"' |wc -l\n\t  785\n\t  $ git log v2.24.0 |grep -E '[0-9a-f]{7} \\([^\"]' |wc -l\n\t  2276\n\n\tThose double-quotes don't add any value to the references, but they\n\tresult in weird looking references for 1083 of our commits whose\n\tsubject lines happen to end with double-quotes, e.g.:\n\n\t  f23a465132 (\"hashmap_get{,_from_hash} return \"struct hashmap_entry *\"\", 2019-10-06)\n\n\tand without those unnecessary pair of double-quotes we would have\n\t~3000 more commits whose summary would fit on a single line.\n\nRemove references to the enclosing double-quotes from SubmittingPatches\nsince our de-facto standard for referencing commits does not actually\nuse them.\n\n[1]: cf. <20191114011048.GS4348@szeder.dev>\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/SubmittingPatches | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex 5a00329d5a..a1aad13384 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -142,19 +142,19 @@ archive, summarize the relevant points of the discussion.\n \n [[commit-reference]]\n If you want to reference a previous commit in the history of a stable\n-branch, use the format \"abbreviated hash (subject, date)\",\n-with the subject enclosed in a pair of double-quotes, like this:\n+branch, use the format \"abbreviated hash (subject, date)\", like this:\n \n ....\n-\tCommit f86a374 (\"pack-bitmap.c: fix a memleak\", 2015-03-30)\n+\tCommit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)\n \tnoticed that ...\n ....\n \n The \"Copy commit summary\" command of gitk can be used to obtain this\n-format, or this invocation of `git show`:\n+format (with the subject enclosed in a pair of double-quotes), or this\n+invocation of `git show`:\n \n ....\n-\tgit show -s --date=short --pretty='format:%h (\"%s\", %ad)' <commit>\n+\tgit show -s --date=short --pretty='format:%h (%s, %ad)' <commit>\n ....\n \n [[git-tools]]\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386587","messageId":"2baa7f8d3d8aaaa348014d4ce611d372e3d3a210.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 04/11] completion: complete `tformat:` pretty format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:11Z","receivedAt":"2019-11-20T00:51:17Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Signed-off-by: Denton Liu <liu.denton@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e087c4bf00..6bf91ab154 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1737,7 +1737,7 @@ __git_log_shortlog_options=\"\n \t--all-match --invert-grep\n \"\n \n-__git_log_pretty_formats=\"oneline short medium full fuller email raw format: mboxrd\"\n+__git_log_pretty_formats=\"oneline short medium full fuller email raw format: tformat: mboxrd\"\n __git_log_date_formats=\"relative iso8601 iso8601-strict rfc2822 short local default raw unix format:\"\n \n _git_log ()\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386588","messageId":"ac23c4ec4522dd2343b8147b95b2408eddba0678.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 05/11] revision: make get_revision_mark() return const pointer","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:13Z","receivedAt":"2019-11-20T00:51:18Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"get_revision_mark() used to return a `char *`, even though all of the\nstrings it was returning were string literals. Make get_revision_mark()\nreturn a `const char *` so that callers won't be tempted to modify the\nreturned string.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n revision.c | 4 ++--\n revision.h | 4 ++--\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 07412297f0..2eb9ff089b 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -3934,7 +3934,7 @@ struct commit *get_revision(struct rev_info *revs)\n \treturn c;\n }\n \n-char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n+const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n \tif (commit->object.flags & BOUNDARY)\n \t\treturn \"-\";\n@@ -3956,7 +3956,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit\n \n void put_revision_mark(const struct rev_info *revs, const struct commit *commit)\n {\n-\tchar *mark = get_revision_mark(revs, commit);\n+\tconst char *mark = get_revision_mark(revs, commit);\n \tif (!strlen(mark))\n \t\treturn;\n \tfputs(mark, stdout);\ndiff --git a/revision.h b/revision.h\nindex 4134dc6029..addd69410b 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,\n void reset_revision_walk(void);\n int prepare_revision_walk(struct rev_info *revs);\n struct commit *get_revision(struct rev_info *revs);\n-char *get_revision_mark(const struct rev_info *revs,\n-\t\t\tconst struct commit *commit);\n+const char *get_revision_mark(const struct rev_info *revs,\n+\t\t\t      const struct commit *commit);\n void put_revision_mark(const struct rev_info *revs,\n \t\t       const struct commit *commit);\n \n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386589","messageId":"fa375f8271fd30b0e4be5f10c4cb10deb45afee5.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 06/11] pretty.c: inline initalize format_context","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:16Z","receivedAt":"2019-11-20T00:51:20Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Instead of memsetting and then initializing the fields in the struct,\nmove the initialization of `format_context` to its assignment.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n pretty.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex e4ed14effe..da154affd4 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1612,14 +1612,14 @@ void repo_format_commit_message(struct repository *r,\n \t\t\t\tconst char *format, struct strbuf *sb,\n \t\t\t\tconst struct pretty_print_context *pretty_ctx)\n {\n-\tstruct format_commit_context context;\n+\tstruct format_commit_context context = {\n+\t\t.commit = commit,\n+\t\t.pretty_ctx = pretty_ctx,\n+\t\t.wrap_start = sb->len\n+\t};\n \tconst char *output_enc = pretty_ctx->output_encoding;\n \tconst char *utf8 = \"UTF-8\";\n \n-\tmemset(&context, 0, sizeof(context));\n-\tcontext.commit = commit;\n-\tcontext.pretty_ctx = pretty_ctx;\n-\tcontext.wrap_start = sb->len;\n \t/*\n \t * convert a commit message to UTF-8 first\n \t * as far as 'format_commit_item' assumes it in UTF-8\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386590","messageId":"1519677b30f7a543141c7a0c313c6a965c616a58.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 07/11] t4205: cover `git log --reflog -z` blindspot","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:18Z","receivedAt":"2019-11-20T00:51:23Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"The test suite does not include any tests where `--reflog` and `-z` are\nused together in `git log`. Cover this blindspot. Note that the\n`--pretty=oneline` case is written separately because it follows a\nslightly different codepath.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t4205-log-pretty-formats.sh | 30 ++++++++++++++++++++++++++++++\n 1 file changed, 30 insertions(+)\n\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex f42a69faa2..0335b428b1 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -134,6 +134,36 @@ test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' '\n \ttest_cmp expected actual\n '\n \n+for p in short medium full fuller email raw\n+do\n+\ttest_expect_success \"NUL termination with --reflog --pretty=$p\" '\n+\t\trevs=\"$(git rev-list --reflog)\" &&\n+\t\tfor r in $revs\n+\t\tdo\n+\t\t\tgit show -s \"$r\" --pretty=\"$p\" &&\n+\t\t\tprintf \"\\0\" || return 1\n+\t\tdone >expect &&\n+\t\t{\n+\t\t\tgit log -z --reflog --pretty=\"$p\" &&\n+\t\t\tprintf \"\\0\"\n+\t\t} >actual &&\n+\t\ttest_cmp expect actual\n+\t'\n+done\n+\n+test_expect_success 'NUL termination with --reflog --pretty=oneline' '\n+\trevs=\"$(git rev-list --reflog)\" &&\n+\tfor r in $revs\n+\tdo\n+\t\tgit show -s --pretty=oneline \"$r\" >raw &&\n+\t\tcat raw | lf_to_nul || exit 1\n+\tdone >expect &&\n+\t# the trailing NUL is already produced so we do not need to\n+\t# output another one\n+\tgit log -z --pretty=oneline --reflog >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_expect_success 'setup more commits' '\n \ttest_commit \"message one\" one one message-one &&\n \ttest_commit \"message two\" two two message-two &&\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386591","messageId":"6c41491c3ebb822a2f0a9744f7994709862a66b9.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 08/11] pretty: provide short date format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:21Z","receivedAt":"2019-11-20T00:51:25Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"From: René Scharfe <l.s.r@web.de>\n\nAdd the placeholders %as and %cs to format author date and committer\ndate, respectively, without the time part, like --date=short does, i.e.\nlike YYYY-MM-DD.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/pretty-formats.txt | 2 ++\n pretty.c                         | 3 +++\n t/t4205-log-pretty-formats.sh    | 6 ++++++\n 3 files changed, 11 insertions(+)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex fdccfe5b03..34bbc39273 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -169,6 +169,7 @@ The placeholders are:\n '%at':: author date, UNIX timestamp\n '%ai':: author date, ISO 8601-like format\n '%aI':: author date, strict ISO 8601 format\n+'%as':: author date, short format (`YYYY-MM-DD`)\n '%cn':: committer name\n '%cN':: committer name (respecting .mailmap, see\n \tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n@@ -181,6 +182,7 @@ The placeholders are:\n '%ct':: committer date, UNIX timestamp\n '%ci':: committer date, ISO 8601-like format\n '%cI':: committer date, strict ISO 8601 format\n+'%cs':: committer date, short format (`YYYY-MM-DD`)\n '%d':: ref names, like the --decorate option of linkgit:git-log[1]\n '%D':: ref names without the \" (\", \")\" wrapping.\n '%S':: ref name given on the command line by which the commit was reached\ndiff --git a/pretty.c b/pretty.c\nindex da154affd4..61014cc25a 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -731,6 +731,9 @@ static size_t format_person_part(struct strbuf *sb, char part,\n \tcase 'I':\t/* date, ISO 8601 strict */\n \t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(ISO8601_STRICT)));\n \t\treturn placeholder_len;\n+\tcase 's':\n+\t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(SHORT)));\n+\t\treturn placeholder_len;\n \t}\n \n skip:\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex 0335b428b1..da9cacffea 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -533,6 +533,12 @@ test_expect_success 'ISO and ISO-strict date formats display the same values' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'short date' '\n+\tgit log --format=%ad%n%cd --date=short >expected &&\n+\tgit log --format=%as%n%cs >actual &&\n+\ttest_cmp expected actual\n+'\n+\n # get new digests (with no abbreviations)\n test_expect_success 'set up log decoration tests' '\n \thead1=$(git rev-parse --verify HEAD~0) &&\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386592","messageId":"ec05907b6202b07733c02ca4af55de2d01681b7e.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 09/11] pretty: add struct cmt_fmt_map::default_date_mode_type","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:23Z","receivedAt":"2019-11-20T00:51:27Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"In a future commit, we plan on having a pretty format which will use a\ndefault date format unless otherwise overidden. Add support for this by\nadding a `default_date_mode_type` member in `struct cmt_fmt_map`.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n pretty.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/pretty.c b/pretty.c\nindex 61014cc25a..63fa600276 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -20,6 +20,7 @@ static struct cmt_fmt_map {\n \tint is_tformat;\n \tint expand_tabs_in_log;\n \tint is_alias;\n+\tenum date_mode_type default_date_mode_type;\n \tconst char *user_format;\n } *commit_formats;\n static size_t builtin_formats_len;\n@@ -181,6 +182,8 @@ void get_commit_format(const char *arg, struct rev_info *rev)\n \trev->commit_format = commit_format->format;\n \trev->use_terminator = commit_format->is_tformat;\n \trev->expand_tabs_in_log_default = commit_format->expand_tabs_in_log;\n+\tif (!rev->date_mode_explicit && commit_format->default_date_mode_type)\n+\t\trev->date_mode.type = commit_format->default_date_mode_type;\n \tif (commit_format->format == CMIT_FMT_USERFORMAT) {\n \t\tsave_user_format(rev, commit_format->user_format,\n \t\t\t\t commit_format->is_tformat);\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386593","messageId":"5264c44fab5d64cdfea8ef9fe2c1088af3d41014.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 10/11] pretty: implement 'reference' format","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:25Z","receivedAt":"2019-11-20T00:51:32Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"The standard format for referencing other commits within some projects\n(such as git.git) is the reference format. This is described in\nDocumentation/SubmittingPatches as\n\n\tIf you want to reference a previous commit in the history of a stable\n\tbranch, use the format \"abbreviated hash (subject, date)\", like this:\n\n\t....\n\t\tCommit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)\n\t\tnoticed that ...\n\t....\n\nSince this format is so commonly used, standardize it as a pretty\nformat.\n\nThe tests that are implemented essentially show that the format-string\ndoes not change in response to various log options. This is useful\nbecause, for future developers, it shows that we've considered the\nlimitations of the \"canned format-string\" approach and we are fine with\nthem.\n\nBased-on-a-patch-by: SZEDER Gábor <szeder.dev@gmail.com>\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/pretty-formats.txt       | 11 +++++++\n Documentation/pretty-options.txt       |  2 +-\n Documentation/rev-list-options.txt     |  4 ++-\n contrib/completion/git-completion.bash |  2 +-\n pretty.c                               |  4 ++-\n t/t4205-log-pretty-formats.sh          | 43 ++++++++++++++++++++++++++\n 6 files changed, 62 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 34bbc39273..0df418e609 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -63,6 +63,17 @@ This is designed to be as compact as possible.\n \n \t       <full commit message>\n \n+* 'reference'\n+\n+\t  <abbrev hash> (<title line>, <short author date>)\n++\n+This format is used to refer to another commit in a commit message and\n+is the same as `--pretty='format:%C(auto)%h (%s, %ad)'`.  By default,\n+the date is formatted with `--date=short` unless another `--date` option\n+is explicitly specified.  As with any `format:` with format\n+placeholders, its output is not affected by other options like\n+`--decorate` and `--walk-reflogs`.\n+\n * 'email'\n \n \t  From <hash> <date>\ndiff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\nindex e44fc8f738..a59426eefd 100644\n--- a/Documentation/pretty-options.txt\n+++ b/Documentation/pretty-options.txt\n@@ -3,7 +3,7 @@\n \n \tPretty-print the contents of the commit logs in a given format,\n \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n-\t'full', 'fuller', 'email', 'raw', 'format:<string>'\n+\t'full', 'fuller', 'reference', 'email', 'raw', 'format:<string>'\n \tand 'tformat:<string>'.  When '<format>' is none of the above,\n \tand has '%placeholder' in it, it acts as if\n \t'--pretty=tformat:<format>' were given.\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex bb1251c036..b94ed85c7a 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -269,7 +269,7 @@ list.\n \texclude (that is, '{caret}commit', 'commit1..commit2',\n \tand 'commit1\\...commit2' notations cannot be used).\n +\n-With `--pretty` format other than `oneline` (for obvious reasons),\n+With `--pretty` format other than `oneline` and `reference` (for obvious reasons),\n this causes the output to have two extra lines of information\n taken from the reflog.  The reflog designator in the output may be shown\n as `ref@{Nth}` (where `Nth` is the reverse-chronological index in the\n@@ -293,6 +293,8 @@ Under `--pretty=oneline`, the commit message is\n prefixed with this information on the same line.\n This option cannot be combined with `--reverse`.\n See also linkgit:git-reflog[1].\n++\n+Under `--pretty=reference`, this information will not be shown at all.\n \n --merge::\n \tAfter a failed merge, show refs that touch files having a\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6bf91ab154..889e707a05 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1737,7 +1737,7 @@ __git_log_shortlog_options=\"\n \t--all-match --invert-grep\n \"\n \n-__git_log_pretty_formats=\"oneline short medium full fuller email raw format: tformat: mboxrd\"\n+__git_log_pretty_formats=\"oneline short medium full fuller reference email raw format: tformat: mboxrd\"\n __git_log_date_formats=\"relative iso8601 iso8601-strict rfc2822 short local default raw unix format:\"\n \n _git_log ()\ndiff --git a/pretty.c b/pretty.c\nindex 63fa600276..5fc8b730d8 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -98,7 +98,9 @@ static void setup_commit_formats(void)\n \t\t{ \"mboxrd\",\tCMIT_FMT_MBOXRD,\t0,\t0 },\n \t\t{ \"fuller\",\tCMIT_FMT_FULLER,\t0,\t8 },\n \t\t{ \"full\",\tCMIT_FMT_FULL,\t\t0,\t8 },\n-\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 }\n+\t\t{ \"oneline\",\tCMIT_FMT_ONELINE,\t1,\t0 },\n+\t\t{ \"reference\",\tCMIT_FMT_USERFORMAT,\t1,\t0,\n+\t\t\t0, DATE_SHORT, \"%C(auto)%h (%s, %ad)\" },\n \t\t/*\n \t\t * Please update $__git_log_pretty_formats in\n \t\t * git-completion.bash when you add new formats.\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex da9cacffea..a8ef3784cf 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -824,4 +824,47 @@ test_expect_success '%S in git log --format works with other placeholders (part\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'log --pretty=reference' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference with log.date is overridden by short date' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\ttest_config log.date rfc &&\n+\tgit log --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference with explicit date overrides short date' '\n+\tgit log --date=rfc --pretty=\"tformat:%h (%s, %ad)\" >expect &&\n+\tgit log --date=rfc --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference is never unabbreviated' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --no-abbrev-commit --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference is never decorated' '\n+\tgit log --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --decorate=short --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference does not output reflog info' '\n+\tgit log --walk-reflogs --pretty=\"tformat:%h (%s, %as)\" >expect &&\n+\tgit log --walk-reflogs --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'log --pretty=reference is colored appropriately' '\n+\tgit log --color=always --pretty=\"tformat:%C(auto)%h (%s, %as)\" >expect &&\n+\tgit log --color=always --pretty=reference >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386594","messageId":"1281927cb3f03f17d71abfce7f559df8e02306be.1574211027.git.liu.denton@gmail.com","threadId":"52187","inReplyTo":"cover.1574211027.git.liu.denton@gmail.com","subject":"[PATCH v5 11/11] SubmittingPatches: use `--pretty=reference`","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-20T00:51:28Z","receivedAt":"2019-11-20T00:51:33Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Since Git was taught the `--pretty=reference` option, it is no longer\nnecessary to manually specify the format string to get the commit\nreference. Teach users to use the new option while keeping the old\ninvocation around in case they have an older version of Git.\n\nSigned-off-by: Denton Liu <liu.denton@gmail.com>\n---\n Documentation/SubmittingPatches | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches\nindex a1aad13384..af9fb356ca 100644\n--- a/Documentation/SubmittingPatches\n+++ b/Documentation/SubmittingPatches\n@@ -153,6 +153,12 @@ The \"Copy commit summary\" command of gitk can be used to obtain this\n format (with the subject enclosed in a pair of double-quotes), or this\n invocation of `git show`:\n \n+....\n+\tgit show -s --pretty=reference <commit>\n+....\n+\n+or, on an older version of Git without support for --pretty=reference:\n+\n ....\n \tgit show -s --date=short --pretty='format:%h (%s, %ad)' <commit>\n ....\n-- \n2.24.0.420.g9ac4901264\n\n"},{"id":"386605","messageId":"xmqqr223ck5t.fsf@gitster-ct.c.googlers.com","threadId":"52187","inReplyTo":"ec05907b6202b07733c02ca4af55de2d01681b7e.1574211027.git.liu.denton@gmail.com","subject":"Re: [PATCH v5 09/11] pretty: add struct cmt_fmt_map::default_date_mode_type","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-20T03:15:58Z","receivedAt":"2019-11-20T03:16:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denton Liu <liu.denton@gmail.com> writes:\n\n> In a future commit, we plan on having a pretty format which will use a\n> default date format unless otherwise overidden. Add support for this by\n> adding a `default_date_mode_type` member in `struct cmt_fmt_map`.\n>\n> Signed-off-by: Denton Liu <liu.denton@gmail.com>\n> ---\n>  pretty.c | 3 +++\n>  1 file changed, 3 insertions(+)\n\nYup, that is what I meant.  expand_tabs_in_log and friends are\ngood examples of per-format tweak defined in this table, and the\ndefault date mode is a good addition.\n\nThanks.\n\n>\n> diff --git a/pretty.c b/pretty.c\n> index 61014cc25a..63fa600276 100644\n> --- a/pretty.c\n> +++ b/pretty.c\n> @@ -20,6 +20,7 @@ static struct cmt_fmt_map {\n>  \tint is_tformat;\n>  \tint expand_tabs_in_log;\n>  \tint is_alias;\n> +\tenum date_mode_type default_date_mode_type;\n>  \tconst char *user_format;\n>  } *commit_formats;\n>  static size_t builtin_formats_len;\n> @@ -181,6 +182,8 @@ void get_commit_format(const char *arg, struct rev_info *rev)\n>  \trev->commit_format = commit_format->format;\n>  \trev->use_terminator = commit_format->is_tformat;\n>  \trev->expand_tabs_in_log_default = commit_format->expand_tabs_in_log;\n> +\tif (!rev->date_mode_explicit && commit_format->default_date_mode_type)\n> +\t\trev->date_mode.type = commit_format->default_date_mode_type;\n>  \tif (commit_format->format == CMIT_FMT_USERFORMAT) {\n>  \t\tsave_user_format(rev, commit_format->user_format,\n>  \t\t\t\t commit_format->is_tformat);\n"}]}