t / t6044-merge-unrelated-index-changes.shon commit Merge branch 'rs/copy-array' (b1f0a85)
   1#!/bin/sh
   2
   3test_description="merges with unrelated index changes"
   4
   5. ./test-lib.sh
   6
   7# Testcase for some simple merges
   8#   A
   9#   o-----o B
  10#    \
  11#     \---o C
  12#      \
  13#       \-o D
  14#        \
  15#         o E
  16#   Commit A: some file a
  17#   Commit B: adds file b, modifies end of a
  18#   Commit C: adds file c
  19#   Commit D: adds file d, modifies beginning of a
  20#   Commit E: renames a->subdir/a, adds subdir/e
  21
  22test_expect_success 'setup trivial merges' '
  23        test_seq 1 10 >a &&
  24        git add a &&
  25        test_tick && git commit -m A &&
  26
  27        git branch A &&
  28        git branch B &&
  29        git branch C &&
  30        git branch D &&
  31        git branch E &&
  32
  33        git checkout B &&
  34        echo b >b &&
  35        echo 11 >>a &&
  36        git add a b &&
  37        test_tick && git commit -m B &&
  38
  39        git checkout C &&
  40        echo c >c &&
  41        git add c &&
  42        test_tick && git commit -m C &&
  43
  44        git checkout D &&
  45        test_seq 2 10 >a &&
  46        echo d >d &&
  47        git add a d &&
  48        test_tick && git commit -m D &&
  49
  50        git checkout E &&
  51        mkdir subdir &&
  52        git mv a subdir/a &&
  53        echo e >subdir/e &&
  54        git add subdir &&
  55        test_tick && git commit -m E
  56'
  57
  58test_expect_success 'ff update' '
  59        git reset --hard &&
  60        git checkout A^0 &&
  61
  62        touch random_file && git add random_file &&
  63
  64        git merge E^0 &&
  65
  66        test_must_fail git rev-parse HEAD:random_file &&
  67        test "$(git diff --name-only --cached E)" = "random_file"
  68'
  69
  70test_expect_success 'ff update, important file modified' '
  71        git reset --hard &&
  72        git checkout A^0 &&
  73
  74        mkdir subdir &&
  75        touch subdir/e &&
  76        git add subdir/e &&
  77
  78        test_must_fail git merge E^0
  79'
  80
  81test_expect_success 'resolve, trivial' '
  82        git reset --hard &&
  83        git checkout B^0 &&
  84
  85        touch random_file && git add random_file &&
  86
  87        test_must_fail git merge -s resolve C^0
  88'
  89
  90test_expect_success 'resolve, non-trivial' '
  91        git reset --hard &&
  92        git checkout B^0 &&
  93
  94        touch random_file && git add random_file &&
  95
  96        test_must_fail git merge -s resolve D^0
  97'
  98
  99test_expect_success 'recursive' '
 100        git reset --hard &&
 101        git checkout B^0 &&
 102
 103        touch random_file && git add random_file &&
 104
 105        test_must_fail git merge -s recursive C^0
 106'
 107
 108test_expect_success 'octopus, unrelated file touched' '
 109        git reset --hard &&
 110        git checkout B^0 &&
 111
 112        touch random_file && git add random_file &&
 113
 114        test_must_fail git merge C^0 D^0
 115'
 116
 117test_expect_success 'octopus, related file removed' '
 118        git reset --hard &&
 119        git checkout B^0 &&
 120
 121        git rm b &&
 122
 123        test_must_fail git merge C^0 D^0
 124'
 125
 126test_expect_success 'octopus, related file modified' '
 127        git reset --hard &&
 128        git checkout B^0 &&
 129
 130        echo 12 >>a && git add a &&
 131
 132        test_must_fail git merge C^0 D^0
 133'
 134
 135test_expect_success 'ours' '
 136        git reset --hard &&
 137        git checkout B^0 &&
 138
 139        touch random_file && git add random_file &&
 140
 141        test_must_fail git merge -s ours C^0
 142'
 143
 144test_expect_success 'subtree' '
 145        git reset --hard &&
 146        git checkout B^0 &&
 147
 148        touch random_file && git add random_file &&
 149
 150        test_must_fail git merge -s subtree E^0
 151'
 152
 153test_done