2008-06-27 20:39:12 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='apply same filename'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2008-07-04 08:43:19 +02:00
|
|
|
modify () {
|
|
|
|
sed -e "$1" < "$2" > "$2".x &&
|
|
|
|
mv "$2".x "$2"
|
|
|
|
}
|
|
|
|
|
2008-06-27 20:39:12 +02:00
|
|
|
test_expect_success setup '
|
|
|
|
for i in a b c d e f g h i j k l m
|
|
|
|
do
|
|
|
|
echo $i
|
|
|
|
done >same_fn &&
|
|
|
|
cp same_fn other_fn &&
|
|
|
|
git add same_fn other_fn &&
|
|
|
|
git commit -m initial
|
|
|
|
'
|
|
|
|
test_expect_success 'apply same filename with independent changes' '
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^d/z/" same_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git diff > patch0 &&
|
|
|
|
git add same_fn &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^i/y/" same_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git diff >> patch0 &&
|
|
|
|
cp same_fn same_fn2 &&
|
|
|
|
git reset --hard &&
|
2008-09-03 10:59:29 +02:00
|
|
|
git apply patch0 &&
|
2010-05-14 11:31:37 +02:00
|
|
|
test_cmp same_fn same_fn2
|
2008-06-27 20:39:12 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'apply same filename with overlapping changes' '
|
2010-10-31 02:46:54 +01:00
|
|
|
git reset --hard &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^d/z/" same_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git diff > patch0 &&
|
|
|
|
git add same_fn &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^e/y/" same_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git diff >> patch0 &&
|
|
|
|
cp same_fn same_fn2 &&
|
|
|
|
git reset --hard &&
|
2008-09-03 10:59:29 +02:00
|
|
|
git apply patch0 &&
|
2010-05-14 11:31:37 +02:00
|
|
|
test_cmp same_fn same_fn2
|
2008-06-27 20:39:12 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'apply same new filename after rename' '
|
2010-10-31 02:46:54 +01:00
|
|
|
git reset --hard &&
|
|
|
|
git mv same_fn new_fn &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^d/z/" new_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git add new_fn &&
|
|
|
|
git diff -M --cached > patch1 &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^e/y/" new_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git diff >> patch1 &&
|
|
|
|
cp new_fn new_fn2 &&
|
|
|
|
git reset --hard &&
|
|
|
|
git apply --index patch1 &&
|
2010-05-14 11:31:37 +02:00
|
|
|
test_cmp new_fn new_fn2
|
2008-06-27 20:39:12 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'apply same old filename after rename -- should fail.' '
|
2010-10-31 02:46:54 +01:00
|
|
|
git reset --hard &&
|
|
|
|
git mv same_fn new_fn &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^d/z/" new_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git add new_fn &&
|
|
|
|
git diff -M --cached > patch1 &&
|
2010-10-31 02:46:54 +01:00
|
|
|
git mv new_fn same_fn &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^e/y/" same_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git diff >> patch1 &&
|
|
|
|
git reset --hard &&
|
|
|
|
test_must_fail git apply patch1
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' '
|
2010-10-31 02:46:54 +01:00
|
|
|
git reset --hard &&
|
|
|
|
git mv same_fn new_fn &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^d/z/" new_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git add new_fn &&
|
|
|
|
git diff -M --cached > patch1 &&
|
|
|
|
git commit -m "a rename" &&
|
2010-10-31 02:46:54 +01:00
|
|
|
git mv other_fn same_fn &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^e/y/" same_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git add same_fn &&
|
|
|
|
git diff -M --cached >> patch1 &&
|
2008-07-04 08:43:19 +02:00
|
|
|
modify "s/^g/x/" same_fn &&
|
2008-06-27 20:39:12 +02:00
|
|
|
git diff >> patch1 &&
|
|
|
|
git reset --hard HEAD^ &&
|
|
|
|
git apply patch1
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|