git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/7] builtin/blame: Accept a user-specified format

From
ATAleks Todorov <aleks.todorov.1337@gmail.com>
Date
Mar 1, 2025, 21:45 UTC
Message-ID
<20250301214652.536439-2-aleks.todorov.1337@gmail.com>
In-Reply-To
<20250301214652.536439-1-aleks.todorov.1337@gmail.com>

Add a --format / -F option to `git-blame` which allows the user to provide a string with placeholders which will be expanded to include custom information in the blame output.

Signed-off-by: Aleks Todorov <aleks.todorov.1337@gmail.com>
---
 builtin/blame.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/builtin/blame.c b/builtin/blame.c
index c470654c7e..437ac8bd73 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -66,6 +66,7 @@ static int xdl_opts;
 static int abbrev = -1;
 static int no_whole_file_rename;
 static int show_progress;
+static char *format = NULL;
 static char repeated_meta_color[COLOR_MAXLEN];
 static int coloring_mode;
 static struct string_list ignore_revs_file_list = STRING_LIST_INIT_DUP;
@@ -905,6 +906,7 @@ int cmd_blame(int argc,
 		OPT_BIT('t', NULL, &output_option, N_("show raw timestamp (Default: off)"), OUTPUT_RAW_TIMESTAMP),
 		OPT_BIT('l', NULL, &output_option, N_("show long commit SHA1 (Default: off)"), OUTPUT_LONG_OBJECT_NAME),
 		OPT_BIT('s', NULL, &output_option, N_("suppress author name and timestamp (Default: off)"), OUTPUT_NO_AUTHOR),
+		OPT_STRING('F', "format", &format, N_("format"), N_("print blame entries in the given <format>")),
 		OPT_BIT('e', "show-email", &output_option, N_("show author email instead of name (Default: off)"), OUTPUT_SHOW_EMAIL),
 		OPT_BIT('w', NULL, &xdl_opts, N_("ignore whitespace differences"), XDF_IGNORE_WHITESPACE),
 		OPT_STRING_LIST(0, "ignore-rev", &ignore_rev_list, N_("rev"), N_("ignore <rev> when blaming")),
-- 
2.43.0
Previous: Aleks TodorovNext: Aleks Todorov
Message 2 of 8 in “Add Format Specifier for Blame”
  1. 0/7 Add Format Specifier for BlameAleks Todorov, Mar 1, 2025
  2. 1/7 builtin/blame: Accept a user-specified formatAleks Todorov, Mar 1, 2025
  3. 2/7 builtin/blame: Add blame.format config optionAleks Todorov, Mar 1, 2025
  4. 3/7 pretty: Add F and L format specifiersAleks Todorov, Mar 1, 2025
  5. 4/7 builtin/blame: Expand format when availableAleks Todorov, Mar 1, 2025
  6. 5/7 t8015: Add tests for git blame -FAleks Todorov, Mar 1, 2025
  7. 6/7 Documentation: Move placeholders to separate fileAleks Todorov, Mar 1, 2025
  8. 7/7 Documentation: Add docs for blame formatAleks Todorov, Mar 1, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.