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

[PATCH 2/3] log: when --cc is given, default to -p unless told otherwise

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 20, 2015, 22:43 UTC
Message-ID
<1440110591-12941-3-git-send-email-gitster@pobox.com>
In-Reply-To
<1440110591-12941-1-git-send-email-gitster@pobox.com>

The "--cc" option to "git log" is clearly a request to show some sort of combined diff (be it --patch or --raw), but traditionally we required the command line to explicitly ask for "git log -p --cc".

Teach the command line parser to treat a lone "--cc" as if the user specified "-p --cc". Formats that do ask for other forms of diff output, e.g. "log --raw --cc", are not overriden.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/log.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/builtin/log.c b/builtin/log.c
index 8651105..e37c27a 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -633,6 +633,10 @@ static void log_setup_revisions_tweak(struct rev_info *rev,
 	if (DIFF_OPT_TST(&rev->diffopt, DEFAULT_FOLLOW_RENAMES) &&
 	    rev->prune_data.nr == 1)
 		DIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);
+
+	/* Turn --cc/-c into -p --cc/-c when -p was not given */
+	if (!rev->diffopt.output_format && rev->combine_merges)
+		rev->diffopt.output_format = DIFF_FORMAT_PATCH;
 }
 
 int cmd_log(int argc, const char **argv, const char *prefix)
-- 
2.5.0-546-gb1bbc0d
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 6 in “Showing merges easier with "git log"”
  1. 0/3 Showing merges easier with "git log"Junio C Hamano, Aug 20, 2015
  2. 1/3 log: rename "tweak" helpersJunio C Hamano, Aug 20, 2015
  3. 2/3 log: when --cc is given, default to -p unless told otherwiseJunio C Hamano, Aug 20, 2015
  4. 3/3 log: show merge commit when --cc is givenJunio C Hamano, Aug 20, 2015
  5. 4/3 builtin/log.c: minor reformatJunio C Hamano, Aug 21, 2015
  6. log: make '-p' imply '-m --cc'Junio C Hamano, Aug 21, 2015

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.