Code

Make thin-pack generation subproject aware.
[git.git] / t / t4116-apply-reverse.sh
index 69aebe600573fa0e014e97001f40836d3a18b82b..9ae2b3a8efaad4430bbcea02152470b064263b2b 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Junio C Hamano
 #
 
-test_description='git-apply in reverse
+test_description='git apply in reverse
 
 '
 
@@ -22,25 +22,70 @@ test_expect_success setup '
        tr "[mon]" '\''[\0\1\2]'\'' <file1 >file2 &&
 
        git commit -a -m second &&
+       git tag second &&
 
-       git diff --binary -R initial >patch
+       git diff --binary initial second >patch
 
 '
 
 test_expect_success 'apply in forward' '
 
+       T0=`git rev-parse "second^{tree}"` &&
+       git reset --hard initial &&
        git apply --index --binary patch &&
-       git diff initial >diff &&
-       diff -u /dev/null diff
-
+       T1=`git write-tree` &&
+       test "$T0" = "$T1"
 '
 
 test_expect_success 'apply in reverse' '
 
+       git reset --hard second &&
        git apply --reverse --binary --index patch &&
        git diff >diff &&
-       diff -u /dev/null diff
+       git diff /dev/null diff
+
+'
+
+test_expect_success 'setup separate repository lacking postimage' '
+
+       git tar-tree initial initial | tar xf - &&
+       (
+               cd initial && git init && git add .
+       ) &&
+
+       git tar-tree second second | tar xf - &&
+       (
+               cd second && git init && git add .
+       )
+
+'
+
+test_expect_success 'apply in forward without postimage' '
+
+       T0=`git rev-parse "second^{tree}"` &&
+       (
+               cd initial &&
+               git apply --index --binary ../patch &&
+               T1=`git write-tree` &&
+               test "$T0" = "$T1"
+       )
+'
+
+test_expect_success 'apply in reverse without postimage' '
+
+       T0=`git rev-parse "initial^{tree}"` &&
+       (
+               cd second &&
+               git apply --index --binary --reverse ../patch &&
+               T1=`git write-tree` &&
+               test "$T0" = "$T1"
+       )
+'
 
+test_expect_success 'reversing a whitespace introduction' '
+       sed "s/a/a /" < file1 > file1.new &&
+       mv file1.new file1 &&
+       git diff | git apply --reverse --whitespace=error
 '
 
 test_done