e21b5d27d71eb87af353fdd4b7052f98619303b3
   1#!/bin/sh
   2
   3test_description='CRLF merge conflict across text=auto change
   4
   5* [master] remove .gitattributes
   6 ! [side] add line from b
   7--
   8 + [side] add line from b
   9*  [master] remove .gitattributes
  10*  [master^] add line from a
  11*  [master~2] normalize file
  12*+ [side^] Initial
  13'
  14
  15. ./test-lib.sh
  16
  17test_expect_success setup '
  18        git config merge.renormalize true &&
  19        git config core.autocrlf false &&
  20
  21        echo first line | append_cr >file &&
  22        echo first line >control_file &&
  23        echo only line >inert_file &&
  24
  25        git add file control_file inert_file &&
  26        test_tick &&
  27        git commit -m "Initial" &&
  28        git tag initial &&
  29        git branch side &&
  30
  31        echo "* text=auto" >.gitattributes &&
  32        touch file &&
  33        git add .gitattributes file &&
  34        test_tick &&
  35        git commit -m "normalize file" &&
  36
  37        echo same line | append_cr >>file &&
  38        echo same line >>control_file &&
  39        git add file control_file &&
  40        test_tick &&
  41        git commit -m "add line from a" &&
  42        git tag a &&
  43
  44        git rm .gitattributes &&
  45        rm file &&
  46        git checkout file &&
  47        test_tick &&
  48        git commit -m "remove .gitattributes" &&
  49        git tag c &&
  50
  51        git checkout side &&
  52        echo same line | append_cr >>file &&
  53        echo same line >>control_file &&
  54        git add file control_file &&
  55        test_tick &&
  56        git commit -m "add line from b" &&
  57        git tag b &&
  58
  59        git checkout master
  60'
  61
  62test_expect_success 'Merge after setting text=auto' '
  63        cat <<-\EOF >expected &&
  64        first line
  65        same line
  66        EOF
  67
  68        git rm -fr . &&
  69        rm -f .gitattributes &&
  70        git reset --hard a &&
  71        git merge b &&
  72        test_cmp expected file
  73'
  74
  75test_expect_success 'Merge addition of text=auto' '
  76        cat <<-\EOF >expected &&
  77        first line
  78        same line
  79        EOF
  80
  81        git rm -fr . &&
  82        rm -f .gitattributes &&
  83        git reset --hard b &&
  84        git merge a &&
  85        test_cmp expected file
  86'
  87
  88test_expect_success 'Test delete/normalize conflict' '
  89        git checkout -f side &&
  90        git rm -fr . &&
  91        rm -f .gitattributes &&
  92        git reset --hard initial &&
  93        git rm file &&
  94        git commit -m "remove file" &&
  95        git checkout master &&
  96        git reset --hard a^ &&
  97        git merge side
  98'
  99
 100test_done