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

[PATCH 1/1] log: ensure diffs are omitted with --oneline

From
James Liu <james@jamesliu.io>
Date
Mar 13, 2024, 09:08 UTC
Message-ID
<20240313090841.36717-2-james@jamesliu.io>
In-Reply-To
<20240313090841.36717-1-james@jamesliu.io>

Currently when `git log --oneline` is invoked with the -L flag, the full diffs are displayed along with the single line commit message. It appears that within the log_tree_commit() function, the special case that executes when opt->line_level_traverse is enabled (as in the case when -L is provided) doesn't respect the --oneline option.

Ensure the --oneline option is respected by explicitly setting DIFF_FORMAT_NO_OUTPUT if required.

Signed-off-by: James Liu <james@jamesliu.io>
---
 builtin/log.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/builtin/log.c b/builtin/log.c
index e5da0d1043..dd77ede00c 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -279,6 +279,10 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 		rev->diffopt.output_format |= DIFF_FORMAT_NO_OUTPUT;
 	argc = setup_revisions(argc, argv, rev, opt);
 
+	/* Ensure that we don't output diffs if the --oneline flag is provided */
+	if (rev->commit_format == CMIT_FMT_ONELINE)
+		rev->diffopt.output_format |= DIFF_FORMAT_NO_OUTPUT;
+
 	/* Any arguments at this point are not recognized */
 	if (argc > 1)
 		die(_("unrecognized argument: %s"), argv[1]);
-- 
2.43.2
Previous: James LiuNext: Junio C Hamano
Message 2 of 7 in “log: make the --oneline option work with -L”
  1. 0/1 log: make the --oneline option work with -LJames Liu, Mar 13, 2024
  2. 1/1 log: ensure diffs are omitted with --onelineJames Liu, Mar 13, 2024
  3. Junio C HamanoMar 13, 2024
  4. Beat BolliMar 13, 2024
  5. James LiuMar 13, 2024
  6. James LiuMar 13, 2024
  7. Junio C HamanoMar 13, 2024

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.