]> git.ipfire.org Git - thirdparty/git.git/commit - t/test-lib-functions.sh
apply --whitespace=fix: avoid running over the postimage buffer
authorJunio C Hamano <gitster@pobox.com>
Fri, 22 Mar 2013 18:10:03 +0000 (11:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 22 Mar 2013 18:16:01 +0000 (11:16 -0700)
commit250b3c6c992b3cb04e756eb33bed99442fc55193
tree83e7a3f5b95a391d43c381e5a117ad768bf84e41
parent15999998fbda60552742275570947431b57108ae
apply --whitespace=fix: avoid running over the postimage buffer

Originally update-pre-post-images could assume that any whitespace
fixing will make the result only shorter by unexpanding runs of
leading SPs into HTs and removing trailing whitespaces at the end of
lines.  Updating the post-image we read from the patch to match the
actual result can be performed in-place under this assumption.
These days, however, we have tab-in-indent (aka Python) rule whose
result can be longer than the original, and we do need to allocate
a larger buffer than the input and replace the result.

Fortunately the support for lengthening rewrite was already added
when we began supporting "match while ignoring whitespace
differences" mode in 86c91f91794c (git apply: option to ignore
whitespace differences, 2009-08-04).  We only need to correctly
count the number of bytes necessary to hold the updated result and
tell the function to allocate a new buffer.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/apply.c
t/t4124-apply-ws-rule.sh
t/t4150-am.sh
t/test-lib-functions.sh