t / t4129-apply-samemode.shon commit Merge branch 'jl/submodule-ignore-diff' (cc34bb0)
   1#!/bin/sh
   2
   3test_description='applying patch with mode bits'
   4
   5. ./test-lib.sh
   6
   7if test "$(git config --bool core.filemode)" = false
   8then
   9        say 'filemode disabled on the filesystem'
  10else
  11        test_set_prereq FILEMODE
  12fi
  13
  14test_expect_success setup '
  15        echo original >file &&
  16        git add file &&
  17        test_tick &&
  18        git commit -m initial &&
  19        git tag initial &&
  20        echo modified >file &&
  21        git diff --stat -p >patch-0.txt &&
  22        chmod +x file &&
  23        git diff --stat -p >patch-1.txt
  24'
  25
  26test_expect_success FILEMODE 'same mode (no index)' '
  27        git reset --hard &&
  28        chmod +x file &&
  29        git apply patch-0.txt &&
  30        test -x file
  31'
  32
  33test_expect_success FILEMODE 'same mode (with index)' '
  34        git reset --hard &&
  35        chmod +x file &&
  36        git add file &&
  37        git apply --index patch-0.txt &&
  38        test -x file &&
  39        git diff --exit-code
  40'
  41
  42test_expect_success FILEMODE 'same mode (index only)' '
  43        git reset --hard &&
  44        chmod +x file &&
  45        git add file &&
  46        git apply --cached patch-0.txt &&
  47        git ls-files -s file | grep "^100755"
  48'
  49
  50test_expect_success FILEMODE 'mode update (no index)' '
  51        git reset --hard &&
  52        git apply patch-1.txt &&
  53        test -x file
  54'
  55
  56test_expect_success FILEMODE 'mode update (with index)' '
  57        git reset --hard &&
  58        git apply --index patch-1.txt &&
  59        test -x file &&
  60        git diff --exit-code
  61'
  62
  63test_expect_success FILEMODE 'mode update (index only)' '
  64        git reset --hard &&
  65        git apply --cached patch-1.txt &&
  66        git ls-files -s file | grep "^100755"
  67'
  68
  69test_done