t / t4300-merge-tree.shon commit git p4: import/export of labels to/from p4 (06804c7)
   1#!/bin/sh
   2#
   3# Copyright (c) 2010 Will Palmer
   4#
   5
   6test_description='git merge-tree'
   7. ./test-lib.sh
   8
   9test_expect_success setup '
  10        test_commit "initial" "initial-file" "initial"
  11'
  12
  13test_expect_success 'file add A, !B' '
  14        cat >expected <<\EXPECTED &&
  15added in remote
  16  their  100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
  17@@ -0,0 +1 @@
  18+AAA
  19EXPECTED
  20
  21        git reset --hard initial &&
  22        test_commit "add-a-not-b" "ONE" "AAA" &&
  23        git merge-tree initial initial add-a-not-b >actual &&
  24        test_cmp expected actual
  25'
  26
  27test_expect_success 'file add !A, B' '
  28        cat >expected <<\EXPECTED &&
  29added in local
  30  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
  31EXPECTED
  32
  33        git reset --hard initial &&
  34        test_commit "add-not-a-b" "ONE" "AAA" &&
  35        git merge-tree initial add-not-a-b initial >actual &&
  36        test_cmp expected actual
  37'
  38
  39test_expect_success 'file add A, B (same)' '
  40        cat >expected <<\EXPECTED &&
  41added in both
  42  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
  43  their  100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
  44EXPECTED
  45
  46        git reset --hard initial &&
  47        test_commit "add-a-b-same-A" "ONE" "AAA" &&
  48        git reset --hard initial &&
  49        test_commit "add-a-b-same-B" "ONE" "AAA" &&
  50        git merge-tree initial add-a-b-same-A add-a-b-same-B >actual &&
  51        test_cmp expected actual
  52'
  53
  54test_expect_success 'file add A, B (different)' '
  55        cat >expected <<\EXPECTED &&
  56added in both
  57  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
  58  their  100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
  59@@ -1 +1,5 @@
  60+<<<<<<< .our
  61 AAA
  62+=======
  63+BBB
  64+>>>>>>> .their
  65EXPECTED
  66
  67        git reset --hard initial &&
  68        test_commit "add-a-b-diff-A" "ONE" "AAA" &&
  69        git reset --hard initial &&
  70        test_commit "add-a-b-diff-B" "ONE" "BBB" &&
  71        git merge-tree initial add-a-b-diff-A add-a-b-diff-B >actual &&
  72        test_cmp expected actual
  73'
  74
  75test_expect_success 'file change A, !B' '
  76        cat >expected <<\EXPECTED &&
  77EXPECTED
  78
  79        git reset --hard initial &&
  80        test_commit "change-a-not-b" "initial-file" "BBB" &&
  81        git merge-tree initial change-a-not-b initial >actual &&
  82        test_cmp expected actual
  83'
  84
  85test_expect_success 'file change !A, B' '
  86        cat >expected <<\EXPECTED &&
  87merged
  88  result 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
  89  our    100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
  90@@ -1 +1 @@
  91-initial
  92+BBB
  93EXPECTED
  94
  95        git reset --hard initial &&
  96        test_commit "change-not-a-b" "initial-file" "BBB" &&
  97        git merge-tree initial initial change-not-a-b >actual &&
  98        test_cmp expected actual
  99'
 100
 101test_expect_success 'file change A, B (same)' '
 102        cat >expected <<\EXPECTED &&
 103EXPECTED
 104
 105        git reset --hard initial &&
 106        test_commit "change-a-b-same-A" "initial-file" "AAA" &&
 107        git reset --hard initial &&
 108        test_commit "change-a-b-same-B" "initial-file" "AAA" &&
 109        git merge-tree initial change-a-b-same-A change-a-b-same-B >actual &&
 110        test_cmp expected actual
 111'
 112
 113test_expect_success 'file change A, B (different)' '
 114        cat >expected <<\EXPECTED &&
 115changed in both
 116  base   100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
 117  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d initial-file
 118  their  100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
 119@@ -1 +1,5 @@
 120+<<<<<<< .our
 121 AAA
 122+=======
 123+BBB
 124+>>>>>>> .their
 125EXPECTED
 126
 127        git reset --hard initial &&
 128        test_commit "change-a-b-diff-A" "initial-file" "AAA" &&
 129        git reset --hard initial &&
 130        test_commit "change-a-b-diff-B" "initial-file" "BBB" &&
 131        git merge-tree initial change-a-b-diff-A change-a-b-diff-B >actual &&
 132        test_cmp expected actual
 133'
 134
 135test_expect_success 'file change A, B (mixed)' '
 136        cat >expected <<\EXPECTED &&
 137changed in both
 138  base   100644 f4f1f998c7776568c4ff38f516d77fef9399b5a7 ONE
 139  our    100644 af14c2c3475337c73759d561ef70b59e5c731176 ONE
 140  their  100644 372d761493f524d44d59bd24700c3bdf914c973c ONE
 141@@ -7,7 +7,11 @@
 142 AAA
 143 AAA
 144 AAA
 145+<<<<<<< .our
 146 BBB
 147+=======
 148+CCC
 149+>>>>>>> .their
 150 AAA
 151 AAA
 152 AAA
 153EXPECTED
 154
 155        git reset --hard initial &&
 156        test_commit "change-a-b-mix-base" "ONE" "
 157AAA
 158AAA
 159AAA
 160AAA
 161AAA
 162AAA
 163AAA
 164AAA
 165AAA
 166AAA
 167AAA
 168AAA
 169AAA
 170AAA
 171AAA" &&
 172        test_commit "change-a-b-mix-A" "ONE" \
 173                "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/BBB/;}" <ONE)" &&
 174        git reset --hard change-a-b-mix-base &&
 175        test_commit "change-a-b-mix-B" "ONE" \
 176                "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/CCC/;}" <ONE)" &&
 177        git merge-tree change-a-b-mix-base change-a-b-mix-A change-a-b-mix-B \
 178                >actual &&
 179        test_cmp expected actual
 180'
 181
 182test_expect_success 'file remove A, !B' '
 183        cat >expected <<\EXPECTED &&
 184removed in local
 185  base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 186  their  100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 187EXPECTED
 188
 189        git reset --hard initial &&
 190        test_commit "rm-a-not-b-base" "ONE" "AAA" &&
 191        git rm ONE &&
 192        git commit -m "rm-a-not-b" &&
 193        git tag "rm-a-not-b" &&
 194        git merge-tree rm-a-not-b-base rm-a-not-b rm-a-not-b-base >actual &&
 195        test_cmp expected actual
 196'
 197
 198test_expect_success 'file remove !A, B' '
 199        cat >expected <<\EXPECTED &&
 200removed in remote
 201  base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 202  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 203@@ -1 +0,0 @@
 204-AAA
 205EXPECTED
 206
 207        git reset --hard initial &&
 208        test_commit "rm-not-a-b-base" "ONE" "AAA" &&
 209        git rm ONE &&
 210        git commit -m "rm-not-a-b" &&
 211        git tag "rm-not-a-b" &&
 212        git merge-tree rm-a-not-b-base rm-a-not-b-base rm-a-not-b >actual &&
 213        test_cmp expected actual
 214'
 215
 216test_expect_success 'file change A, remove B' '
 217        cat >expected <<\EXPECTED &&
 218removed in remote
 219  base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 220  our    100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
 221@@ -1 +0,0 @@
 222-BBB
 223EXPECTED
 224
 225        git reset --hard initial &&
 226        test_commit "change-a-rm-b-base" "ONE" "AAA" &&
 227        test_commit "change-a-rm-b-A" "ONE" "BBB" &&
 228        git reset --hard change-a-rm-b-base &&
 229        git rm ONE &&
 230        git commit -m "change-a-rm-b-B" &&
 231        git tag "change-a-rm-b-B" &&
 232        git merge-tree change-a-rm-b-base change-a-rm-b-A change-a-rm-b-B \
 233                >actual &&
 234        test_cmp expected actual
 235'
 236
 237test_expect_success 'file remove A, change B' '
 238        cat >expected <<\EXPECTED &&
 239removed in local
 240  base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 241  their  100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
 242EXPECTED
 243
 244        git reset --hard initial &&
 245        test_commit "rm-a-change-b-base" "ONE" "AAA" &&
 246
 247        git rm ONE &&
 248        git commit -m "rm-a-change-b-A" &&
 249        git tag "rm-a-change-b-A" &&
 250        git reset --hard rm-a-change-b-base &&
 251        test_commit "rm-a-change-b-B" "ONE" "BBB" &&
 252        git merge-tree rm-a-change-b-base rm-a-change-b-A rm-a-change-b-B \
 253                >actual &&
 254        test_cmp expected actual
 255'
 256
 257test_done