t / t6200-fmt-merge-msg.shon commit Merge branch 'maint-1.7.1' into maint-1.7.2 (6a7f71d)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006, Junio C Hamano
   4#
   5
   6test_description='fmt-merge-msg test'
   7
   8. ./test-lib.sh
   9
  10test_expect_success setup '
  11        echo one >one &&
  12        git add one &&
  13        test_tick &&
  14        git commit -m "Initial" &&
  15
  16        git clone . remote &&
  17
  18        echo uno >one &&
  19        echo dos >two &&
  20        git add two &&
  21        test_tick &&
  22        git commit -a -m "Second" &&
  23
  24        git checkout -b left &&
  25
  26        echo "c1" >one &&
  27        test_tick &&
  28        git commit -a -m "Common #1" &&
  29
  30        echo "c2" >one &&
  31        test_tick &&
  32        git commit -a -m "Common #2" &&
  33
  34        git branch right &&
  35
  36        echo "l3" >two &&
  37        test_tick &&
  38        git commit -a -m "Left #3" &&
  39
  40        echo "l4" >two &&
  41        test_tick &&
  42        git commit -a -m "Left #4" &&
  43
  44        echo "l5" >two &&
  45        test_tick &&
  46        git commit -a -m "Left #5" &&
  47        git tag tag-l5 &&
  48
  49        git checkout right &&
  50
  51        echo "r3" >three &&
  52        git add three &&
  53        test_tick &&
  54        git commit -a -m "Right #3" &&
  55        git tag tag-r3 &&
  56
  57        echo "r4" >three &&
  58        test_tick &&
  59        git commit -a -m "Right #4" &&
  60
  61        echo "r5" >three &&
  62        test_tick &&
  63        git commit -a -m "Right #5" &&
  64
  65        git checkout -b long &&
  66        i=0 &&
  67        while test $i -lt 30
  68        do
  69                test_commit $i one &&
  70                i=$(($i+1))
  71        done &&
  72
  73        git show-branch
  74'
  75
  76cat >expected <<\EOF
  77Merge branch 'left'
  78EOF
  79
  80test_expect_success 'merge-msg test #1' '
  81
  82        git checkout master &&
  83        git fetch . left &&
  84
  85        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
  86        test_cmp expected actual
  87'
  88
  89cat >expected <<EOF
  90Merge branch 'left' of $(pwd)
  91EOF
  92
  93test_expect_success 'merge-msg test #2' '
  94
  95        git checkout master &&
  96        git fetch "$(pwd)" left &&
  97
  98        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
  99        test_cmp expected actual
 100'
 101
 102cat >expected <<\EOF
 103Merge branch 'left'
 104
 105* left:
 106  Left #5
 107  Left #4
 108  Left #3
 109  Common #2
 110  Common #1
 111EOF
 112
 113test_expect_success 'merge-msg test #3-1' '
 114
 115        git config --unset-all merge.log
 116        git config --unset-all merge.summary
 117        git config merge.log true &&
 118
 119        git checkout master &&
 120        test_tick &&
 121        git fetch . left &&
 122
 123        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 124        test_cmp expected actual
 125'
 126
 127test_expect_success 'merge-msg test #3-2' '
 128
 129        git config --unset-all merge.log
 130        git config --unset-all merge.summary
 131        git config merge.summary true &&
 132
 133        git checkout master &&
 134        test_tick &&
 135        git fetch . left &&
 136
 137        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 138        test_cmp expected actual
 139'
 140
 141cat >expected <<\EOF
 142Merge branches 'left' and 'right'
 143
 144* left:
 145  Left #5
 146  Left #4
 147  Left #3
 148  Common #2
 149  Common #1
 150
 151* right:
 152  Right #5
 153  Right #4
 154  Right #3
 155  Common #2
 156  Common #1
 157EOF
 158
 159test_expect_success 'merge-msg test #4-1' '
 160
 161        git config --unset-all merge.log
 162        git config --unset-all merge.summary
 163        git config merge.log true &&
 164
 165        git checkout master &&
 166        test_tick &&
 167        git fetch . left right &&
 168
 169        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 170        test_cmp expected actual
 171'
 172
 173test_expect_success 'merge-msg test #4-2' '
 174
 175        git config --unset-all merge.log
 176        git config --unset-all merge.summary
 177        git config merge.summary true &&
 178
 179        git checkout master &&
 180        test_tick &&
 181        git fetch . left right &&
 182
 183        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 184        test_cmp expected actual
 185'
 186
 187test_expect_success 'merge-msg test #5-1' '
 188
 189        git config --unset-all merge.log
 190        git config --unset-all merge.summary
 191        git config merge.log yes &&
 192
 193        git checkout master &&
 194        test_tick &&
 195        git fetch . left right &&
 196
 197        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 198        test_cmp expected actual
 199'
 200
 201test_expect_success 'merge-msg test #5-2' '
 202
 203        git config --unset-all merge.log
 204        git config --unset-all merge.summary
 205        git config merge.summary yes &&
 206
 207        git checkout master &&
 208        test_tick &&
 209        git fetch . left right &&
 210
 211        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 212        test_cmp expected actual
 213'
 214
 215test_expect_success 'merge-msg -F' '
 216
 217        git config --unset-all merge.log
 218        git config --unset-all merge.summary
 219        git config merge.summary yes &&
 220
 221        git checkout master &&
 222        test_tick &&
 223        git fetch . left right &&
 224
 225        git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
 226        test_cmp expected actual
 227'
 228
 229test_expect_success 'merge-msg -F in subdirectory' '
 230
 231        git config --unset-all merge.log
 232        git config --unset-all merge.summary
 233        git config merge.summary yes &&
 234
 235        git checkout master &&
 236        test_tick &&
 237        git fetch . left right &&
 238        mkdir sub &&
 239        cp .git/FETCH_HEAD sub/FETCH_HEAD &&
 240        (
 241                cd sub &&
 242                git fmt-merge-msg -F FETCH_HEAD >../actual
 243        ) &&
 244        test_cmp expected actual
 245'
 246
 247test_expect_success 'merge-msg with nothing to merge' '
 248
 249        git config --unset-all merge.log
 250        git config --unset-all merge.summary
 251        git config merge.summary yes &&
 252
 253        (
 254                cd remote &&
 255                git checkout -b unrelated &&
 256                test_tick &&
 257                git fetch origin &&
 258                git fmt-merge-msg <.git/FETCH_HEAD >../actual
 259        ) &&
 260
 261        test_cmp /dev/null actual
 262'
 263
 264cat >expected <<\EOF
 265Merge tag 'tag-r3'
 266
 267* tag 'tag-r3':
 268  Right #3
 269  Common #2
 270  Common #1
 271EOF
 272
 273test_expect_success 'merge-msg tag' '
 274
 275        git config --unset-all merge.log
 276        git config --unset-all merge.summary
 277        git config merge.summary yes &&
 278
 279        git checkout master &&
 280        test_tick &&
 281        git fetch . tag tag-r3 &&
 282
 283        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 284        test_cmp expected actual
 285'
 286
 287cat >expected <<\EOF
 288Merge tags 'tag-r3' and 'tag-l5'
 289
 290* tag 'tag-r3':
 291  Right #3
 292  Common #2
 293  Common #1
 294
 295* tag 'tag-l5':
 296  Left #5
 297  Left #4
 298  Left #3
 299  Common #2
 300  Common #1
 301EOF
 302
 303test_expect_success 'merge-msg two tags' '
 304
 305        git config --unset-all merge.log
 306        git config --unset-all merge.summary
 307        git config merge.summary yes &&
 308
 309        git checkout master &&
 310        test_tick &&
 311        git fetch . tag tag-r3 tag tag-l5 &&
 312
 313        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 314        test_cmp expected actual
 315'
 316
 317cat >expected <<\EOF
 318Merge branch 'left', tag 'tag-r3'
 319
 320* tag 'tag-r3':
 321  Right #3
 322  Common #2
 323  Common #1
 324
 325* left:
 326  Left #5
 327  Left #4
 328  Left #3
 329  Common #2
 330  Common #1
 331EOF
 332
 333test_expect_success 'merge-msg tag and branch' '
 334
 335        git config --unset-all merge.log
 336        git config --unset-all merge.summary
 337        git config merge.summary yes &&
 338
 339        git checkout master &&
 340        test_tick &&
 341        git fetch . tag tag-r3 left &&
 342
 343        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 344        test_cmp expected actual
 345'
 346
 347cat >expected <<\EOF
 348Merge branch 'long'
 349
 350* long: (35 commits)
 351EOF
 352
 353test_expect_success 'merge-msg lots of commits' '
 354
 355        git checkout master &&
 356        test_tick &&
 357        git fetch . long &&
 358
 359        i=29 &&
 360        while test $i -gt 9
 361        do
 362                echo "  $i" &&
 363                i=$(($i-1))
 364        done >>expected &&
 365        echo "  ..." >>expected
 366
 367        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 368        test_cmp expected actual
 369'
 370
 371test_done