git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Timo Hirvonen <tihirvon@gmail.com>
To: junkio@cox.net
Cc: git@vger.kernel.org
Subject: [PATCH] Make -p --stat and --stat -p behave like --patch-with-stat
Date: Thu, 22 Jun 2006 16:25:11 +0300	[thread overview]
Message-ID: <20060622162511.4788505e.tihirvon@gmail.com> (raw)

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

             reply	other threads:[~2006-06-22 13:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-22 13:25 Timo Hirvonen [this message]
2006-06-22 18:58 ` [PATCH] Make -p --stat and --stat -p behave like --patch-with-stat Junio C Hamano
2006-06-23 12:00   ` Timo Hirvonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060622162511.4788505e.tihirvon@gmail.com \
    --to=tihirvon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).