{"thread":{"id":"4614","subject":"[PATCH] Make -p --stat and --stat -p behave like --patch-with-stat","startedAt":"2006-06-22T13:25:11Z","lastAt":"2006-06-23T12:00:49Z","messageCount":3,"participants":["Timo Hirvonen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"22274","messageId":"20060622162511.4788505e.tihirvon@gmail.com","threadId":"4614","inReplyTo":null,"subject":"[PATCH] Make -p --stat and --stat -p behave like --patch-with-stat","fromName":"Timo Hirvonen","fromEmail":"tihirvon@gmail.com","sentAt":"2006-06-22T13:25:11Z","receivedAt":"2006-06-22T13:25:11Z","isPatch":true,"sender":{"key":"tihirvon@gmail.com","avatar":null},"body":"git log                    log only\ngit log --stat             log with stat\ngit log -p                 log with patch\ngit log --stat -p          log with patch (no stat!)\ngit log -p --stat          log with stat (no patch!)\ngit log --patch-with-stat  log with patch and stat\n\nThis patch makes -p --stat and --stat -p work like --patch-with-stat.\n\nSigned-off-by: Timo Hirvonen <tihirvon@gmail.com>\n---\n\n  Maybe DIFF_FORMAT_* should be reworked instead but this was easy.\n\n  Only negative impact of this patch is that if you have a alias\n\n     l=log --stat\n\n  then you can't override --stat with \"git l -p\", it will still show\n  diffstat, but I don't think it matters.\n\n diff.c |   17 ++++++++++++++---\n 1 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 9e9cfc8..75632d3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1382,16 +1382,27 @@ int opt_arg(const char *arg, int arg_sho\n int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n {\n \tconst char *arg = av[0];\n-\tif (!strcmp(arg, \"-p\") || !strcmp(arg, \"-u\"))\n+\tif (!strcmp(arg, \"-p\") || !strcmp(arg, \"-u\")) {\n+\t\tif (options->output_format == DIFF_FORMAT_DIFFSTAT) {\n+\t\t\t// --stat -p\n+\t\t\toptions->with_stat = 1;\n+\t\t}\n \t\toptions->output_format = DIFF_FORMAT_PATCH;\n+\t}\n \telse if (opt_arg(arg, 'U', \"unified\", &options->context))\n \t\toptions->output_format = DIFF_FORMAT_PATCH;\n \telse if (!strcmp(arg, \"--patch-with-raw\")) {\n \t\toptions->output_format = DIFF_FORMAT_PATCH;\n \t\toptions->with_raw = 1;\n \t}\n-\telse if (!strcmp(arg, \"--stat\"))\n-\t\toptions->output_format = DIFF_FORMAT_DIFFSTAT;\n+\telse if (!strcmp(arg, \"--stat\")) {\n+\t\tif (options->output_format == DIFF_FORMAT_PATCH) {\n+\t\t\t// -p --stat\n+\t\t\toptions->with_stat = 1;\n+\t\t} else {\n+\t\t\toptions->output_format = DIFF_FORMAT_DIFFSTAT;\n+\t\t}\n+\t}\n \telse if (!strcmp(arg, \"--check\"))\n \t\toptions->output_format = DIFF_FORMAT_CHECKDIFF;\n \telse if (!strcmp(arg, \"--summary\"))\n-- \n1.4.0.g5fdc-dirty\n"},{"id":"22294","messageId":"7vr71hkofg.fsf@assigned-by-dhcp.cox.net","threadId":"4614","inReplyTo":"20060622162511.4788505e.tihirvon@gmail.com","subject":"Re: [PATCH] Make -p --stat and --stat -p behave like --patch-with-stat","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-22T18:58:27Z","receivedAt":"2006-06-22T18:58:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Timo Hirvonen <tihirvon@gmail.com> writes:\n\n> git log                    log only\n> git log --stat             log with stat\n> git log -p                 log with patch\n> git log --stat -p          log with patch (no stat!)\n> git log -p --stat          log with stat (no patch!)\n> git log --patch-with-stat  log with patch and stat\n>\n> This patch makes -p --stat and --stat -p work like --patch-with-stat.\n>\n> Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>\n> ---\n>\n>   Maybe DIFF_FORMAT_* should be reworked instead but this was easy.\n>\n>   Only negative impact of this patch is that if you have a alias\n>\n>      l=log --stat\n>\n>   then you can't override --stat with \"git l -p\", it will still show\n>   diffstat, but I don't think it matters.\n\nI do not think it matters that much either, but DIFF_FORMAT_*\nreally should be reworked regardless.  --with-foo should really\nbe independent switches that can be added together, perhaps.\n\nSo how would we go about this?  A strawman.\n\nThe diff output has four parts, each of which can independently\nbe enabled.  When no options are specified on the command line,\neach command has its own default but in general the low-level\ncommands default to raw output only, and the higher-level ones\ndefault to patch output only.\n\nThe four parts are controlled with a bit each, and are output in\nthe fixed order (iow the order of the options given from the\ncommand line does not matter): raw, stat, summary and patch.\n\nWhen --name-only or --name-status is specified, that would be\nthe only thing that is output (iow the above four parts would\nnot be shown, just names optionally with the status are shown).\n\nThe four switches are: --raw, --stat, --summary and --patch.\nExisting flags are supported as obvious shorthands to turn on\nthe corresponding bits:\n\n\t-p, -u\t\t\t--patch\n        --patch-with-raw\t--raw --patch\n        --patch-with-stat\t--stat --patch\n\nAnybody interested in doing a patch?\n"},{"id":"22344","messageId":"20060623150049.9d147262.tihirvon@gmail.com","threadId":"4614","inReplyTo":"7vr71hkofg.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Make -p --stat and --stat -p behave like --patch-with-stat","fromName":"Timo Hirvonen","fromEmail":"tihirvon@gmail.com","sentAt":"2006-06-23T12:00:49Z","receivedAt":"2006-06-23T12:00:49Z","isPatch":true,"sender":{"key":"tihirvon@gmail.com","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n\n> The diff output has four parts, each of which can independently\n> be enabled.  When no options are specified on the command line,\n> each command has its own default but in general the low-level\n> commands default to raw output only, and the higher-level ones\n> default to patch output only.\n> \n> The four parts are controlled with a bit each, and are output in\n> the fixed order (iow the order of the options given from the\n> command line does not matter): raw, stat, summary and patch.\n> \n> When --name-only or --name-status is specified, that would be\n> the only thing that is output (iow the above four parts would\n> not be shown, just names optionally with the status are shown).\n> \n> The four switches are: --raw, --stat, --summary and --patch.\n> Existing flags are supported as obvious shorthands to turn on\n> the corresponding bits:\n> \n> \t-p, -u\t\t\t--patch\n>         --patch-with-raw\t--raw --patch\n>         --patch-with-stat\t--stat --patch\n> \n> Anybody interested in doing a patch?\n\nI'll try. It shouldn't be too hard.\n\n-- \nhttp://onion.dynserv.net/~timo/\n"}]}