1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-12 20:23:02 +01:00
git/t/t4127-apply-same-fn.sh
Gary V. Vaughan 4fdf71be1c tests: use "test_cmp", not "diff", when verifying the result
In tests, call test_cmp rather than raw diff where possible (i.e. if
the output does not go to a pipe), to allow the use of, say, 'cmp'
when the default 'diff -u' is not compatible with a vendor diff.

When that is not possible, use $DIFF, as set in GIT-BUILD-OPTIONS.

Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-05-31 16:59:27 -07:00

90 lines
2 KiB
Bash
Executable file

#!/bin/sh
test_description='apply same filename'
. ./test-lib.sh
modify () {
sed -e "$1" < "$2" > "$2".x &&
mv "$2".x "$2"
}
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' '
modify "s/^d/z/" same_fn &&
git diff > patch0 &&
git add same_fn &&
modify "s/^i/y/" same_fn &&
git diff >> patch0 &&
cp same_fn same_fn2 &&
git reset --hard &&
git apply patch0 &&
test_cmp same_fn same_fn2
'
test_expect_success 'apply same filename with overlapping changes' '
git reset --hard
modify "s/^d/z/" same_fn &&
git diff > patch0 &&
git add same_fn &&
modify "s/^e/y/" same_fn &&
git diff >> patch0 &&
cp same_fn same_fn2 &&
git reset --hard &&
git apply patch0 &&
test_cmp same_fn same_fn2
'
test_expect_success 'apply same new filename after rename' '
git reset --hard
git mv same_fn new_fn
modify "s/^d/z/" new_fn &&
git add new_fn &&
git diff -M --cached > patch1 &&
modify "s/^e/y/" new_fn &&
git diff >> patch1 &&
cp new_fn new_fn2 &&
git reset --hard &&
git apply --index patch1 &&
test_cmp new_fn new_fn2
'
test_expect_success 'apply same old filename after rename -- should fail.' '
git reset --hard
git mv same_fn new_fn
modify "s/^d/z/" new_fn &&
git add new_fn &&
git diff -M --cached > patch1 &&
git mv new_fn same_fn
modify "s/^e/y/" same_fn &&
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.' '
git reset --hard
git mv same_fn new_fn
modify "s/^d/z/" new_fn &&
git add new_fn &&
git diff -M --cached > patch1 &&
git commit -m "a rename" &&
git mv other_fn same_fn
modify "s/^e/y/" same_fn &&
git add same_fn &&
git diff -M --cached >> patch1 &&
modify "s/^g/x/" same_fn &&
git diff >> patch1 &&
git reset --hard HEAD^ &&
git apply patch1
'
test_done