#!/bin/sh global test_description := ''applying patch with mode bits'' source ./test-lib.sh test_expect_success setup ' echo original >file && git add file && test_tick && git commit -m initial && git tag initial && echo modified >file && git diff --stat -p >patch-0.txt && chmod +x file && git diff --stat -p >patch-1.txt ' test_expect_success FILEMODE 'same mode (no index)' ' git reset --hard && chmod +x file && git apply patch-0.txt && test -x file ' test_expect_success FILEMODE 'same mode (with index)' ' git reset --hard && chmod +x file && git add file && git apply --index patch-0.txt && test -x file && git diff --exit-code ' test_expect_success FILEMODE 'same mode (index only)' ' git reset --hard && chmod +x file && git add file && git apply --cached patch-0.txt && git ls-files -s file | grep "^100755" ' test_expect_success FILEMODE 'mode update (no index)' ' git reset --hard && git apply patch-1.txt && test -x file ' test_expect_success FILEMODE 'mode update (with index)' ' git reset --hard && git apply --index patch-1.txt && test -x file && git diff --exit-code ' test_expect_success FILEMODE 'mode update (index only)' ' git reset --hard && git apply --cached patch-1.txt && git ls-files -s file | grep "^100755" ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"applying patch with mode bits">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\techo original >file &&\n"> <"\tgit add file &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m initial &&\n"> <"\tgit tag initial &&\n"> <"\techo modified >file &&\n"> <"\tgit diff --stat -p >patch-0.txt &&\n"> <"\tchmod +x file &&\n"> <"\tgit diff --stat -p >patch-1.txt\n"> ) } ) (C {(test_expect_success)} {(FILEMODE)} {(SQ <"same mode (no index)">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tchmod +x file &&\n"> <"\tgit apply patch-0.txt &&\n"> <"\ttest -x file\n"> ) } ) (C {(test_expect_success)} {(FILEMODE)} {(SQ <"same mode (with index)">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tchmod +x file &&\n"> <"\tgit add file &&\n"> <"\tgit apply --index patch-0.txt &&\n"> <"\ttest -x file &&\n"> <"\tgit diff --exit-code\n"> ) } ) (C {(test_expect_success)} {(FILEMODE)} {(SQ <"same mode (index only)">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tchmod +x file &&\n"> <"\tgit add file &&\n"> <"\tgit apply --cached patch-0.txt &&\n"> <"\tgit ls-files -s file | grep \"^100755\"\n"> ) } ) (C {(test_expect_success)} {(FILEMODE)} {(SQ <"mode update (no index)">)} {(SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit apply patch-1.txt &&\n"> <"\ttest -x file\n">)} ) (C {(test_expect_success)} {(FILEMODE)} {(SQ <"mode update (with index)">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit apply --index patch-1.txt &&\n"> <"\ttest -x file &&\n"> <"\tgit diff --exit-code\n"> ) } ) (C {(test_expect_success)} {(FILEMODE)} {(SQ <"mode update (index only)">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit apply --cached patch-1.txt &&\n"> <"\tgit ls-files -s file | grep \"^100755\"\n"> ) } ) (C {(test_done)}) ] )