git-apply: handle a patch that touches the same path more than once better
commit7a07841c0ba8d791dd4c7363eaf004b4a7d11fb6
authorDon Zickus <dzickus@redhat.com>
Fri, 27 Jun 2008 18:39:12 +0000 (27 14:39 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sat, 28 Jun 2008 00:01:02 +0000 (27 17:01 -0700)
tree025e715aa95dbfb4aa511032cf533ea81c465cb8
parentd54467b8c319571b5dc433b1f7e471c4b0f21caf
git-apply: handle a patch that touches the same path more than once better

When working with a lot of people who backport patches all day long, every
once in a while I get a patch that modifies the same file more than once
inside the same patch.  git-apply either fails if the second change relies
on the first change or silently drops the first change if the second change
is independent.

The silent part is the scary scenario for us.  Also this behaviour is
different from the patch-utils.

I have modified git-apply to create a table of the filenames of files it
modifies such that if a later patch chunk modifies a file in the table it
will buffer the previously changed file instead of reading the original file
from disk.

Logic has been put in to handle creations/deletions/renames/copies.  All the
relevant tests of git-apply succeed.

A new test has been added to cover the cases I addressed.

The fix is relatively straight-forward.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-apply.c
t/t4127-apply-same-fn.sh [new file with mode: 0755]