Re: [PATCH] apply: reallocate the postimage buffer when needed
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:16
Carlos Martín Nieto [off-list ref] writes:
Blame says Junio and Giuseppe were the last ones to touch this part of the code, so there you go.
Whatever you do in your fix, this comment block needs to be updated: /* * Adjust the common context lines in postimage. This can be * done in-place when we are just doing whitespace fixing, * which does not make the string grow, but needs a new buffer * when ignoring whitespace causes the update, since in this case * we could have e.g. tabs converted to multiple spaces. * We trust the caller to tell us if the update can be done * in place (postlen==0) or not. */ The second sentence used to be true for a long time (if you indented your line with too many spaces, we removed them and replaced with fewer number of tabs; if you had spaces before a tab, we removed them; if you added unnecessary whitespaces at the end, we removed them), but ceased to be so when Python style "indent must be spaces" was added. So I think this either always needs to re-allocate, or the caller has to tell it by other means than "!postlen" the need for reallocation. I wasn't involved in the "apply while ignoring whitespace differences", so Giuseppe may be able to notice other mode of beakages in this and fuzzy_matchlines() function. The commit to be stared at is 86c91f9 (git apply: option to ignore whitespace differences, 2009-08-04). Thanks.