From: Junio C Hamano Date: Wed, 19 Oct 2011 17:49:13 +0000 (-0700) Subject: Merge branch 'rs/diff-whole-function' X-Git-Tag: v1.7.8-rc0~37 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9b55aa03daebf43067021b7d58abea249229987b?ds=inline;hp=-c Merge branch 'rs/diff-whole-function' * rs/diff-whole-function: diff: add option to show whole functions as context xdiff: factor out get_func_line() --- 9b55aa03daebf43067021b7d58abea249229987b diff --combined Documentation/diff-options.txt index 5c53bdba94,1ce4ae3b17..08b581f040 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@@ -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 d922b77aef,42c4891eb3..374ecf3b48 --- a/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")) @@@ -3536,6 -3532,12 +3538,12 @@@ 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)