git-commit-vandalism/t/t4130-apply-criss-cross-rename.sh
Michał Kiedrowicz e8141fcf54 builtin-apply: keep information about files to be deleted
Example correct diff generated by `diff -M -B' might look like this:

	diff --git a/file1 b/file2
	similarity index 100%
	rename from file1
	rename to file2
	diff --git a/file2 b/file1
	similarity index 100%
	rename from file2
	rename to file1

Information about removing `file2' comes after information about creation
of new `file2' (renamed from `file1'). Existing implementation isn't able to
apply such patch, because it has to know in advance which files will be
removed.

This patch populates fn_table with information about removal of files
before calling check_patch() for each patch to be applied.

Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-20 13:46:58 -07:00

39 lines
583 B
Bash
Executable File

#!/bin/sh
test_description='git apply handling criss-cross rename patch.'
. ./test-lib.sh
create_file() {
cnt=0
while test $cnt -le 100
do
cnt=$(($cnt + 1))
echo "$2" >> "$1"
done
}
test_expect_success 'setup' '
create_file file1 "File1 contents" &&
create_file file2 "File2 contents" &&
git add file1 file2 &&
git commit -m 1
'
test_expect_success 'criss-cross rename' '
mv file1 tmp &&
mv file2 file1 &&
mv tmp file2
'
test_expect_success 'diff -M -B' '
git diff -M -B > diff &&
git reset --hard
'
test_expect_success 'apply' '
git apply diff
'
test_done