]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t4129-apply-samemode.sh
Merge branch 'cp/apply-core-filemode'
[thirdparty/git.git] / t / t4129-apply-samemode.sh
index 2775bfadd8619b2a5e2440209c46c0658205ddcd..4eb84440298552ec53520307641419a7f6d7fd77 100755 (executable)
@@ -103,4 +103,31 @@ test_expect_success POSIXPERM 'do not use core.sharedRepository for working tree
        )
 '
 
+test_expect_success 'git apply respects core.fileMode' '
+       test_config core.fileMode false &&
+       echo true >script.sh &&
+       git add --chmod=+x script.sh &&
+       git ls-files -s script.sh >ls-files-output &&
+       test_grep "^100755" ls-files-output &&
+       test_tick && git commit -m "Add script" &&
+       git ls-tree -r HEAD script.sh >ls-tree-output &&
+       test_grep "^100755" ls-tree-output &&
+
+       echo true >>script.sh &&
+       test_tick && git commit -m "Modify script" script.sh &&
+       git format-patch -1 --stdout >patch &&
+       test_grep "^index.*100755$" patch &&
+
+       git switch -c branch HEAD^ &&
+       git apply --index patch 2>err &&
+       test_grep ! "has type 100644, expected 100755" err &&
+       git reset --hard &&
+
+       git apply patch 2>err &&
+       test_grep ! "has type 100644, expected 100755" err &&
+
+       git apply --cached patch 2>err &&
+       test_grep ! "has type 100644, expected 100755" err
+'
+
 test_done