log: when --cc is given, default to -p unless told otherwise
authorJunio C Hamano <gitster@pobox.com>
Thu, 20 Aug 2015 21:36:49 +0000 (14:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Aug 2015 22:03:57 +0000 (15:03 -0700)
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
index 865110534d848e418457bda71ff860aeb010bb44..e37c27ab7efface402b59de46516c7e64f83691b 100644 (file)
@@ -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)