From bd00717eab1f2c9e9f50d8bca3fa81f7f953f283 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Tue, 19 Nov 2019 16:51:03 -0800 Subject: SubmittingPatches: use generic terms for hash Since Git is planning on upgrading from SHA-1 to be more hash-agnostic, replace specific references to SHA-1 with more generic terminology. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- Documentation/SubmittingPatches | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 6d589e118c..5a00329d5a 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -142,7 +142,7 @@ archive, summarize the relevant points of the discussion. [[commit-reference]] If you want to reference a previous commit in the history of a stable -branch, use the format "abbreviated sha1 (subject, date)", +branch, use the format "abbreviated hash (subject, date)", with the subject enclosed in a pair of double-quotes, like this: .... -- cgit v1.2.3 From bae74c9dfbacce38dcd8cc7c2737af11a85d9906 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Tue, 19 Nov 2019 16:51:06 -0800 Subject: pretty-formats.txt: use generic terms for hash Since Git is planning on upgrading from SHA-1 to be more hash-agnostic, replace specific references to SHA-1 with more generic terminology. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- Documentation/pretty-formats.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index 079598307a..fdccfe5b03 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -4,7 +4,7 @@ PRETTY FORMATS If the commit is a merge, and if the pretty-format is not 'oneline', 'email' or 'raw', an additional line is inserted before the 'Author:' line. This line begins with -"Merge: " and the sha1s of ancestral commits are printed, +"Merge: " and the hashes of ancestral commits are printed, separated by spaces. Note that the listed commits may not necessarily be the list of the *direct* parent commits if you have limited your view of history: for example, if you are @@ -20,20 +20,20 @@ built-in formats: * 'oneline' - + <hash> <title line> + This is designed to be as compact as possible. * 'short' - commit <sha1> + commit <hash> Author: <author> <title line> * 'medium' - commit <sha1> + commit <hash> Author: <author> Date: <author date> @@ -43,7 +43,7 @@ This is designed to be as compact as possible. * 'full' - commit <sha1> + commit <hash> Author: <author> Commit: <committer> @@ -53,7 +53,7 @@ This is designed to be as compact as possible. * 'fuller' - commit <sha1> + commit <hash> Author: <author> AuthorDate: <author date> Commit: <committer> @@ -65,7 +65,7 @@ This is designed to be as compact as possible. * 'email' - From <sha1> <date> + From <hash> <date> From: <author> Date: <author date> Subject: [PATCH] <title line> @@ -75,7 +75,7 @@ This is designed to be as compact as possible. * 'raw' + The 'raw' format shows the entire commit exactly as -stored in the commit object. Notably, the SHA-1s are +stored in the commit object. Notably, the hashes are displayed in full, regardless of whether --abbrev or --no-abbrev are used, and 'parents' information show the true parent commits, without taking grafts or history -- cgit v1.2.3 From fb2ffa77a6cbd0f4b996befe372f1c7a1b881e66 Mon Sep 17 00:00:00 2001 From: Denton Liu <liu.denton@gmail.com> Date: Tue, 19 Nov 2019 16:51:08 -0800 Subject: SubmittingPatches: remove dq from commit reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quoting SZEDER Gábor[1], SubmittingPatches is simply wrong: our de-facto standard format for referencing other commits does not enclose the subject in a pair of double-quotes: $ git log v2.24.0 |grep -E '[0-9a-f]{7} \("' |wc -l 785 $ git log v2.24.0 |grep -E '[0-9a-f]{7} \([^"]' |wc -l 2276 Those double-quotes don't add any value to the references, but they result in weird looking references for 1083 of our commits whose subject lines happen to end with double-quotes, e.g.: f23a465132 ("hashmap_get{,_from_hash} return "struct hashmap_entry *"", 2019-10-06) and without those unnecessary pair of double-quotes we would have ~3000 more commits whose summary would fit on a single line. Remove references to the enclosing double-quotes from SubmittingPatches since our de-facto standard for referencing commits does not actually use them. [1]: cf. <20191114011048.GS4348@szeder.dev> Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- Documentation/SubmittingPatches | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 5a00329d5a..a1aad13384 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -142,19 +142,19 @@ archive, summarize the relevant points of the discussion. [[commit-reference]] If you want to reference a previous commit in the history of a stable -branch, use the format "abbreviated hash (subject, date)", -with the subject enclosed in a pair of double-quotes, like this: +branch, use the format "abbreviated hash (subject, date)", like this: .... - Commit f86a374 ("pack-bitmap.c: fix a memleak", 2015-03-30) + Commit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30) noticed that ... .... The "Copy commit summary" command of gitk can be used to obtain this -format, or this invocation of `git show`: +format (with the subject enclosed in a pair of double-quotes), or this +invocation of `git show`: .... - git show -s --date=short --pretty='format:%h ("%s", %ad)' <commit> + git show -s --date=short --pretty='format:%h (%s, %ad)' <commit> .... [[git-tools]] -- cgit v1.2.3 From f0f9de2bd71b41afeb2a2a77a681a15a83246a62 Mon Sep 17 00:00:00 2001 From: Denton Liu <liu.denton@gmail.com> Date: Tue, 19 Nov 2019 16:51:11 -0800 Subject: completion: complete `tformat:` pretty format Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index e087c4bf00..6bf91ab154 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1737,7 +1737,7 @@ __git_log_shortlog_options=" --all-match --invert-grep " -__git_log_pretty_formats="oneline short medium full fuller email raw format: mboxrd" +__git_log_pretty_formats="oneline short medium full fuller email raw format: tformat: mboxrd" __git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:" _git_log () -- cgit v1.2.3 From 4982516451ed4979bc7fc1a7f002fc310b060118 Mon Sep 17 00:00:00 2001 From: Denton Liu <liu.denton@gmail.com> Date: Tue, 19 Nov 2019 16:51:13 -0800 Subject: revision: make get_revision_mark() return const pointer get_revision_mark() used to return a `char *`, even though all of the strings it was returning were string literals. Make get_revision_mark() return a `const char *` so that callers won't be tempted to modify the returned string. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- revision.c | 4 ++-- revision.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/revision.c b/revision.c index 07412297f0..2eb9ff089b 100644 --- a/revision.c +++ b/revision.c @@ -3934,7 +3934,7 @@ struct commit *get_revision(struct rev_info *revs) return c; } -char *get_revision_mark(const struct rev_info *revs, const struct commit *commit) +const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit) { if (commit->object.flags & BOUNDARY) return "-"; @@ -3956,7 +3956,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit void put_revision_mark(const struct rev_info *revs, const struct commit *commit) { - char *mark = get_revision_mark(revs, commit); + const char *mark = get_revision_mark(revs, commit); if (!strlen(mark)) return; fputs(mark, stdout); diff --git a/revision.h b/revision.h index 4134dc6029..addd69410b 100644 --- a/revision.h +++ b/revision.h @@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs, void reset_revision_walk(void); int prepare_revision_walk(struct rev_info *revs); struct commit *get_revision(struct rev_info *revs); -char *get_revision_mark(const struct rev_info *revs, - const struct commit *commit); +const char *get_revision_mark(const struct rev_info *revs, + const struct commit *commit); void put_revision_mark(const struct rev_info *revs, const struct commit *commit); -- cgit v1.2.3 From 3e8ed3b93e9b46eb6fe61589482751728865de57 Mon Sep 17 00:00:00 2001 From: Denton Liu <liu.denton@gmail.com> Date: Tue, 19 Nov 2019 16:51:16 -0800 Subject: pretty.c: inline initalize format_context Instead of memsetting and then initializing the fields in the struct, move the initialization of `format_context` to its assignment. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- pretty.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pretty.c b/pretty.c index e4ed14effe..da154affd4 100644 --- a/pretty.c +++ b/pretty.c @@ -1612,14 +1612,14 @@ void repo_format_commit_message(struct repository *r, const char *format, struct strbuf *sb, const struct pretty_print_context *pretty_ctx) { - struct format_commit_context context; + struct format_commit_context context = { + .commit = commit, + .pretty_ctx = pretty_ctx, + .wrap_start = sb->len + }; const char *output_enc = pretty_ctx->output_encoding; const char *utf8 = "UTF-8"; - memset(&context, 0, sizeof(context)); - context.commit = commit; - context.pretty_ctx = pretty_ctx; - context.wrap_start = sb->len; /* * convert a commit message to UTF-8 first * as far as 'format_commit_item' assumes it in UTF-8 -- cgit v1.2.3 From ac52d9410e5fad8d0bffa95e70e514c3fbd96871 Mon Sep 17 00:00:00 2001 From: Denton Liu <liu.denton@gmail.com> Date: Tue, 19 Nov 2019 16:51:18 -0800 Subject: t4205: cover `git log --reflog -z` blindspot The test suite does not include any tests where `--reflog` and `-z` are used together in `git log`. Cover this blindspot. Note that the `--pretty=oneline` case is written separately because it follows a slightly different codepath. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- t/t4205-log-pretty-formats.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index f42a69faa2..0335b428b1 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -134,6 +134,36 @@ test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' ' test_cmp expected actual ' +for p in short medium full fuller email raw +do + test_expect_success "NUL termination with --reflog --pretty=$p" ' + revs="$(git rev-list --reflog)" && + for r in $revs + do + git show -s "$r" --pretty="$p" && + printf "\0" || return 1 + done >expect && + { + git log -z --reflog --pretty="$p" && + printf "\0" + } >actual && + test_cmp expect actual + ' +done + +test_expect_success 'NUL termination with --reflog --pretty=oneline' ' + revs="$(git rev-list --reflog)" && + for r in $revs + do + git show -s --pretty=oneline "$r" >raw && + cat raw | lf_to_nul || exit 1 + done >expect && + # the trailing NUL is already produced so we do not need to + # output another one + git log -z --pretty=oneline --reflog >actual && + test_cmp expect actual +' + test_expect_success 'setup more commits' ' test_commit "message one" one one message-one && test_commit "message two" two two message-two && -- cgit v1.2.3 From 0df621172d830adf36d4226b98f9cf4006d183a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= <l.s.r@web.de> Date: Tue, 19 Nov 2019 16:51:21 -0800 Subject: pretty: provide short date format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the placeholders %as and %cs to format author date and committer date, respectively, without the time part, like --date=short does, i.e. like YYYY-MM-DD. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- Documentation/pretty-formats.txt | 2 ++ pretty.c | 3 +++ t/t4205-log-pretty-formats.sh | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index fdccfe5b03..34bbc39273 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -169,6 +169,7 @@ The placeholders are: '%at':: author date, UNIX timestamp '%ai':: author date, ISO 8601-like format '%aI':: author date, strict ISO 8601 format +'%as':: author date, short format (`YYYY-MM-DD`) '%cn':: committer name '%cN':: committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) @@ -181,6 +182,7 @@ The placeholders are: '%ct':: committer date, UNIX timestamp '%ci':: committer date, ISO 8601-like format '%cI':: committer date, strict ISO 8601 format +'%cs':: committer date, short format (`YYYY-MM-DD`) '%d':: ref names, like the --decorate option of linkgit:git-log[1] '%D':: ref names without the " (", ")" wrapping. '%S':: ref name given on the command line by which the commit was reached diff --git a/pretty.c b/pretty.c index da154affd4..61014cc25a 100644 --- a/pretty.c +++ b/pretty.c @@ -731,6 +731,9 @@ static size_t format_person_part(struct strbuf *sb, char part, case 'I': /* date, ISO 8601 strict */ strbuf_addstr(sb, show_ident_date(&s, DATE_MODE(ISO8601_STRICT))); return placeholder_len; + case 's': + strbuf_addstr(sb, show_ident_date(&s, DATE_MODE(SHORT))); + return placeholder_len; } skip: diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index 0335b428b1..da9cacffea 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -533,6 +533,12 @@ test_expect_success 'ISO and ISO-strict date formats display the same values' ' test_cmp expected actual ' +test_expect_success 'short date' ' + git log --format=%ad%n%cd --date=short >expected && + git log --format=%as%n%cs >actual && + test_cmp expected actual +' + # get new digests (with no abbreviations) test_expect_success 'set up log decoration tests' ' head1=$(git rev-parse --verify HEAD~0) && -- cgit v1.2.3 From 618a855083fbd3b8f9491ec8b32b39bdea91868d Mon Sep 17 00:00:00 2001 From: Denton Liu <liu.denton@gmail.com> Date: Tue, 19 Nov 2019 16:51:23 -0800 Subject: pretty: add struct cmt_fmt_map::default_date_mode_type In a future commit, we plan on having a pretty format which will use a default date format unless otherwise overidden. Add support for this by adding a `default_date_mode_type` member in `struct cmt_fmt_map`. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- pretty.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pretty.c b/pretty.c index 61014cc25a..63fa600276 100644 --- a/pretty.c +++ b/pretty.c @@ -20,6 +20,7 @@ static struct cmt_fmt_map { int is_tformat; int expand_tabs_in_log; int is_alias; + enum date_mode_type default_date_mode_type; const char *user_format; } *commit_formats; static size_t builtin_formats_len; @@ -181,6 +182,8 @@ void get_commit_format(const char *arg, struct rev_info *rev) rev->commit_format = commit_format->format; rev->use_terminator = commit_format->is_tformat; rev->expand_tabs_in_log_default = commit_format->expand_tabs_in_log; + if (!rev->date_mode_explicit && commit_format->default_date_mode_type) + rev->date_mode.type = commit_format->default_date_mode_type; if (commit_format->format == CMIT_FMT_USERFORMAT) { save_user_format(rev, commit_format->user_format, commit_format->is_tformat); -- cgit v1.2.3 From 1f0fc1db8599f87520494ca4f0e3c1b6fabdf997 Mon Sep 17 00:00:00 2001 From: Denton Liu <liu.denton@gmail.com> Date: Tue, 19 Nov 2019 16:51:25 -0800 Subject: pretty: implement 'reference' format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The standard format for referencing other commits within some projects (such as git.git) is the reference format. This is described in Documentation/SubmittingPatches as If you want to reference a previous commit in the history of a stable branch, use the format "abbreviated hash (subject, date)", like this: .... Commit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30) noticed that ... .... Since this format is so commonly used, standardize it as a pretty format. The tests that are implemented essentially show that the format-string does not change in response to various log options. This is useful because, for future developers, it shows that we've considered the limitations of the "canned format-string" approach and we are fine with them. Based-on-a-patch-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- Documentation/pretty-formats.txt | 11 +++++++++ Documentation/pretty-options.txt | 2 +- Documentation/rev-list-options.txt | 4 +++- contrib/completion/git-completion.bash | 2 +- pretty.c | 4 +++- t/t4205-log-pretty-formats.sh | 43 ++++++++++++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 4 deletions(-) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index 34bbc39273..0df418e609 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -63,6 +63,17 @@ This is designed to be as compact as possible. <full commit message> +* 'reference' + + <abbrev hash> (<title line>, <short author date>) ++ +This format is used to refer to another commit in a commit message and +is the same as `--pretty='format:%C(auto)%h (%s, %ad)'`. By default, +the date is formatted with `--date=short` unless another `--date` option +is explicitly specified. As with any `format:` with format +placeholders, its output is not affected by other options like +`--decorate` and `--walk-reflogs`. + * 'email' From <hash> <date> diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt index e44fc8f738..a59426eefd 100644 --- a/Documentation/pretty-options.txt +++ b/Documentation/pretty-options.txt @@ -3,7 +3,7 @@ Pretty-print the contents of the commit logs in a given format, where '<format>' can be one of 'oneline', 'short', 'medium', - 'full', 'fuller', 'email', 'raw', 'format:<string>' + 'full', 'fuller', 'reference', 'email', 'raw', 'format:<string>' and 'tformat:<string>'. When '<format>' is none of the above, and has '%placeholder' in it, it acts as if '--pretty=tformat:<format>' were given. diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index bb1251c036..b94ed85c7a 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -269,7 +269,7 @@ list. exclude (that is, '{caret}commit', 'commit1..commit2', and 'commit1\...commit2' notations cannot be used). + -With `--pretty` format other than `oneline` (for obvious reasons), +With `--pretty` format other than `oneline` and `reference` (for obvious reasons), this causes the output to have two extra lines of information taken from the reflog. The reflog designator in the output may be shown as `ref@{Nth}` (where `Nth` is the reverse-chronological index in the @@ -293,6 +293,8 @@ Under `--pretty=oneline`, the commit message is prefixed with this information on the same line. This option cannot be combined with `--reverse`. See also linkgit:git-reflog[1]. ++ +Under `--pretty=reference`, this information will not be shown at all. --merge:: After a failed merge, show refs that touch files having a diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 6bf91ab154..889e707a05 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1737,7 +1737,7 @@ __git_log_shortlog_options=" --all-match --invert-grep " -__git_log_pretty_formats="oneline short medium full fuller email raw format: tformat: mboxrd" +__git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd" __git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:" _git_log () diff --git a/pretty.c b/pretty.c index 63fa600276..5fc8b730d8 100644 --- a/pretty.c +++ b/pretty.c @@ -98,7 +98,9 @@ static void setup_commit_formats(void) { "mboxrd", CMIT_FMT_MBOXRD, 0, 0 }, { "fuller", CMIT_FMT_FULLER, 0, 8 }, { "full", CMIT_FMT_FULL, 0, 8 }, - { "oneline", CMIT_FMT_ONELINE, 1, 0 } + { "oneline", CMIT_FMT_ONELINE, 1, 0 }, + { "reference", CMIT_FMT_USERFORMAT, 1, 0, + 0, DATE_SHORT, "%C(auto)%h (%s, %ad)" }, /* * Please update $__git_log_pretty_formats in * git-completion.bash when you add new formats. diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index da9cacffea..a8ef3784cf 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -824,4 +824,47 @@ test_expect_success '%S in git log --format works with other placeholders (part test_cmp expect actual ' +test_expect_success 'log --pretty=reference' ' + git log --pretty="tformat:%h (%s, %as)" >expect && + git log --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference with log.date is overridden by short date' ' + git log --pretty="tformat:%h (%s, %as)" >expect && + test_config log.date rfc && + git log --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference with explicit date overrides short date' ' + git log --date=rfc --pretty="tformat:%h (%s, %ad)" >expect && + git log --date=rfc --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference is never unabbreviated' ' + git log --pretty="tformat:%h (%s, %as)" >expect && + git log --no-abbrev-commit --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference is never decorated' ' + git log --pretty="tformat:%h (%s, %as)" >expect && + git log --decorate=short --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference does not output reflog info' ' + git log --walk-reflogs --pretty="tformat:%h (%s, %as)" >expect && + git log --walk-reflogs --pretty=reference >actual && + test_cmp expect actual +' + +test_expect_success 'log --pretty=reference is colored appropriately' ' + git log --color=always --pretty="tformat:%C(auto)%h (%s, %as)" >expect && + git log --color=always --pretty=reference >actual && + test_cmp expect actual +' + test_done -- cgit v1.2.3 From 3798149a74f0c2b84b42b108b4fc6ce28c6ab023 Mon Sep 17 00:00:00 2001 From: Denton Liu <liu.denton@gmail.com> Date: Tue, 19 Nov 2019 16:51:28 -0800 Subject: SubmittingPatches: use `--pretty=reference` Since Git was taught the `--pretty=reference` option, it is no longer necessary to manually specify the format string to get the commit reference. Teach users to use the new option while keeping the old invocation around in case they have an older version of Git. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> --- Documentation/SubmittingPatches | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index a1aad13384..af9fb356ca 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -153,6 +153,12 @@ The "Copy commit summary" command of gitk can be used to obtain this format (with the subject enclosed in a pair of double-quotes), or this invocation of `git show`: +.... + git show -s --pretty=reference <commit> +.... + +or, on an older version of Git without support for --pretty=reference: + .... git show -s --date=short --pretty='format:%h (%s, %ad)' <commit> .... -- cgit v1.2.3