t / t4021-format-patch-numbered.shon commit tests: document cherry-pick behavior in face of conflicts (6a84334)
   1#!/bin/sh
   2#
   3# Copyright (c) 2006 Brian C Gernhardt
   4#
   5
   6test_description='Format-patch numbering options'
   7
   8. ./test-lib.sh
   9
  10test_expect_success setup '
  11
  12        echo A > file &&
  13        git add file &&
  14        git commit -m First &&
  15
  16        echo B >> file &&
  17        git commit -a -m Second &&
  18
  19        echo C >> file &&
  20        git commit -a -m Third
  21
  22'
  23
  24# Each of these gets used multiple times.
  25
  26test_num_no_numbered() {
  27        cnt=$(grep "^Subject: \[PATCH\]" $1 | wc -l) &&
  28        test $cnt = $2
  29}
  30
  31test_single_no_numbered() {
  32        test_num_no_numbered $1 1
  33}
  34
  35test_no_numbered() {
  36        test_num_no_numbered $1 2
  37}
  38
  39test_single_numbered() {
  40        grep "^Subject: \[PATCH 1/1\]" $1
  41}
  42
  43test_numbered() {
  44        grep "^Subject: \[PATCH 1/2\]" $1 &&
  45        grep "^Subject: \[PATCH 2/2\]" $1
  46}
  47
  48test_expect_success 'single patch defaults to no numbers' '
  49        git format-patch --stdout HEAD~1 >patch0.single &&
  50        test_single_no_numbered patch0.single
  51'
  52
  53test_expect_success 'multiple patch defaults to numbered' '
  54
  55        git format-patch --stdout HEAD~2 >patch0.multiple &&
  56        test_numbered patch0.multiple
  57
  58'
  59
  60test_expect_success 'Use --numbered' '
  61
  62        git format-patch --numbered --stdout HEAD~1 >patch1 &&
  63        test_single_numbered patch1
  64
  65'
  66
  67test_expect_success 'format.numbered = true' '
  68
  69        git config format.numbered true &&
  70        git format-patch --stdout HEAD~2 >patch2 &&
  71        test_numbered patch2
  72
  73'
  74
  75test_expect_success 'format.numbered && single patch' '
  76
  77        git format-patch --stdout HEAD^ > patch3 &&
  78        test_single_numbered patch3
  79
  80'
  81
  82test_expect_success 'format.numbered && --no-numbered' '
  83
  84        git format-patch --no-numbered --stdout HEAD~2 >patch4 &&
  85        test_no_numbered patch4
  86
  87'
  88
  89test_expect_success 'format.numbered && --keep-subject' '
  90
  91        git format-patch --keep-subject --stdout HEAD^ >patch4a &&
  92        grep "^Subject: Third" patch4a
  93
  94'
  95
  96test_expect_success 'format.numbered = auto' '
  97
  98        git config format.numbered auto
  99        git format-patch --stdout HEAD~2 > patch5 &&
 100        test_numbered patch5
 101
 102'
 103
 104test_expect_success 'format.numbered = auto && single patch' '
 105
 106        git format-patch --stdout HEAD^ > patch6 &&
 107        test_single_no_numbered patch6
 108
 109'
 110
 111test_expect_success 'format.numbered = auto && --no-numbered' '
 112
 113        git format-patch --no-numbered --stdout HEAD~2 > patch7 &&
 114        test_no_numbered patch7
 115
 116'
 117
 118test_expect_success '--start-number && --numbered' '
 119
 120        git format-patch --start-number 3 --numbered --stdout HEAD~1 > patch8 &&
 121        grep "^Subject: \[PATCH 3/3\]" patch8
 122'
 123
 124test_done