Code

Merge branch 'rs/diff-whole-function'
authorJunio C Hamano <gitster@pobox.com>
Wed, 19 Oct 2011 17:49:13 +0000 (10:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Oct 2011 17:49:13 +0000 (10:49 -0700)
* rs/diff-whole-function:
  diff: add option to show whole functions as context
  xdiff: factor out get_func_line()

1  2 
Documentation/diff-options.txt
diff.c

index 5c53bdba948ea817e01e169a9fc183d4fc2d1313,1ce4ae3b17a7bca7082e499bf7edbc80359c2e79..08b581f040859d39aeaad8294bc7a3e7760ab0b9
@@@ -45,10 -45,6 +45,10 @@@ ifndef::git-format-patch[
        Synonym for `-p --raw`.
  endif::git-format-patch[]
  
 +--minimal::
 +      Spend extra time to make sure the smallest possible
 +      diff is produced.
 +
  --patience::
        Generate a diff using the "patience diff" algorithm.
  
@@@ -408,6 -404,10 +408,10 @@@ endif::git-format-patch[
        Show the context between diff hunks, up to the specified number
        of lines, thereby fusing hunks that are close to each other.
  
+ -W::
+ --function-context::
+       Show whole surrounding functions of changes.
  ifndef::git-format-patch[]
  --exit-code::
        Make the program exit with codes similar to diff(1).
diff --combined diff.c
index d922b77aef2da84824a8e14fc21961e36e6d2e36,42c4891eb3e7163786d51d01f7219b2421e09dd3..374ecf3b486e218c52f94ba14481a715c19b80db
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -2169,6 -2169,8 +2169,8 @@@ static void builtin_diff(const char *na
                xecfg.ctxlen = o->context;
                xecfg.interhunkctxlen = o->interhunkcontext;
                xecfg.flags = XDL_EMIT_FUNCNAMES;
+               if (DIFF_OPT_TST(o, FUNCCONTEXT))
+                       xecfg.flags |= XDL_EMIT_FUNCCONTEXT;
                if (pe)
                        xdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);
                if (!diffopts)
@@@ -2274,8 -2276,6 +2276,8 @@@ static void builtin_diffstat(const cha
                memset(&xpp, 0, sizeof(xpp));
                memset(&xecfg, 0, sizeof(xecfg));
                xpp.flags = o->xdl_opts;
 +              xecfg.ctxlen = o->context;
 +              xecfg.interhunkctxlen = o->interhunkcontext;
                xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
                              &xpp, &xecfg);
        }
@@@ -3387,10 -3387,6 +3389,10 @@@ int diff_opt_parse(struct diff_options 
        }
  
        /* xdiff options */
 +      else if (!strcmp(arg, "--minimal"))
 +              DIFF_XDL_SET(options, NEED_MINIMAL);
 +      else if (!strcmp(arg, "--no-minimal"))
 +              DIFF_XDL_CLR(options, NEED_MINIMAL);
        else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
                DIFF_XDL_SET(options, IGNORE_WHITESPACE);
        else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change"))
        else if (opt_arg(arg, '\0', "inter-hunk-context",
                         &options->interhunkcontext))
                ;
+       else if (!strcmp(arg, "-W"))
+               DIFF_OPT_SET(options, FUNCCONTEXT);
+       else if (!strcmp(arg, "--function-context"))
+               DIFF_OPT_SET(options, FUNCCONTEXT);
+       else if (!strcmp(arg, "--no-function-context"))
+               DIFF_OPT_CLR(options, FUNCCONTEXT);
        else if ((argcount = parse_long_opt("output", av, &optarg))) {
                options->file = fopen(optarg, "w");
                if (!options->file)