git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make -p --stat and --stat -p behave like --patch-with-stat
@ 2006-06-22 13:25 Timo Hirvonen
  2006-06-22 18:58 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Timo Hirvonen @ 2006-06-22 13:25 UTC (permalink / raw)
  To: junkio; +Cc: git

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make -p --stat and --stat -p behave like --patch-with-stat
  2006-06-22 13:25 [PATCH] Make -p --stat and --stat -p behave like --patch-with-stat Timo Hirvonen
@ 2006-06-22 18:58 ` Junio C Hamano
  2006-06-23 12:00   ` Timo Hirvonen
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2006-06-22 18:58 UTC (permalink / raw)
  To: Timo Hirvonen; +Cc: junkio, git

Timo Hirvonen <tihirvon@gmail.com> writes:

> 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.

I do not think it matters that much either, but DIFF_FORMAT_*
really should be reworked regardless.  --with-foo should really
be independent switches that can be added together, perhaps.

So how would we go about this?  A strawman.

The diff output has four parts, each of which can independently
be enabled.  When no options are specified on the command line,
each command has its own default but in general the low-level
commands default to raw output only, and the higher-level ones
default to patch output only.

The four parts are controlled with a bit each, and are output in
the fixed order (iow the order of the options given from the
command line does not matter): raw, stat, summary and patch.

When --name-only or --name-status is specified, that would be
the only thing that is output (iow the above four parts would
not be shown, just names optionally with the status are shown).

The four switches are: --raw, --stat, --summary and --patch.
Existing flags are supported as obvious shorthands to turn on
the corresponding bits:

	-p, -u			--patch
        --patch-with-raw	--raw --patch
        --patch-with-stat	--stat --patch

Anybody interested in doing a patch?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make -p --stat and --stat -p behave like --patch-with-stat
  2006-06-22 18:58 ` Junio C Hamano
@ 2006-06-23 12:00   ` Timo Hirvonen
  0 siblings, 0 replies; 3+ messages in thread
From: Timo Hirvonen @ 2006-06-23 12:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: junkio, git

Junio C Hamano <junkio@cox.net> wrote:

> The diff output has four parts, each of which can independently
> be enabled.  When no options are specified on the command line,
> each command has its own default but in general the low-level
> commands default to raw output only, and the higher-level ones
> default to patch output only.
> 
> The four parts are controlled with a bit each, and are output in
> the fixed order (iow the order of the options given from the
> command line does not matter): raw, stat, summary and patch.
> 
> When --name-only or --name-status is specified, that would be
> the only thing that is output (iow the above four parts would
> not be shown, just names optionally with the status are shown).
> 
> The four switches are: --raw, --stat, --summary and --patch.
> Existing flags are supported as obvious shorthands to turn on
> the corresponding bits:
> 
> 	-p, -u			--patch
>         --patch-with-raw	--raw --patch
>         --patch-with-stat	--stat --patch
> 
> Anybody interested in doing a patch?

I'll try. It shouldn't be too hard.

-- 
http://onion.dynserv.net/~timo/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-06-23 12:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-22 13:25 [PATCH] Make -p --stat and --stat -p behave like --patch-with-stat Timo Hirvonen
2006-06-22 18:58 ` Junio C Hamano
2006-06-23 12:00   ` Timo Hirvonen

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).