{"thread":{"id":"63035","subject":"[PATCH 0/7] Add Format Specifier for Blame","startedAt":"2025-03-01T21:47:22Z","lastAt":"2025-03-01T21:47:33Z","messageCount":8,"participants":["Aleks Todorov"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"513346","messageId":"20250301214652.536439-1-aleks.todorov.1337@gmail.com","threadId":"63035","inReplyTo":null,"subject":"[PATCH 0/7] Add Format Specifier for Blame","fromName":"Aleks Todorov","fromEmail":"aleks.todorov.1337@gmail.com","sentAt":"2025-03-01T21:44:59Z","receivedAt":"2025-03-01T21:47:22Z","isPatch":true,"sender":{"key":"aleks.todorov.1337@gmail.com","avatar":null},"body":"Hi,\n\nAs previously discussed, this patch series implements a `--format`\noption for `git-blame`, re-using the existing implementation from\n`git-log`.\n\nMy motivation for this is that I use git blame quite often when\ndebugging, and find myself checking the commit subject for a large\nnumber of lines that I look at. Instead, it would speed up my workflow\nif I could see the commit subject next to each line in the blame output.\n\nSince this is a personal preference and each git user probably has their\nown personal preference for what kind of output they want to see, as per\nJunio's suggestion, by implementing a generic format option, we serve a\nvariety of use cases all at the same time.\n\nFor context, we can now use a command like:\n\n  git blame builtin/blame.c -F '%h %<(17,trunc)%F (%<(20,trunc)%an %ai %>(4)%L) '\n\nto see output like:\n\n  df8738116f7 builtin/blame.c   (Ævar Arnfjörð Bjar.. 2022-10-13 17:39:20 +0200   40) static char annotate_usage[] = N_(\"git annotate [<options>] [<rev-opts>] [<rev>] [--] <file>\");\n  5817da01434 builtin-blame.c   (Pierre Habouzit      2008-07-08 15:19:34 +0200   41)\n  5817da01434 builtin-blame.c   (Pierre Habouzit      2008-07-08 15:19:34 +0200   42) static const char *blame_opt_usage[] = {\n  5817da01434 builtin-blame.c   (Pierre Habouzit      2008-07-08 15:19:34 +0200   43)     blame_usage,\n  5817da01434 builtin-blame.c   (Pierre Habouzit      2008-07-08 15:19:34 +0200   44)     \"\",\n\nHowever, one key feature I could not find an easy way to implement was\nto include a length specifier that auto-detects the minimum column width\nrequired to display a placeholder without trimming the output. As a\nresult, I could not re-implement the existing options using the\nformatting syntax.\n\nNevertheless, these patches serve my purpose, are self-contained, and\ncould be extended in the future to complete the plan.\n\nI've made my best effort to include clear atomic commits, write\nconforming code, include tests, and add documentation. However, as this\nis my first submission here, I expect that I may have missed something -\nso please let me know what can be improved and whether this patch series\nis suitable for integration.\n\nA short logical summary of the patches:\n\n  1. Add --format / -F option\n  2. Add format config option\n  3. Add %F and %L format specifiers (blame-only) to allow the filename\n     and line number to be emitted\n  4. Call into pretty.c to expand the provided format string\n  5. Add tests\n  6. Refactor documentation structure\n  7. Add documentation specific to `git blame --format`\n\nPatches are based on main.\n\nThanks,\nAleks\n\nAleks Todorov (7):\n  builtin/blame: Accept a user-specified format\n  builtin/blame: Add blame.format config option\n  pretty: Add F and L format specifiers\n  builtin/blame: Expand format when available\n  t8015: Add tests for git blame -F\n  Documentation: Move placeholders to separate file\n  Documentation: Add docs for blame format\n\n Documentation/config/blame.adoc   |   5 +\n Documentation/git-blame.adoc      |  16 ++\n Documentation/placeholders.adoc   | 242 ++++++++++++++++++++++++++++++\n Documentation/pretty-formats.adoc | 239 +----------------------------\n builtin/blame.c                   | 119 +++++++++------\n pretty.c                          |  14 ++\n pretty.h                          |   5 +\n t/meson.build                     |   1 +\n t/t8015-blame-format.sh           |  39 +++++\n 9 files changed, 395 insertions(+), 285 deletions(-)\n create mode 100644 Documentation/placeholders.adoc\n create mode 100755 t/t8015-blame-format.sh\n\n-- \n2.43.0\n\n"},{"id":"513347","messageId":"20250301214652.536439-2-aleks.todorov.1337@gmail.com","threadId":"63035","inReplyTo":"20250301214652.536439-1-aleks.todorov.1337@gmail.com","subject":"[PATCH 1/7] builtin/blame: Accept a user-specified format","fromName":"Aleks Todorov","fromEmail":"aleks.todorov.1337@gmail.com","sentAt":"2025-03-01T21:45:00Z","receivedAt":"2025-03-01T21:47:24Z","isPatch":true,"sender":{"key":"aleks.todorov.1337@gmail.com","avatar":null},"body":"Add a --format / -F option to `git-blame` which allows the user to\nprovide a string with placeholders which will be expanded to include\ncustom information in the blame output.\n\nSigned-off-by: Aleks Todorov <aleks.todorov.1337@gmail.com>\n---\n builtin/blame.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex c470654c7e..437ac8bd73 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -66,6 +66,7 @@ static int xdl_opts;\n static int abbrev = -1;\n static int no_whole_file_rename;\n static int show_progress;\n+static char *format = NULL;\n static char repeated_meta_color[COLOR_MAXLEN];\n static int coloring_mode;\n static struct string_list ignore_revs_file_list = STRING_LIST_INIT_DUP;\n@@ -905,6 +906,7 @@ int cmd_blame(int argc,\n \t\tOPT_BIT('t', NULL, &output_option, N_(\"show raw timestamp (Default: off)\"), OUTPUT_RAW_TIMESTAMP),\n \t\tOPT_BIT('l', NULL, &output_option, N_(\"show long commit SHA1 (Default: off)\"), OUTPUT_LONG_OBJECT_NAME),\n \t\tOPT_BIT('s', NULL, &output_option, N_(\"suppress author name and timestamp (Default: off)\"), OUTPUT_NO_AUTHOR),\n+\t\tOPT_STRING('F', \"format\", &format, N_(\"format\"), N_(\"print blame entries in the given <format>\")),\n \t\tOPT_BIT('e', \"show-email\", &output_option, N_(\"show author email instead of name (Default: off)\"), OUTPUT_SHOW_EMAIL),\n \t\tOPT_BIT('w', NULL, &xdl_opts, N_(\"ignore whitespace differences\"), XDF_IGNORE_WHITESPACE),\n \t\tOPT_STRING_LIST(0, \"ignore-rev\", &ignore_rev_list, N_(\"rev\"), N_(\"ignore <rev> when blaming\")),\n-- \n2.43.0\n\n"},{"id":"513348","messageId":"20250301214652.536439-3-aleks.todorov.1337@gmail.com","threadId":"63035","inReplyTo":"20250301214652.536439-1-aleks.todorov.1337@gmail.com","subject":"[PATCH 2/7] builtin/blame: Add blame.format config option","fromName":"Aleks Todorov","fromEmail":"aleks.todorov.1337@gmail.com","sentAt":"2025-03-01T21:45:01Z","receivedAt":"2025-03-01T21:47:26Z","isPatch":true,"sender":{"key":"aleks.todorov.1337@gmail.com","avatar":null},"body":"Source the format string from the user's configuration for convenience,\nin place of the \"-F\" option.\n\nSigned-off-by: Aleks Todorov <aleks.todorov.1337@gmail.com>\n---\n builtin/blame.c | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 437ac8bd73..891ac017f7 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -772,6 +772,11 @@ static int git_blame_config(const char *var, const char *value,\n \t\t}\n \t}\n \n+\tif (!strcmp(var, \"blame.format\")) {\n+\t\tgit_config_string(&format, var, value);\n+\t\treturn 0;\n+\t}\n+\n \tif (git_diff_heuristic_config(var, value, cb) < 0)\n \t\treturn -1;\n \tif (userdiff_config(var, value) < 0)\n-- \n2.43.0\n\n"},{"id":"513349","messageId":"20250301214652.536439-4-aleks.todorov.1337@gmail.com","threadId":"63035","inReplyTo":"20250301214652.536439-1-aleks.todorov.1337@gmail.com","subject":"[PATCH 3/7] pretty: Add F and L format specifiers","fromName":"Aleks Todorov","fromEmail":"aleks.todorov.1337@gmail.com","sentAt":"2025-03-01T21:45:02Z","receivedAt":"2025-03-01T21:47:27Z","isPatch":true,"sender":{"key":"aleks.todorov.1337@gmail.com","avatar":null},"body":"Add the F (filename) and L (line number) format specifiers. These are to\nbe used with blame only and therefore only work with blame.\n\nSigned-off-by: Aleks Todorov <aleks.todorov.1337@gmail.com>\n---\n pretty.c | 14 ++++++++++++++\n pretty.h |  5 +++++\n 2 files changed, 19 insertions(+)\n\ndiff --git a/pretty.c b/pretty.c\nindex 0bc8ad8a9a..d2b7284854 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1446,6 +1446,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */\n \tconst char *arg, *eol;\n \tsize_t res;\n \tchar **slot;\n+\tchar line_number[16];\n \n \t/* these are independent of the commit */\n \tres = strbuf_expand_literal(sb, placeholder);\n@@ -1549,6 +1550,19 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */\n \tif (!commit->object.parsed)\n \t\tparse_object(the_repository, &commit->object.oid);\n \n+\tif (c->pretty_ctx->is_blame) {\n+\t\tswitch (placeholder[0]) {\n+\t\tcase 'F':\t\t/* filename */\n+\t\t\tstrbuf_addstr(sb, c->pretty_ctx->filename);\n+\t\t\treturn 1;\n+\t\tcase 'L':\t\t/* line number */\n+\t\t\tsnprintf(line_number, sizeof(line_number), \"%zu\",\n+\t\t\t\t c->pretty_ctx->line);\n+\t\t\tstrbuf_addstr(sb, line_number);\n+\t\t\treturn 1;\n+\t\t}\n+\t}\n+\n \tswitch (placeholder[0]) {\n \tcase 'H':\t\t/* commit hash */\n \t\tstrbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_COMMIT));\ndiff --git a/pretty.h b/pretty.h\nindex df267afe4a..eb54070ecb 100644\n--- a/pretty.h\n+++ b/pretty.h\n@@ -51,6 +51,11 @@ struct pretty_print_context {\n \tunsigned encode_email_headers:1;\n \tstruct pretty_print_describe_status *describe_status;\n \n+\t/* Blame fields */\n+\tbool is_blame;\n+\tconst char *filename;\n+\tsize_t line;\n+\n \t/*\n \t * Fields below here are manipulated internally by pp_* functions and\n \t * should not be counted on by callers.\n-- \n2.43.0\n\n"},{"id":"513350","messageId":"20250301214652.536439-5-aleks.todorov.1337@gmail.com","threadId":"63035","inReplyTo":"20250301214652.536439-1-aleks.todorov.1337@gmail.com","subject":"[PATCH 4/7] builtin/blame: Expand format when available","fromName":"Aleks Todorov","fromEmail":"aleks.todorov.1337@gmail.com","sentAt":"2025-03-01T21:45:03Z","receivedAt":"2025-03-01T21:47:28Z","isPatch":true,"sender":{"key":"aleks.todorov.1337@gmail.com","avatar":null},"body":"When the user-specified format string is available, expand the string by\nfilling in the details and emit.\n\nWe can therefore now emulate the default format with the following\ncommand:\n\n  git blame builtin/blame.c -F '%h %<(17,trunc)%F (%<(20,trunc)%an %ai %>(4)%L) '\n\nSigned-off-by: Aleks Todorov <aleks.todorov.1337@gmail.com>\n---\n builtin/blame.c | 112 ++++++++++++++++++++++++++++--------------------\n 1 file changed, 65 insertions(+), 47 deletions(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 891ac017f7..d2b605f7a9 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -489,63 +489,81 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int\n \t\tif (color)\n \t\t\tfputs(color, stdout);\n \n-\t\tif (suspect->commit->object.flags & UNINTERESTING) {\n-\t\t\tif (blank_boundary) {\n-\t\t\t\tmemset(hex, ' ', strlen(hex));\n-\t\t\t} else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) {\n-\t\t\t\tlength--;\n-\t\t\t\tputchar('^');\n-\t\t\t}\n-\t\t}\n-\n-\t\tif (mark_unblamable_lines && ent->unblamable) {\n-\t\t\tlength--;\n-\t\t\tputchar('*');\n-\t\t}\n-\t\tif (mark_ignored_lines && ent->ignored) {\n-\t\t\tlength--;\n-\t\t\tputchar('?');\n-\t\t}\n-\n-\t\tprintf(\"%.*s\", (int)(length < GIT_MAX_HEXSZ ? length : GIT_MAX_HEXSZ), hex);\n-\t\tif (opt & OUTPUT_ANNOTATE_COMPAT) {\n-\t\t\tconst char *name;\n-\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n-\t\t\t\tname = ci.author_mail.buf;\n-\t\t\telse\n-\t\t\t\tname = ci.author.buf;\n-\t\t\tprintf(\"\\t(%10s\\t%10s\\t%d)\", name,\n-\t\t\t       format_time(ci.author_time, ci.author_tz.buf,\n-\t\t\t\t\t   show_raw_time),\n-\t\t\t       ent->lno + 1 + cnt);\n+\t\tif (format) {\n+\t\t\tstruct strbuf sb = STRBUF_INIT;\n+\t\t\tstruct pretty_print_context context = {\n+\t\t\t\t.fmt = CMIT_FMT_USERFORMAT,\n+\t\t\t\t.abbrev = abbrev,\n+\t\t\t\t.is_blame = true,\n+\t\t\t\t.filename = suspect->path,\n+\t\t\t\t.line = ent->lno + 1 + cnt,\n+\t\t\t};\n+\t\t\trepo_format_commit_message(the_repository,\n+\t\t\t\t\t\t   suspect->commit, format, &sb,\n+\t\t\t\t\t\t   &context);\n+\t\t\tprintf(\"%s\", sb.buf);\n+\t\t\tstrbuf_release(&sb);\n \t\t} else {\n-\t\t\tif (opt & OUTPUT_SHOW_SCORE)\n-\t\t\t\tprintf(\" %*d %02d\",\n-\t\t\t\t       max_score_digits, ent->score,\n-\t\t\t\t       ent->suspect->refcnt);\n-\t\t\tif (opt & OUTPUT_SHOW_NAME)\n-\t\t\t\tprintf(\" %-*.*s\", longest_file, longest_file,\n-\t\t\t\t       suspect->path);\n-\t\t\tif (opt & OUTPUT_SHOW_NUMBER)\n-\t\t\t\tprintf(\" %*d\", max_orig_digits,\n-\t\t\t\t       ent->s_lno + 1 + cnt);\n+\t\t\tif (suspect->commit->object.flags & UNINTERESTING) {\n+\t\t\t\tif (blank_boundary) {\n+\t\t\t\t\tmemset(hex, ' ', strlen(hex));\n+\t\t\t\t} else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) {\n+\t\t\t\t\tlength--;\n+\t\t\t\t\tputchar('^');\n+\t\t\t\t}\n+\t\t\t}\n \n-\t\t\tif (!(opt & OUTPUT_NO_AUTHOR)) {\n+\t\t\tif (mark_unblamable_lines && ent->unblamable) {\n+\t\t\t\tlength--;\n+\t\t\t\tputchar('*');\n+\t\t\t}\n+\t\t\tif (mark_ignored_lines && ent->ignored) {\n+\t\t\t\tlength--;\n+\t\t\t\tputchar('?');\n+\t\t\t}\n+\n+\t\t\tprintf(\"%.*s\",\n+\t\t\t       (int)(length < GIT_MAX_HEXSZ ? length :\n+\t\t\t\t\t\t\t      GIT_MAX_HEXSZ),\n+\t\t\t       hex);\n+\t\t\tif (opt & OUTPUT_ANNOTATE_COMPAT) {\n \t\t\t\tconst char *name;\n-\t\t\t\tint pad;\n \t\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n \t\t\t\t\tname = ci.author_mail.buf;\n \t\t\t\telse\n \t\t\t\t\tname = ci.author.buf;\n-\t\t\t\tpad = longest_author - utf8_strwidth(name);\n-\t\t\t\tprintf(\" (%s%*s %10s\",\n-\t\t\t\t       name, pad, \"\",\n+\t\t\t\tprintf(\"\\t(%10s\\t%10s\\t%d)\", name,\n \t\t\t\t       format_time(ci.author_time,\n \t\t\t\t\t\t   ci.author_tz.buf,\n-\t\t\t\t\t\t   show_raw_time));\n+\t\t\t\t\t\t   show_raw_time),\n+\t\t\t\t       ent->lno + 1 + cnt);\n+\t\t\t} else {\n+\t\t\t\tif (opt & OUTPUT_SHOW_SCORE)\n+\t\t\t\t\tprintf(\" %*d %02d\", max_score_digits,\n+\t\t\t\t\t       ent->score, ent->suspect->refcnt);\n+\t\t\t\tif (opt & OUTPUT_SHOW_NAME)\n+\t\t\t\t\tprintf(\" %-*.*s\", longest_file,\n+\t\t\t\t\t       longest_file, suspect->path);\n+\t\t\t\tif (opt & OUTPUT_SHOW_NUMBER)\n+\t\t\t\t\tprintf(\" %*d\", max_orig_digits,\n+\t\t\t\t\t       ent->s_lno + 1 + cnt);\n+\n+\t\t\t\tif (!(opt & OUTPUT_NO_AUTHOR)) {\n+\t\t\t\t\tconst char *name;\n+\t\t\t\t\tint pad;\n+\t\t\t\t\tif (opt & OUTPUT_SHOW_EMAIL)\n+\t\t\t\t\t\tname = ci.author_mail.buf;\n+\t\t\t\t\telse\n+\t\t\t\t\t\tname = ci.author.buf;\n+\t\t\t\t\tpad = longest_author -\n+\t\t\t\t\t      utf8_strwidth(name);\n+\t\t\t\t\tprintf(\" (%s%*s %10s\", name, pad, \"\",\n+\t\t\t\t\t       format_time(ci.author_time,\n+\t\t\t\t\t\t\t   ci.author_tz.buf,\n+\t\t\t\t\t\t\t   show_raw_time));\n+\t\t\t\t}\n+\t\t\t\tprintf(\" %*d) \", max_digits, ent->lno + 1 + cnt);\n \t\t\t}\n-\t\t\tprintf(\" %*d) \",\n-\t\t\t       max_digits, ent->lno + 1 + cnt);\n \t\t}\n \t\tif (reset)\n \t\t\tfputs(reset, stdout);\n-- \n2.43.0\n\n"},{"id":"513351","messageId":"20250301214652.536439-6-aleks.todorov.1337@gmail.com","threadId":"63035","inReplyTo":"20250301214652.536439-1-aleks.todorov.1337@gmail.com","subject":"[PATCH 5/7] t8015: Add tests for git blame -F","fromName":"Aleks Todorov","fromEmail":"aleks.todorov.1337@gmail.com","sentAt":"2025-03-01T21:45:04Z","receivedAt":"2025-03-01T21:47:30Z","isPatch":true,"sender":{"key":"aleks.todorov.1337@gmail.com","avatar":null},"body":"Include three tests, testing each facet of the implementation:\n\n  - an empty format test to confirm that the flag is available and\n    correctly hooked into git (respects empty format and does not emit\n    any blame metadata)\n\n  - a default format test to confirm that both the existing log\n    specifiers and the new blame-specific specifiers %F and %L are\n    expanded as expected\n\n  - a config test to confirm that the blame.format config is available\n    under the correct name and used by the program\n\nSigned-off-by: Aleks Todorov <aleks.todorov.1337@gmail.com>\n---\n t/meson.build           |  1 +\n t/t8015-blame-format.sh | 39 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 40 insertions(+)\n create mode 100755 t/t8015-blame-format.sh\n\ndiff --git a/t/meson.build b/t/meson.build\nindex 780939d49f..da798fbc88 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -958,6 +958,7 @@ integration_tests = [\n   't8012-blame-colors.sh',\n   't8013-blame-ignore-revs.sh',\n   't8014-blame-ignore-fuzzy.sh',\n+  't8015-blame-format.sh',\n   't9001-send-email.sh',\n   't9002-column.sh',\n   't9003-help-autocorrect.sh',\ndiff --git a/t/t8015-blame-format.sh b/t/t8015-blame-format.sh\nnew file mode 100755\nindex 0000000000..8d05310d5d\n--- /dev/null\n+++ b/t/t8015-blame-format.sh\n@@ -0,0 +1,39 @@\n+#!/bin/sh\n+\n+test_description='git blame -F option'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\techo line1 >file &&\n+\tgit add file &&\n+\tgit commit -m commit1 &&\n+\techo line2 >>file &&\n+\tgit add file &&\n+\tgit commit -m commit2 &&\n+\tshortId1=$(git rev-parse HEAD^ | cut -c 1-8) &&\n+\tshortId2=$(git rev-parse HEAD | cut -c 1-8)\n+'\n+\n+test_expect_success 'empty format' '\n+\techo \"line1\\nline2\" >expect &&\n+\tgit blame file -F \"\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'default format' '\n+\techo \"$shortId1 file (A U Thor 2005-04-01 13:14:15 +0200 1) line1\" >expect &&\n+\techo \"$shortId2 file (A U Thor 2005-04-01 13:14:15 +0200 2) line2\" >>expect &&\n+\tgit blame file -F \"%h %F (%an %ai %L) \" >/tmp/actual &&\n+\ttest_cmp expect /tmp/actual\n+'\n+\n+test_expect_success 'blame.format config' '\n+\techo \"$shortId1 file (A U Thor 2005-04-01 13:14:15 +0200 1) line1\" >expect &&\n+\techo \"$shortId2 file (A U Thor 2005-04-01 13:14:15 +0200 2) line2\" >>expect &&\n+\tgit config blame.format \"%h %F (%an %ai %L) \" &&\n+\tgit blame file >/tmp/actual &&\n+\ttest_cmp expect /tmp/actual\n+'\n+\n+test_done\n-- \n2.43.0\n\n"},{"id":"513352","messageId":"20250301214652.536439-7-aleks.todorov.1337@gmail.com","threadId":"63035","inReplyTo":"20250301214652.536439-1-aleks.todorov.1337@gmail.com","subject":"[PATCH 6/7] Documentation: Move placeholders to separate file","fromName":"Aleks Todorov","fromEmail":"aleks.todorov.1337@gmail.com","sentAt":"2025-03-01T21:45:05Z","receivedAt":"2025-03-01T21:47:31Z","isPatch":true,"sender":{"key":"aleks.todorov.1337@gmail.com","avatar":null},"body":"Move formatting placeholders to a separate file so they can be included\nby multiple commands. In particular, git-blame will also need to include\nthe placeholder docs for the new --format option.\n\nSigned-off-by: Aleks Todorov <aleks.todorov.1337@gmail.com>\n---\n Documentation/placeholders.adoc   | 238 +++++++++++++++++++++++++++++\n Documentation/pretty-formats.adoc | 239 +-----------------------------\n 2 files changed, 239 insertions(+), 238 deletions(-)\n create mode 100644 Documentation/placeholders.adoc\n\ndiff --git a/Documentation/placeholders.adoc b/Documentation/placeholders.adoc\nnew file mode 100644\nindex 0000000000..7f4d0b59c7\n--- /dev/null\n+++ b/Documentation/placeholders.adoc\n@@ -0,0 +1,238 @@\n+The placeholders are:\n+\n+- Placeholders that expand to a single literal character:\n+'%n':: newline\n+'%%':: a raw '%'\n+'%x00':: '%x' followed by two hexadecimal digits is replaced with a\n+\t byte with the hexadecimal digits' value (we will call this\n+\t \"literal formatting code\" in the rest of this document).\n+\n+- Placeholders that affect formatting of later placeholders:\n+'%Cred':: switch color to red\n+'%Cgreen':: switch color to green\n+'%Cblue':: switch color to blue\n+'%Creset':: reset color\n+'%C(...)':: color specification, as described under Values in the\n+\t    \"CONFIGURATION FILE\" section of linkgit:git-config[1].  By\n+\t    default, colors are shown only when enabled for log output\n+\t    (by `color.diff`, `color.ui`, or `--color`, and respecting\n+\t    the `auto` settings of the former if we are going to a\n+\t    terminal). `%C(auto,...)` is accepted as a historical\n+\t    synonym for the default (e.g., `%C(auto,red)`). Specifying\n+\t    `%C(always,...)` will show the colors even when color is\n+\t    not otherwise enabled (though consider just using\n+\t    `--color=always` to enable color for the whole output,\n+\t    including this format and anything else git might color).\n+\t    `auto` alone (i.e. `%C(auto)`) will turn on auto coloring\n+\t    on the next placeholders until the color is switched\n+\t    again.\n+'%m':: left (`<`), right (`>`) or boundary (`-`) mark\n+'%w([<w>[,<i1>[,<i2>]]])':: switch line wrapping, like the -w option of\n+\t\t\t    linkgit:git-shortlog[1].\n+'%<( <N> [,trunc|ltrunc|mtrunc])':: make the next placeholder take at\n+\t\t\t\t  least N column widths, padding spaces on\n+\t\t\t\t  the right if necessary.  Optionally\n+\t\t\t\t  truncate (with ellipsis '..') at the left (ltrunc) `..ft`,\n+\t\t\t\t  the middle (mtrunc) `mi..le`, or the end\n+\t\t\t\t  (trunc) `rig..`, if the output is longer than\n+\t\t\t\t  N columns.\n+\t\t\t\t  Note 1: that truncating\n+\t\t\t\t  only works correctly with N >= 2.\n+\t\t\t\t  Note 2: spaces around the N and M (see below)\n+\t\t\t\t  values are optional.\n+\t\t\t\t  Note 3: Emojis and other wide characters\n+\t\t\t\t  will take two display columns, which may\n+\t\t\t\t  over-run column boundaries.\n+\t\t\t\t  Note 4: decomposed character combining marks\n+\t\t\t\t  may be misplaced at padding boundaries.\n+'%<|( <M> )':: make the next placeholder take at least until Mth\n+\t     display column, padding spaces on the right if necessary.\n+\t     Use negative M values for column positions measured\n+\t     from the right hand edge of the terminal window.\n+'%>( <N> )', '%>|( <M> )':: similar to '%<( <N> )', '%<|( <M> )' respectively,\n+\t\t\tbut padding spaces on the left\n+'%>>( <N> )', '%>>|( <M> )':: similar to '%>( <N> )', '%>|( <M> )'\n+\t\t\t  respectively, except that if the next\n+\t\t\t  placeholder takes more spaces than given and\n+\t\t\t  there are spaces on its left, use those\n+\t\t\t  spaces\n+'%><( <N> )', '%><|( <M> )':: similar to '%<( <N> )', '%<|( <M> )'\n+\t\t\t  respectively, but padding both sides\n+\t\t\t  (i.e. the text is centered)\n+\n+- Placeholders that expand to information extracted from the commit:\n+'%H':: commit hash\n+'%h':: abbreviated commit hash\n+'%T':: tree hash\n+'%t':: abbreviated tree hash\n+'%P':: parent hashes\n+'%p':: abbreviated parent hashes\n+'%an':: author name\n+'%aN':: author name (respecting .mailmap, see linkgit:git-shortlog[1]\n+\tor linkgit:git-blame[1])\n+'%ae':: author email\n+'%aE':: author email (respecting .mailmap, see linkgit:git-shortlog[1]\n+\tor linkgit:git-blame[1])\n+'%al':: author email local-part (the part before the '@' sign)\n+'%aL':: author local-part (see '%al') respecting .mailmap, see\n+\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n+'%ad':: author date (format respects --date= option)\n+'%aD':: author date, RFC2822 style\n+'%ar':: author date, relative\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+'%ah':: author date, human style (like the `--date=human` option of\n+\tlinkgit:git-rev-list[1])\n+'%cn':: committer name\n+'%cN':: committer name (respecting .mailmap, see\n+\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n+'%ce':: committer email\n+'%cE':: committer email (respecting .mailmap, see\n+\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n+'%cl':: committer email local-part (the part before the '@' sign)\n+'%cL':: committer local-part (see '%cl') respecting .mailmap, see\n+\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n+'%cd':: committer date (format respects --date= option)\n+'%cD':: committer date, RFC2822 style\n+'%cr':: committer date, relative\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+'%ch':: committer date, human style (like the `--date=human` option of\n+\tlinkgit:git-rev-list[1])\n+'%d':: ref names, like the --decorate option of linkgit:git-log[1]\n+'%D':: ref names without the \" (\", \")\" wrapping.\n+'%(decorate[:<options>])'::\n+ref names with custom decorations. The `decorate` string may be followed by a\n+colon and zero or more comma-separated options. Option values may contain\n+literal formatting codes. These must be used for commas (`%x2C`) and closing\n+parentheses (`%x29`), due to their role in the option syntax.\n++\n+** 'prefix=<value>': Shown before the list of ref names.  Defaults to \"{nbsp}`(`\".\n+** 'suffix=<value>': Shown after the list of ref names.  Defaults to \"`)`\".\n+** 'separator=<value>': Shown between ref names.  Defaults to \"`,`{nbsp}\".\n+** 'pointer=<value>': Shown between HEAD and the branch it points to, if any.\n+\t\t      Defaults to \"{nbsp}`->`{nbsp}\".\n+** 'tag=<value>': Shown before tag names. Defaults to \"`tag:`{nbsp}\".\n+\n++\n+For example, to produce decorations with no wrapping\n+or tag annotations, and spaces as separators:\n++\n+`%(decorate:prefix=,suffix=,tag=,separator= )`\n+\n+'%(describe[:<options>])'::\n+human-readable name, like linkgit:git-describe[1]; empty string for\n+undescribable commits.  The `describe` string may be followed by a colon and\n+zero or more comma-separated options.  Descriptions can be inconsistent when\n+tags are added or removed at the same time.\n++\n+** 'tags[=<bool-value>]': Instead of only considering annotated tags,\n+   consider lightweight tags as well.\n+** 'abbrev=<number>': Instead of using the default number of hexadecimal digits\n+   (which will vary according to the number of objects in the repository with a\n+   default of 7) of the abbreviated object name, use <number> digits, or as many\n+   digits as needed to form a unique object name.\n+** 'match=<pattern>': Only consider tags matching the given\n+   `glob(7)` pattern, excluding the \"refs/tags/\" prefix.\n+** 'exclude=<pattern>': Do not consider tags matching the given\n+   `glob(7)` pattern, excluding the \"refs/tags/\" prefix.\n+\n+'%S':: ref name given on the command line by which the commit was reached\n+       (like `git log --source`), only works with `git log`\n+'%e':: encoding\n+'%s':: subject\n+'%f':: sanitized subject line, suitable for a filename\n+'%b':: body\n+'%B':: raw body (unwrapped subject and body)\n+ifndef::git-rev-list[]\n+'%N':: commit notes\n+endif::git-rev-list[]\n+'%GG':: raw verification message from GPG for a signed commit\n+'%G?':: show \"G\" for a good (valid) signature,\n+\t\"B\" for a bad signature,\n+\t\"U\" for a good signature with unknown validity,\n+\t\"X\" for a good signature that has expired,\n+\t\"Y\" for a good signature made by an expired key,\n+\t\"R\" for a good signature made by a revoked key,\n+\t\"E\" if the signature cannot be checked (e.g. missing key)\n+\tand \"N\" for no signature\n+'%GS':: show the name of the signer for a signed commit\n+'%GK':: show the key used to sign a signed commit\n+'%GF':: show the fingerprint of the key used to sign a signed commit\n+'%GP':: show the fingerprint of the primary key whose subkey was used\n+\tto sign a signed commit\n+'%GT':: show the trust level for the key used to sign a signed commit\n+'%gD':: reflog selector, e.g., `refs/stash@{1}` or `refs/stash@{2\n+\tminutes ago}`; the format follows the rules described for the\n+\t`-g` option. The portion before the `@` is the refname as\n+\tgiven on the command line (so `git log -g refs/heads/master`\n+\twould yield `refs/heads/master@{0}`).\n+'%gd':: shortened reflog selector; same as `%gD`, but the refname\n+\tportion is shortened for human readability (so\n+\t`refs/heads/master` becomes just `master`).\n+'%gn':: reflog identity name\n+'%gN':: reflog identity name (respecting .mailmap, see\n+\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n+'%ge':: reflog identity email\n+'%gE':: reflog identity email (respecting .mailmap, see\n+\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n+'%gs':: reflog subject\n+'%(trailers[:<options>])'::\n+display the trailers of the body as interpreted by\n+linkgit:git-interpret-trailers[1]. The `trailers` string may be followed by\n+a colon and zero or more comma-separated options. If any option is provided\n+multiple times, the last occurrence wins.\n++\n+** 'key=<key>': only show trailers with specified <key>. Matching is done\n+   case-insensitively and trailing colon is optional. If option is\n+   given multiple times trailer lines matching any of the keys are\n+   shown. This option automatically enables the `only` option so that\n+   non-trailer lines in the trailer block are hidden. If that is not\n+   desired it can be disabled with `only=false`.  E.g.,\n+   `%(trailers:key=Reviewed-by)` shows trailer lines with key\n+   `Reviewed-by`.\n+** 'only[=<bool>]': select whether non-trailer lines from the trailer\n+   block should be included.\n+** 'separator=<sep>': specify the separator inserted between trailer\n+   lines. Defaults to a line feed character. The string <sep> may contain\n+   the literal formatting codes described above. To use comma as\n+   separator one must use `%x2C` as it would otherwise be parsed as\n+   next option. E.g., `%(trailers:key=Ticket,separator=%x2C )`\n+   shows all trailer lines whose key is \"Ticket\" separated by a comma\n+   and a space.\n+** 'unfold[=<bool>]': make it behave as if interpret-trailer's `--unfold`\n+   option was given. E.g.,\n+   `%(trailers:only,unfold=true)` unfolds and shows all trailer lines.\n+** 'keyonly[=<bool>]': only show the key part of the trailer.\n+** 'valueonly[=<bool>]': only show the value part of the trailer.\n+** 'key_value_separator=<sep>': specify the separator inserted between\n+   the key and value of each trailer. Defaults to \": \". Otherwise it\n+   shares the same semantics as 'separator=<sep>' above.\n+\n+NOTE: Some placeholders may depend on other options given to the\n+revision traversal engine. For example, the `%g*` reflog options will\n+insert an empty string unless we are traversing reflog entries (e.g., by\n+`git log -g`). The `%d` and `%D` placeholders will use the \"short\"\n+decoration format if `--decorate` was not already provided on the command\n+line.\n+\n+The boolean options accept an optional value `[=<bool-value>]`. The\n+values taken by `--type=bool` git-config[1], like `yes` and `off`,\n+are all accepted.  Giving a boolean option without `=<value>` is\n+equivalent to giving it with `=true`.\n+\n+If you add a `+` (plus sign) after '%' of a placeholder, a line-feed\n+is inserted immediately before the expansion if and only if the\n+placeholder expands to a non-empty string.\n+\n+If you add a `-` (minus sign) after '%' of a placeholder, all consecutive\n+line-feeds immediately preceding the expansion are deleted if and only if the\n+placeholder expands to an empty string.\n+\n+If you add a ` ` (space) after '%' of a placeholder, a space\n+is inserted immediately before the expansion if and only if the\n+placeholder expands to a non-empty string.\ndiff --git a/Documentation/pretty-formats.adoc b/Documentation/pretty-formats.adoc\nindex 07475de8c3..68c0cebd26 100644\n--- a/Documentation/pretty-formats.adoc\n+++ b/Documentation/pretty-formats.adoc\n@@ -117,244 +117,7 @@ The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<\n \n -------\n +\n-The placeholders are:\n-\n-- Placeholders that expand to a single literal character:\n-'%n':: newline\n-'%%':: a raw '%'\n-'%x00':: '%x' followed by two hexadecimal digits is replaced with a\n-\t byte with the hexadecimal digits' value (we will call this\n-\t \"literal formatting code\" in the rest of this document).\n-\n-- Placeholders that affect formatting of later placeholders:\n-'%Cred':: switch color to red\n-'%Cgreen':: switch color to green\n-'%Cblue':: switch color to blue\n-'%Creset':: reset color\n-'%C(...)':: color specification, as described under Values in the\n-\t    \"CONFIGURATION FILE\" section of linkgit:git-config[1].  By\n-\t    default, colors are shown only when enabled for log output\n-\t    (by `color.diff`, `color.ui`, or `--color`, and respecting\n-\t    the `auto` settings of the former if we are going to a\n-\t    terminal). `%C(auto,...)` is accepted as a historical\n-\t    synonym for the default (e.g., `%C(auto,red)`). Specifying\n-\t    `%C(always,...)` will show the colors even when color is\n-\t    not otherwise enabled (though consider just using\n-\t    `--color=always` to enable color for the whole output,\n-\t    including this format and anything else git might color).\n-\t    `auto` alone (i.e. `%C(auto)`) will turn on auto coloring\n-\t    on the next placeholders until the color is switched\n-\t    again.\n-'%m':: left (`<`), right (`>`) or boundary (`-`) mark\n-'%w([<w>[,<i1>[,<i2>]]])':: switch line wrapping, like the -w option of\n-\t\t\t    linkgit:git-shortlog[1].\n-'%<( <N> [,trunc|ltrunc|mtrunc])':: make the next placeholder take at\n-\t\t\t\t  least N column widths, padding spaces on\n-\t\t\t\t  the right if necessary.  Optionally\n-\t\t\t\t  truncate (with ellipsis '..') at the left (ltrunc) `..ft`,\n-\t\t\t\t  the middle (mtrunc) `mi..le`, or the end\n-\t\t\t\t  (trunc) `rig..`, if the output is longer than\n-\t\t\t\t  N columns.\n-\t\t\t\t  Note 1: that truncating\n-\t\t\t\t  only works correctly with N >= 2.\n-\t\t\t\t  Note 2: spaces around the N and M (see below)\n-\t\t\t\t  values are optional.\n-\t\t\t\t  Note 3: Emojis and other wide characters\n-\t\t\t\t  will take two display columns, which may\n-\t\t\t\t  over-run column boundaries.\n-\t\t\t\t  Note 4: decomposed character combining marks\n-\t\t\t\t  may be misplaced at padding boundaries.\n-'%<|( <M> )':: make the next placeholder take at least until Mth\n-\t     display column, padding spaces on the right if necessary.\n-\t     Use negative M values for column positions measured\n-\t     from the right hand edge of the terminal window.\n-'%>( <N> )', '%>|( <M> )':: similar to '%<( <N> )', '%<|( <M> )' respectively,\n-\t\t\tbut padding spaces on the left\n-'%>>( <N> )', '%>>|( <M> )':: similar to '%>( <N> )', '%>|( <M> )'\n-\t\t\t  respectively, except that if the next\n-\t\t\t  placeholder takes more spaces than given and\n-\t\t\t  there are spaces on its left, use those\n-\t\t\t  spaces\n-'%><( <N> )', '%><|( <M> )':: similar to '%<( <N> )', '%<|( <M> )'\n-\t\t\t  respectively, but padding both sides\n-\t\t\t  (i.e. the text is centered)\n-\n-- Placeholders that expand to information extracted from the commit:\n-'%H':: commit hash\n-'%h':: abbreviated commit hash\n-'%T':: tree hash\n-'%t':: abbreviated tree hash\n-'%P':: parent hashes\n-'%p':: abbreviated parent hashes\n-'%an':: author name\n-'%aN':: author name (respecting .mailmap, see linkgit:git-shortlog[1]\n-\tor linkgit:git-blame[1])\n-'%ae':: author email\n-'%aE':: author email (respecting .mailmap, see linkgit:git-shortlog[1]\n-\tor linkgit:git-blame[1])\n-'%al':: author email local-part (the part before the '@' sign)\n-'%aL':: author local-part (see '%al') respecting .mailmap, see\n-\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n-'%ad':: author date (format respects --date= option)\n-'%aD':: author date, RFC2822 style\n-'%ar':: author date, relative\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-'%ah':: author date, human style (like the `--date=human` option of\n-\tlinkgit:git-rev-list[1])\n-'%cn':: committer name\n-'%cN':: committer name (respecting .mailmap, see\n-\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n-'%ce':: committer email\n-'%cE':: committer email (respecting .mailmap, see\n-\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n-'%cl':: committer email local-part (the part before the '@' sign)\n-'%cL':: committer local-part (see '%cl') respecting .mailmap, see\n-\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n-'%cd':: committer date (format respects --date= option)\n-'%cD':: committer date, RFC2822 style\n-'%cr':: committer date, relative\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-'%ch':: committer date, human style (like the `--date=human` option of\n-\tlinkgit:git-rev-list[1])\n-'%d':: ref names, like the --decorate option of linkgit:git-log[1]\n-'%D':: ref names without the \" (\", \")\" wrapping.\n-'%(decorate[:<options>])'::\n-ref names with custom decorations. The `decorate` string may be followed by a\n-colon and zero or more comma-separated options. Option values may contain\n-literal formatting codes. These must be used for commas (`%x2C`) and closing\n-parentheses (`%x29`), due to their role in the option syntax.\n-+\n-** 'prefix=<value>': Shown before the list of ref names.  Defaults to \"{nbsp}`(`\".\n-** 'suffix=<value>': Shown after the list of ref names.  Defaults to \"`)`\".\n-** 'separator=<value>': Shown between ref names.  Defaults to \"`,`{nbsp}\".\n-** 'pointer=<value>': Shown between HEAD and the branch it points to, if any.\n-\t\t      Defaults to \"{nbsp}`->`{nbsp}\".\n-** 'tag=<value>': Shown before tag names. Defaults to \"`tag:`{nbsp}\".\n-\n-+\n-For example, to produce decorations with no wrapping\n-or tag annotations, and spaces as separators:\n-+\n-`%(decorate:prefix=,suffix=,tag=,separator= )`\n-\n-'%(describe[:<options>])'::\n-human-readable name, like linkgit:git-describe[1]; empty string for\n-undescribable commits.  The `describe` string may be followed by a colon and\n-zero or more comma-separated options.  Descriptions can be inconsistent when\n-tags are added or removed at the same time.\n-+\n-** 'tags[=<bool-value>]': Instead of only considering annotated tags,\n-   consider lightweight tags as well.\n-** 'abbrev=<number>': Instead of using the default number of hexadecimal digits\n-   (which will vary according to the number of objects in the repository with a\n-   default of 7) of the abbreviated object name, use <number> digits, or as many\n-   digits as needed to form a unique object name.\n-** 'match=<pattern>': Only consider tags matching the given\n-   `glob(7)` pattern, excluding the \"refs/tags/\" prefix.\n-** 'exclude=<pattern>': Do not consider tags matching the given\n-   `glob(7)` pattern, excluding the \"refs/tags/\" prefix.\n-\n-'%S':: ref name given on the command line by which the commit was reached\n-       (like `git log --source`), only works with `git log`\n-'%e':: encoding\n-'%s':: subject\n-'%f':: sanitized subject line, suitable for a filename\n-'%b':: body\n-'%B':: raw body (unwrapped subject and body)\n-ifndef::git-rev-list[]\n-'%N':: commit notes\n-endif::git-rev-list[]\n-'%GG':: raw verification message from GPG for a signed commit\n-'%G?':: show \"G\" for a good (valid) signature,\n-\t\"B\" for a bad signature,\n-\t\"U\" for a good signature with unknown validity,\n-\t\"X\" for a good signature that has expired,\n-\t\"Y\" for a good signature made by an expired key,\n-\t\"R\" for a good signature made by a revoked key,\n-\t\"E\" if the signature cannot be checked (e.g. missing key)\n-\tand \"N\" for no signature\n-'%GS':: show the name of the signer for a signed commit\n-'%GK':: show the key used to sign a signed commit\n-'%GF':: show the fingerprint of the key used to sign a signed commit\n-'%GP':: show the fingerprint of the primary key whose subkey was used\n-\tto sign a signed commit\n-'%GT':: show the trust level for the key used to sign a signed commit\n-'%gD':: reflog selector, e.g., `refs/stash@{1}` or `refs/stash@{2\n-\tminutes ago}`; the format follows the rules described for the\n-\t`-g` option. The portion before the `@` is the refname as\n-\tgiven on the command line (so `git log -g refs/heads/master`\n-\twould yield `refs/heads/master@{0}`).\n-'%gd':: shortened reflog selector; same as `%gD`, but the refname\n-\tportion is shortened for human readability (so\n-\t`refs/heads/master` becomes just `master`).\n-'%gn':: reflog identity name\n-'%gN':: reflog identity name (respecting .mailmap, see\n-\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n-'%ge':: reflog identity email\n-'%gE':: reflog identity email (respecting .mailmap, see\n-\tlinkgit:git-shortlog[1] or linkgit:git-blame[1])\n-'%gs':: reflog subject\n-'%(trailers[:<options>])'::\n-display the trailers of the body as interpreted by\n-linkgit:git-interpret-trailers[1]. The `trailers` string may be followed by\n-a colon and zero or more comma-separated options. If any option is provided\n-multiple times, the last occurrence wins.\n-+\n-** 'key=<key>': only show trailers with specified <key>. Matching is done\n-   case-insensitively and trailing colon is optional. If option is\n-   given multiple times trailer lines matching any of the keys are\n-   shown. This option automatically enables the `only` option so that\n-   non-trailer lines in the trailer block are hidden. If that is not\n-   desired it can be disabled with `only=false`.  E.g.,\n-   `%(trailers:key=Reviewed-by)` shows trailer lines with key\n-   `Reviewed-by`.\n-** 'only[=<bool>]': select whether non-trailer lines from the trailer\n-   block should be included.\n-** 'separator=<sep>': specify the separator inserted between trailer\n-   lines. Defaults to a line feed character. The string <sep> may contain\n-   the literal formatting codes described above. To use comma as\n-   separator one must use `%x2C` as it would otherwise be parsed as\n-   next option. E.g., `%(trailers:key=Ticket,separator=%x2C )`\n-   shows all trailer lines whose key is \"Ticket\" separated by a comma\n-   and a space.\n-** 'unfold[=<bool>]': make it behave as if interpret-trailer's `--unfold`\n-   option was given. E.g.,\n-   `%(trailers:only,unfold=true)` unfolds and shows all trailer lines.\n-** 'keyonly[=<bool>]': only show the key part of the trailer.\n-** 'valueonly[=<bool>]': only show the value part of the trailer.\n-** 'key_value_separator=<sep>': specify the separator inserted between\n-   the key and value of each trailer. Defaults to \": \". Otherwise it\n-   shares the same semantics as 'separator=<sep>' above.\n-\n-NOTE: Some placeholders may depend on other options given to the\n-revision traversal engine. For example, the `%g*` reflog options will\n-insert an empty string unless we are traversing reflog entries (e.g., by\n-`git log -g`). The `%d` and `%D` placeholders will use the \"short\"\n-decoration format if `--decorate` was not already provided on the command\n-line.\n-\n-The boolean options accept an optional value `[=<bool-value>]`. The\n-values taken by `--type=bool` git-config[1], like `yes` and `off`,\n-are all accepted.  Giving a boolean option without `=<value>` is\n-equivalent to giving it with `=true`.\n-\n-If you add a `+` (plus sign) after '%' of a placeholder, a line-feed\n-is inserted immediately before the expansion if and only if the\n-placeholder expands to a non-empty string.\n-\n-If you add a `-` (minus sign) after '%' of a placeholder, all consecutive\n-line-feeds immediately preceding the expansion are deleted if and only if the\n-placeholder expands to an empty string.\n-\n-If you add a ` ` (space) after '%' of a placeholder, a space\n-is inserted immediately before the expansion if and only if the\n-placeholder expands to a non-empty string.\n+include::placeholders.adoc[]\n \n * 'tformat:'\n +\n-- \n2.43.0\n\n"},{"id":"513353","messageId":"20250301214652.536439-8-aleks.todorov.1337@gmail.com","threadId":"63035","inReplyTo":"20250301214652.536439-1-aleks.todorov.1337@gmail.com","subject":"[PATCH 7/7] Documentation: Add docs for blame format","fromName":"Aleks Todorov","fromEmail":"aleks.todorov.1337@gmail.com","sentAt":"2025-03-01T21:45:06Z","receivedAt":"2025-03-01T21:47:33Z","isPatch":true,"sender":{"key":"aleks.todorov.1337@gmail.com","avatar":null},"body":"Add documentation explaining the new `git blame --format` option as well\nas the associated `blame.format` config option.\n\nInclude a section listing the available placeholders. Also document the\nnew (blame-specific) placeholders in this section.\n\nSigned-off-by: Aleks Todorov <aleks.todorov.1337@gmail.com>\n---\n Documentation/config/blame.adoc |  5 +++++\n Documentation/git-blame.adoc    | 16 ++++++++++++++++\n Documentation/placeholders.adoc |  4 ++++\n 3 files changed, 25 insertions(+)\n\ndiff --git a/Documentation/config/blame.adoc b/Documentation/config/blame.adoc\nindex 4d047c1790..88ef551c04 100644\n--- a/Documentation/config/blame.adoc\n+++ b/Documentation/config/blame.adoc\n@@ -35,3 +35,8 @@ blame.markUnblamableLines::\n blame.markIgnoredLines::\n \tMark lines that were changed by an ignored revision that we attributed to\n \tanother commit with a '?' in the output of linkgit:git-blame[1].\n+\n+blame.format::\n+\tApply the specified format by default when invoking\n+\tlinkgit:git-blame[1]. For supported format specifiers, see the\n+\tdiscussion of the `--format` option in linkgit:git-blame[1].\ndiff --git a/Documentation/git-blame.adoc b/Documentation/git-blame.adoc\nindex f75ed44790..373ff6b994 100644\n--- a/Documentation/git-blame.adoc\n+++ b/Documentation/git-blame.adoc\n@@ -62,6 +62,17 @@ include::blame-options.adoc[]\n \ta certain threshold for 'git blame' to consider those lines\n \tof code to have been moved.\n \n+-F::\n+--format::\n+\tEmit blame information in a given '<format>'. '<format>' is a string\n+\tthat can contain '%placeholder' specifiers, which will be expanded to\n+\tproduce blame information.\n++\n+See the \"PLACEHOLDERS\" section to learn about all of the available specifiers.\n++\n+Note: you can specify the default blame format in the repository configuration\n+(see `blame.format` in linkgit:git-config[1]).\n+\n -f::\n --show-name::\n \tShow the filename in the original commit.  By default\n@@ -235,6 +246,11 @@ one) at the beginning of the \"extended information\" lines. That way, if\n there is ever added information (like the commit encoding or extended\n commit commentary), a blame viewer will not care.\n \n+PLACEHOLDERS\n+------------\n+\n+:git-blame: 1\n+include::placeholders.adoc[]\n \n MAPPING AUTHORS\n ---------------\ndiff --git a/Documentation/placeholders.adoc b/Documentation/placeholders.adoc\nindex 7f4d0b59c7..5420a44e94 100644\n--- a/Documentation/placeholders.adoc\n+++ b/Documentation/placeholders.adoc\n@@ -145,6 +145,10 @@ tags are added or removed at the same time.\n        (like `git log --source`), only works with `git log`\n '%e':: encoding\n '%s':: subject\n+ifdef::git-blame[]\n+'%L':: line number\n+'%F':: filename in the original commit\n+endif::git-blame[]\n '%f':: sanitized subject line, suitable for a filename\n '%b':: body\n '%B':: raw body (unwrapped subject and body)\n-- \n2.43.0\n\n"}]}