t / t6031-merge-recursive.shon commit Merge branch 'jn/merge-custom-no-trivial' (460645a)
   1#!/bin/sh
   2
   3test_description='merge-recursive: handle file mode'
   4. ./test-lib.sh
   5
   6if ! test "$(git config --bool core.filemode)" = false
   7then
   8        test_set_prereq FILEMODE
   9fi
  10
  11test_expect_success 'mode change in one branch: keep changed version' '
  12        : >file1 &&
  13        git add file1 &&
  14        git commit -m initial &&
  15        git checkout -b a1 master &&
  16        : >dummy &&
  17        git add dummy &&
  18        git commit -m a &&
  19        git checkout -b b1 master &&
  20        test_chmod +x file1 &&
  21        git commit -m b1 &&
  22        git checkout a1 &&
  23        git merge-recursive master -- a1 b1 &&
  24        git ls-files -s file1 | grep ^100755
  25'
  26
  27test_expect_success FILEMODE 'verify executable bit on file' '
  28        test -x file1
  29'
  30
  31test_expect_success 'mode change in both branches: expect conflict' '
  32        git reset --hard HEAD &&
  33        git checkout -b a2 master &&
  34        : >file2 &&
  35        H=$(git hash-object file2) &&
  36        test_chmod +x file2 &&
  37        git commit -m a2 &&
  38        git checkout -b b2 master &&
  39        : >file2 &&
  40        git add file2 &&
  41        git commit -m b2 &&
  42        git checkout a2 &&
  43        (
  44                git merge-recursive master -- a2 b2
  45                test $? = 1
  46        ) &&
  47        git ls-files -u >actual &&
  48        (
  49                echo "100755 $H 2       file2"
  50                echo "100644 $H 3       file2"
  51        ) >expect &&
  52        test_cmp actual expect &&
  53        git ls-files -s file2 | grep ^100755
  54'
  55
  56test_expect_success FILEMODE 'verify executable bit on file' '
  57        test -x file2
  58'
  59
  60test_expect_success 'merging with triple rename across D/F conflict' '
  61        git reset --hard HEAD &&
  62        git checkout -b main &&
  63        git rm -rf . &&
  64
  65        echo "just a file" >sub1 &&
  66        mkdir -p sub2 &&
  67        echo content1 >sub2/file1 &&
  68        echo content2 >sub2/file2 &&
  69        echo content3 >sub2/file3 &&
  70        mkdir simple &&
  71        echo base >simple/bar &&
  72        git add -A &&
  73        test_tick &&
  74        git commit -m base &&
  75
  76        git checkout -b other &&
  77        echo more >>simple/bar &&
  78        test_tick &&
  79        git commit -a -m changesimplefile &&
  80
  81        git checkout main &&
  82        git rm sub1 &&
  83        git mv sub2 sub1 &&
  84        test_tick &&
  85        git commit -m changefiletodir &&
  86
  87        test_tick &&
  88        git merge other
  89'
  90
  91test_done