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

[PATCH] Make -p --stat and --stat -p behave like --patch-with-stat

From
THTimo Hirvonen <tihirvon@gmail.com>
Date
Jun 22, 2006, 13:25 UTC
Message-ID
<20060622162511.4788505e.tihirvon@gmail.com>

git log log only git log --stat log with stat git log -p log with patch git log --stat -p log with patch (no stat!) git log -p --stat log with stat (no patch!) git log --patch-with-stat log with patch and stat

This patch makes -p --stat and --stat -p work like --patch-with-stat.
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
---
  Maybe DIFF_FORMAT_* should be reworked instead but this was easy.
  Only negative impact of this patch is that if you have a alias
     l=log --stat
  then you can't override --stat with "git l -p", it will still show
  diffstat, but I don't think it matters.
 diff.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 9e9cfc8..75632d3 100644
--- a/diff.c
+++ b/diff.c
@@ -1382,16 +1382,27 @@ int opt_arg(const char *arg, int arg_sho
 int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 {
 	const char *arg = av[0];
-	if (!strcmp(arg, "-p") || !strcmp(arg, "-u"))
+	if (!strcmp(arg, "-p") || !strcmp(arg, "-u")) {
+		if (options->output_format == DIFF_FORMAT_DIFFSTAT) {
+			// --stat -p
+			options->with_stat = 1;
+		}
 		options->output_format = DIFF_FORMAT_PATCH;
+	}
 	else if (opt_arg(arg, 'U', "unified", &options->context))
 		options->output_format = DIFF_FORMAT_PATCH;
 	else if (!strcmp(arg, "--patch-with-raw")) {
 		options->output_format = DIFF_FORMAT_PATCH;
 		options->with_raw = 1;
 	}
-	else if (!strcmp(arg, "--stat"))
-		options->output_format = DIFF_FORMAT_DIFFSTAT;
+	else if (!strcmp(arg, "--stat")) {
+		if (options->output_format == DIFF_FORMAT_PATCH) {
+			// -p --stat
+			options->with_stat = 1;
+		} else {
+			options->output_format = DIFF_FORMAT_DIFFSTAT;
+		}
+	}
 	else if (!strcmp(arg, "--check"))
 		options->output_format = DIFF_FORMAT_CHECKDIFF;
 	else if (!strcmp(arg, "--summary"))
-- 
1.4.0.g5fdc-dirty
Next: Junio C Hamano
Message 1 of 3 in “Make -p --stat and --stat -p behave like --patch-with-stat”
  1. Make -p --stat and --stat -p behave like --patch-with-statTimo Hirvonen, Jun 22, 2006
  2. Junio C HamanoJun 22, 2006
  3. Timo HirvonenJun 23, 2006

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.