t / t4129-apply-samemode.shon commit Sync with v1.8.2.3 (b387c77)
   1#!/bin/sh
   2
   3test_description='applying patch with mode bits'
   4
   5. ./test-lib.sh
   6. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
   7
   8test_expect_success setup '
   9        echo original >file &&
  10        git add file &&
  11        test_tick &&
  12        git commit -m initial &&
  13        git tag initial &&
  14        echo modified >file &&
  15        git diff --stat -p >patch-0.txt &&
  16        chmod +x file &&
  17        git diff --stat -p >patch-1.txt
  18'
  19
  20test_expect_success FILEMODE 'same mode (no index)' '
  21        git reset --hard &&
  22        chmod +x file &&
  23        git apply patch-0.txt &&
  24        test -x file
  25'
  26
  27test_expect_success FILEMODE 'same mode (with index)' '
  28        git reset --hard &&
  29        chmod +x file &&
  30        git add file &&
  31        git apply --index patch-0.txt &&
  32        test -x file &&
  33        git diff --exit-code
  34'
  35
  36test_expect_success FILEMODE 'same mode (index only)' '
  37        git reset --hard &&
  38        chmod +x file &&
  39        git add file &&
  40        git apply --cached patch-0.txt &&
  41        git ls-files -s file | grep "^100755"
  42'
  43
  44test_expect_success FILEMODE 'mode update (no index)' '
  45        git reset --hard &&
  46        git apply patch-1.txt &&
  47        test -x file
  48'
  49
  50test_expect_success FILEMODE 'mode update (with index)' '
  51        git reset --hard &&
  52        git apply --index patch-1.txt &&
  53        test -x file &&
  54        git diff --exit-code
  55'
  56
  57test_expect_success FILEMODE 'mode update (index only)' '
  58        git reset --hard &&
  59        git apply --cached patch-1.txt &&
  60        git ls-files -s file | grep "^100755"
  61'
  62
  63test_done