Skip to content

Commit f01cae9

Browse files
committed
diff: teach --stat/--numstat to honor -U$num
"git diff -p" piped to external diffstat and "git diff --stat" may see different patch text (both are valid and describe the same change correctly) when counting the number of added and deleted lines, arriving at different results to confuse the users, as --stat/--numstat codepath always uses the hardcoded -U0 as the context length. Make --stat/--numstat codepath to honor the context length the same way as the textual patch codepath does to avoid this problem. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 87b5054 commit f01cae9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

diff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,6 +2096,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
20962096
memset(&xpp, 0, sizeof(xpp));
20972097
memset(&xecfg, 0, sizeof(xecfg));
20982098
xpp.flags = o->xdl_opts;
2099+
xecfg.ctxlen = o->context;
2100+
xecfg.interhunkctxlen = o->interhunkcontext;
20992101
xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
21002102
&xpp, &xecfg);
21012103
}

0 commit comments

Comments
 (0)