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