Skip to content

Commit

Permalink
diff: teach --stat/--numstat to honor -U$num
Browse files Browse the repository at this point in the history
"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 <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Sep 22, 2011
1 parent 87b5054 commit f01cae9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions diff.c
Original file line number Diff line number Diff line change
@@ -2096,6 +2096,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
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);
}

0 comments on commit f01cae9

Please sign in to comment.