t / t6022-merge-rename.shon commit GIT 0.99.9n aka 1.0rc6 (1ed9193)
   1#!/bin/sh
   2
   3test_description='Merge-recursive merging renames'
   4. ./test-lib.sh
   5
   6test_expect_success setup \
   7'
   8cat >A <<\EOF &&
   9a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  10b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  11c cccccccccccccccccccccccccccccccccccccccccccccccc
  12d dddddddddddddddddddddddddddddddddddddddddddddddd
  13e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
  14f ffffffffffffffffffffffffffffffffffffffffffffffff
  15g gggggggggggggggggggggggggggggggggggggggggggggggg
  16h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
  17i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
  18j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
  19k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
  20l llllllllllllllllllllllllllllllllllllllllllllllll
  21m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
  22n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
  23o oooooooooooooooooooooooooooooooooooooooooooooooo
  24EOF
  25
  26cat >M <<\EOF &&
  27A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  28B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
  29C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
  30D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  31E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
  32F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
  33G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
  34H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
  35I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
  36J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
  37K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
  38L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
  39M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
  40N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
  41O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
  42EOF
  43
  44git add A M &&
  45git commit -m initial &&
  46git branch white &&
  47git branch red &&
  48git branch blue &&
  49
  50sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
  51mv A+ A &&
  52git commit -a -m "master updates A" &&
  53
  54git checkout white &&
  55sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
  56sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
  57rm -f A M &&
  58git update-index --add --remove A B M N &&
  59git commit -m "white renames A->B, M->N" &&
  60
  61git checkout red &&
  62sed -e "/^g /s/.*/g : red changes a line/" <A >B &&
  63sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
  64rm -f A M &&
  65git update-index --add --remove A B M N &&
  66git commit -m "red renames A->B, M->N" &&
  67
  68git checkout blue &&
  69sed -e "/^g /s/.*/g : blue changes a line/" <A >C &&
  70sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
  71rm -f A M &&
  72git update-index --add --remove A C M N &&
  73git commit -m "blue renames A->C, M->N" &&
  74
  75git checkout master'
  76
  77test_expect_success 'pull renaming branch into unrenaming one' \
  78'
  79        git show-branch
  80        git pull . white && {
  81                echo "BAD: should have conflicted"
  82                exit 1
  83        }
  84        git ls-files -s
  85        test "$(git ls-files -u B | wc -l)" -eq 3 || {
  86                echo "BAD: should have left stages for B"
  87                exit 1  
  88        }
  89        test "$(git ls-files -s N | wc -l)" -eq 1 || {
  90                echo "BAD: should have merged N"
  91                exit 1  
  92        }
  93        sed -ne "/^g/{
  94        p
  95        q
  96        }" B | grep master || {
  97                echo "BAD: should have listed our change first"
  98                exit 1
  99        }
 100        test "$(git diff white N | wc -l)" -eq 0 || {
 101                echo "BAD: should have taken colored branch"
 102                exit 1
 103        }
 104'
 105
 106test_expect_success 'pull renaming branch into another renaming one' \
 107'
 108        git reset --hard
 109        git checkout red
 110        git pull . white && {
 111                echo "BAD: should have conflicted"
 112                exit 1
 113        }
 114        test "$(git ls-files -u B | wc -l)" -eq 3 || {
 115                echo "BAD: should have left stages"
 116                exit 1  
 117        }
 118        test "$(git ls-files -s N | wc -l)" -eq 1 || {
 119                echo "BAD: should have merged N"
 120                exit 1  
 121        }
 122        sed -ne "/^g/{
 123        p
 124        q
 125        }" B | grep red || {
 126                echo "BAD: should have listed our change first"
 127                exit 1
 128        }
 129        test "$(git diff white N | wc -l)" -eq 0 || {
 130                echo "BAD: should have taken colored branch"
 131                exit 1
 132        }
 133'
 134
 135test_expect_success 'pull unrenaming branch into renaming one' \
 136'
 137        git reset --hard
 138        git show-branch
 139        git pull . master && {
 140                echo "BAD: should have conflicted"
 141                exit 1
 142        }
 143        test "$(git ls-files -u B | wc -l)" -eq 3 || {
 144                echo "BAD: should have left stages"
 145                exit 1  
 146        }
 147        test "$(git ls-files -s N | wc -l)" -eq 1 || {
 148                echo "BAD: should have merged N"
 149                exit 1  
 150        }
 151        sed -ne "/^g/{
 152        p
 153        q
 154        }" B | grep red || {
 155                echo "BAD: should have listed our change first"
 156                exit 1
 157        }
 158        test "$(git diff white N | wc -l)" -eq 0 || {
 159                echo "BAD: should have taken colored branch"
 160                exit 1
 161        }
 162'
 163
 164test_done