t / t6023-merge-rename-nocruft.shon commit Merge git://git.kernel.org/pub/scm/gitk/gitk (6bc4c72)
   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 has A and M" &&
  46git branch white &&
  47git branch red &&
  48git branch blue &&
  49
  50git checkout white &&
  51sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
  52sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
  53rm -f A M &&
  54git update-index --add --remove A B M N &&
  55git commit -m "white renames A->B, M->N" &&
  56
  57git checkout red &&
  58echo created by red >R &&
  59git update-index --add R &&
  60git commit -m "red creates R" &&
  61
  62git checkout blue &&
  63sed -e "/^o /s/.*/g : blue changes a line/" <A >B &&
  64rm -f A &&
  65mv B A &&
  66git update-index A &&
  67git commit -m "blue modify A" &&
  68
  69git checkout master'
  70
  71# This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae
  72test_expect_success 'merge white into red (A->B,M->N)' \
  73'
  74        git checkout -b red-white red &&
  75        git merge white &&
  76        git write-tree >/dev/null || {
  77                echo "BAD: merge did not complete"
  78                return 1
  79        }
  80
  81        test -f B || {
  82                echo "BAD: B does not exist in working directory"
  83                return 1
  84        }
  85        test -f N || {
  86                echo "BAD: N does not exist in working directory"
  87                return 1
  88        }
  89        test -f R || {
  90                echo "BAD: R does not exist in working directory"
  91                return 1
  92        }
  93
  94        test -f A && {
  95                echo "BAD: A still exists in working directory"
  96                return 1
  97        }
  98        test -f M && {
  99                echo "BAD: M still exists in working directory"
 100                return 1
 101        }
 102        return 0
 103'
 104
 105# This test broke in 8371234ecaaf6e14fe3f2082a855eff1bbd79ae9
 106test_expect_success 'merge blue into white (A->B, mod A, A untracked)' \
 107'
 108        git checkout -b white-blue white &&
 109        echo dirty >A &&
 110        git merge blue &&
 111        git write-tree >/dev/null || {
 112                echo "BAD: merge did not complete"
 113                return 1
 114        }
 115
 116        test -f A || {
 117                echo "BAD: A does not exist in working directory"
 118                return 1
 119        }
 120        test `cat A` = dirty || {
 121                echo "BAD: A content is wrong"
 122                return 1
 123        }
 124        test -f B || {
 125                echo "BAD: B does not exist in working directory"
 126                return 1
 127        }
 128        test -f N || {
 129                echo "BAD: N does not exist in working directory"
 130                return 1
 131        }
 132        test -f M && {
 133                echo "BAD: M still exists in working directory"
 134                return 1
 135        }
 136        return 0
 137'
 138
 139test_done