t / t4300-merge-tree.shon commit status: document the -v/--verbose option (9c589d9)
   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 &&
  29EXPECTED
  30
  31        git reset --hard initial &&
  32        test_commit "add-not-a-b" "ONE" "AAA" &&
  33        git merge-tree initial add-not-a-b initial >actual &&
  34        test_cmp expected actual
  35'
  36
  37test_expect_success 'file add A, B (same)' '
  38        cat >expected <<\EXPECTED &&
  39EXPECTED
  40
  41        git reset --hard initial &&
  42        test_commit "add-a-b-same-A" "ONE" "AAA" &&
  43        git reset --hard initial &&
  44        test_commit "add-a-b-same-B" "ONE" "AAA" &&
  45        git merge-tree initial add-a-b-same-A add-a-b-same-B >actual &&
  46        test_cmp expected actual
  47'
  48
  49test_expect_success 'file add A, B (different)' '
  50        cat >expected <<\EXPECTED &&
  51added in both
  52  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
  53  their  100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
  54@@ -1 +1,5 @@
  55+<<<<<<< .our
  56 AAA
  57+=======
  58+BBB
  59+>>>>>>> .their
  60EXPECTED
  61
  62        git reset --hard initial &&
  63        test_commit "add-a-b-diff-A" "ONE" "AAA" &&
  64        git reset --hard initial &&
  65        test_commit "add-a-b-diff-B" "ONE" "BBB" &&
  66        git merge-tree initial add-a-b-diff-A add-a-b-diff-B >actual &&
  67        test_cmp expected actual
  68'
  69
  70test_expect_success 'file change A, !B' '
  71        cat >expected <<\EXPECTED &&
  72EXPECTED
  73
  74        git reset --hard initial &&
  75        test_commit "change-a-not-b" "initial-file" "BBB" &&
  76        git merge-tree initial change-a-not-b initial >actual &&
  77        test_cmp expected actual
  78'
  79
  80test_expect_success 'file change !A, B' '
  81        cat >expected <<\EXPECTED &&
  82merged
  83  result 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
  84  our    100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
  85@@ -1 +1 @@
  86-initial
  87+BBB
  88EXPECTED
  89
  90        git reset --hard initial &&
  91        test_commit "change-not-a-b" "initial-file" "BBB" &&
  92        git merge-tree initial initial change-not-a-b >actual &&
  93        test_cmp expected actual
  94'
  95
  96test_expect_success 'file change A, B (same)' '
  97        cat >expected <<\EXPECTED &&
  98EXPECTED
  99
 100        git reset --hard initial &&
 101        test_commit "change-a-b-same-A" "initial-file" "AAA" &&
 102        git reset --hard initial &&
 103        test_commit "change-a-b-same-B" "initial-file" "AAA" &&
 104        git merge-tree initial change-a-b-same-A change-a-b-same-B >actual &&
 105        test_cmp expected actual
 106'
 107
 108test_expect_success 'file change A, B (different)' '
 109        cat >expected <<\EXPECTED &&
 110changed in both
 111  base   100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
 112  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d initial-file
 113  their  100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file
 114@@ -1 +1,5 @@
 115+<<<<<<< .our
 116 AAA
 117+=======
 118+BBB
 119+>>>>>>> .their
 120EXPECTED
 121
 122        git reset --hard initial &&
 123        test_commit "change-a-b-diff-A" "initial-file" "AAA" &&
 124        git reset --hard initial &&
 125        test_commit "change-a-b-diff-B" "initial-file" "BBB" &&
 126        git merge-tree initial change-a-b-diff-A change-a-b-diff-B >actual &&
 127        test_cmp expected actual
 128'
 129
 130test_expect_success 'file change A, B (mixed)' '
 131        cat >expected <<\EXPECTED &&
 132changed in both
 133  base   100644 f4f1f998c7776568c4ff38f516d77fef9399b5a7 ONE
 134  our    100644 af14c2c3475337c73759d561ef70b59e5c731176 ONE
 135  their  100644 372d761493f524d44d59bd24700c3bdf914c973c ONE
 136@@ -7,7 +7,11 @@
 137 AAA
 138 AAA
 139 AAA
 140+<<<<<<< .our
 141 BBB
 142+=======
 143+CCC
 144+>>>>>>> .their
 145 AAA
 146 AAA
 147 AAA
 148EXPECTED
 149
 150        git reset --hard initial &&
 151        test_commit "change-a-b-mix-base" "ONE" "
 152AAA
 153AAA
 154AAA
 155AAA
 156AAA
 157AAA
 158AAA
 159AAA
 160AAA
 161AAA
 162AAA
 163AAA
 164AAA
 165AAA
 166AAA" &&
 167        test_commit "change-a-b-mix-A" "ONE" \
 168                "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/BBB/;}" <ONE)" &&
 169        git reset --hard change-a-b-mix-base &&
 170        test_commit "change-a-b-mix-B" "ONE" \
 171                "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/CCC/;}" <ONE)" &&
 172        git merge-tree change-a-b-mix-base change-a-b-mix-A change-a-b-mix-B \
 173                >actual &&
 174        test_cmp expected actual
 175'
 176
 177test_expect_success 'file remove A, !B' '
 178        cat >expected <<\EXPECTED &&
 179EXPECTED
 180
 181        git reset --hard initial &&
 182        test_commit "rm-a-not-b-base" "ONE" "AAA" &&
 183        git rm ONE &&
 184        git commit -m "rm-a-not-b" &&
 185        git tag "rm-a-not-b" &&
 186        git merge-tree rm-a-not-b-base rm-a-not-b rm-a-not-b-base >actual &&
 187        test_cmp expected actual
 188'
 189
 190test_expect_success 'file remove !A, B' '
 191        cat >expected <<\EXPECTED &&
 192removed in remote
 193  base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 194  our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 195@@ -1 +0,0 @@
 196-AAA
 197EXPECTED
 198
 199        git reset --hard initial &&
 200        test_commit "rm-not-a-b-base" "ONE" "AAA" &&
 201        git rm ONE &&
 202        git commit -m "rm-not-a-b" &&
 203        git tag "rm-not-a-b" &&
 204        git merge-tree rm-a-not-b-base rm-a-not-b-base rm-a-not-b >actual &&
 205        test_cmp expected actual
 206'
 207
 208test_expect_success 'file remove A, B (same)' '
 209        cat >expected <<\EXPECTED &&
 210EXPECTED
 211
 212        git reset --hard initial &&
 213        test_commit "rm-a-b-base" "ONE" "AAA" &&
 214        git rm ONE &&
 215        git commit -m "rm-a-b" &&
 216        git tag "rm-a-b" &&
 217        git merge-tree rm-a-b-base rm-a-b rm-a-b >actual &&
 218        test_cmp expected actual
 219'
 220
 221test_expect_success 'file change A, remove B' '
 222        cat >expected <<\EXPECTED &&
 223removed in remote
 224  base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 225  our    100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
 226@@ -1 +0,0 @@
 227-BBB
 228EXPECTED
 229
 230        git reset --hard initial &&
 231        test_commit "change-a-rm-b-base" "ONE" "AAA" &&
 232        test_commit "change-a-rm-b-A" "ONE" "BBB" &&
 233        git reset --hard change-a-rm-b-base &&
 234        git rm ONE &&
 235        git commit -m "change-a-rm-b-B" &&
 236        git tag "change-a-rm-b-B" &&
 237        git merge-tree change-a-rm-b-base change-a-rm-b-A change-a-rm-b-B \
 238                >actual &&
 239        test_cmp expected actual
 240'
 241
 242test_expect_success 'file remove A, change B' '
 243        cat >expected <<\EXPECTED &&
 244removed in local
 245  base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE
 246  their  100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE
 247EXPECTED
 248
 249        git reset --hard initial &&
 250        test_commit "rm-a-change-b-base" "ONE" "AAA" &&
 251
 252        git rm ONE &&
 253        git commit -m "rm-a-change-b-A" &&
 254        git tag "rm-a-change-b-A" &&
 255        git reset --hard rm-a-change-b-base &&
 256        test_commit "rm-a-change-b-B" "ONE" "BBB" &&
 257        git merge-tree rm-a-change-b-base rm-a-change-b-A rm-a-change-b-B \
 258                >actual &&
 259        test_cmp expected actual
 260'
 261
 262test_expect_success 'tree add A, B (same)' '
 263        cat >expect <<-\EOF &&
 264        EOF
 265        git reset --hard initial &&
 266        mkdir sub &&
 267        test_commit "add sub/file" "sub/file" "file" add-tree-A &&
 268        git merge-tree initial add-tree-A add-tree-A >actual &&
 269        test_cmp expect actual
 270'
 271
 272test_expect_success 'tree add A, B (different)' '
 273        cat >expect <<-\EOF &&
 274        added in both
 275          our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file
 276          their  100644 ba629238ca89489f2b350e196ca445e09d8bb834 sub/file
 277        @@ -1 +1,5 @@
 278        +<<<<<<< .our
 279         AAA
 280        +=======
 281        +BBB
 282        +>>>>>>> .their
 283        EOF
 284        git reset --hard initial &&
 285        mkdir sub &&
 286        test_commit "add sub/file" "sub/file" "AAA" add-tree-a-b-A &&
 287        git reset --hard initial &&
 288        mkdir sub &&
 289        test_commit "add sub/file" "sub/file" "BBB" add-tree-a-b-B &&
 290        git merge-tree initial add-tree-a-b-A add-tree-a-b-B >actual &&
 291        test_cmp expect actual
 292'
 293
 294test_expect_success 'tree unchanged A, removed B' '
 295        cat >expect <<-\EOF &&
 296        removed in remote
 297          base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file
 298          our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file
 299        @@ -1 +0,0 @@
 300        -AAA
 301        EOF
 302        git reset --hard initial &&
 303        mkdir sub &&
 304        test_commit "add sub/file" "sub/file" "AAA" tree-remove-b-initial &&
 305        git rm sub/file &&
 306        test_tick &&
 307        git commit -m "remove sub/file" &&
 308        git tag tree-remove-b-B &&
 309        git merge-tree tree-remove-b-initial tree-remove-b-initial tree-remove-b-B >actual &&
 310        test_cmp expect actual
 311'
 312
 313test_expect_success 'turn file to tree' '
 314        git reset --hard initial &&
 315        rm initial-file &&
 316        mkdir initial-file &&
 317        test_commit "turn-file-to-tree" "initial-file/ONE" "CCC" &&
 318        git merge-tree initial initial turn-file-to-tree >actual &&
 319        cat >expect <<-\EOF &&
 320        added in remote
 321          their  100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 initial-file/ONE
 322        @@ -0,0 +1 @@
 323        +CCC
 324        removed in remote
 325          base   100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
 326          our    100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file
 327        @@ -1 +0,0 @@
 328        -initial
 329        EOF
 330        test_cmp expect actual
 331'
 332
 333test_expect_success 'turn tree to file' '
 334        git reset --hard initial &&
 335        mkdir dir &&
 336        test_commit "add-tree" "dir/path" "AAA" &&
 337        test_commit "add-another-tree" "dir/another" "BBB" &&
 338        rm -fr dir &&
 339        test_commit "make-file" "dir" "CCC" &&
 340        git merge-tree add-tree add-another-tree make-file >actual &&
 341        cat >expect <<-\EOF &&
 342        removed in remote
 343          base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
 344          our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d dir/path
 345        @@ -1 +0,0 @@
 346        -AAA
 347        added in remote
 348          their  100644 43aa4fdec31eb92e1fdc2f0ce6ea9ddb7c32bcf7 dir
 349        @@ -0,0 +1 @@
 350        +CCC
 351        EOF
 352        test_cmp expect actual
 353'
 354
 355test_done