From: Junio C Hamano Date: Wed, 03 Feb 2021 19:42:48 GMT Subject: Re: [PATCH 19/25] pickaxe -G: set -U0 for diff generation Message-ID: In-Reply-To: <874kitdy6r.fsf@evledraar.gmail.com> Ævar Arnfjörð Bjarmason writes: > I since discovered Junio's f01cae918f (diff: teach --stat/--numstat to > honor -U$num, 2011-09-22) (as an aside we have no test for that > behavior). > > I haven't looked carefully, but I don't think we'll have the same issue > here, as pickaxe currently doesn't care about whether something is on > the + or - line, when briefly looking at the diffstat edge cases it > seems that's what differs based on -U for the diffstat. With -U0 or different in general, the matching between preimage and postimage may become different, and both -U3 (usual) and -U0 may express the same change "correctly" from the point of view of a program like "git apply", but humans would see them as different patches, and "diffstat" that counts number of +/- would give different results. The patch IDs may also be different. The old commit was to pessimize the logic (because we do not need context just to count +/- lines for the purpose of diffstat) to match human expectations. They expect "'diffstat' must be counting 'diff -p' output" and we were counting "diff -p -U0" instead, resulting in different numbers. With internally using -U0, the updated "pickaxe -G" is likely to get the same complaints: "'pickaxe -G' found this commit, but in the 'git show' output, the token does not seem to be affected". You'd respond to "try 'git show -U0' and now you'd see the ", but again that is probably breaking human expectations.