t / t4021-format-patch-numbered.shon commit builtin-clone: fix initial checkout (a73bc12)
   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 'Default: no numbered' '
  49
  50        git format-patch --stdout HEAD~2 >patch0 &&
  51        test_no_numbered patch0
  52
  53'
  54
  55test_expect_success 'Use --numbered' '
  56
  57        git format-patch --numbered --stdout HEAD~2 >patch1 &&
  58        test_numbered patch1
  59
  60'
  61
  62test_expect_success 'format.numbered = true' '
  63
  64        git config format.numbered true &&
  65        git format-patch --stdout HEAD~2 >patch2 &&
  66        test_numbered patch2
  67
  68'
  69
  70test_expect_success 'format.numbered && single patch' '
  71
  72        git format-patch --stdout HEAD^ > patch3 &&
  73        test_single_numbered patch3
  74
  75'
  76
  77test_expect_success 'format.numbered && --no-numbered' '
  78
  79        git format-patch --no-numbered --stdout HEAD~2 >patch4 &&
  80        test_no_numbered patch4
  81
  82'
  83
  84test_expect_success 'format.numbered = auto' '
  85
  86        git config format.numbered auto
  87        git format-patch --stdout HEAD~2 > patch5 &&
  88        test_numbered patch5
  89
  90'
  91
  92test_expect_success 'format.numbered = auto && single patch' '
  93
  94        git format-patch --stdout HEAD^ > patch6 &&
  95        test_single_no_numbered patch6
  96
  97'
  98
  99test_expect_success 'format.numbered = auto && --no-numbered' '
 100
 101        git format-patch --no-numbered --stdout HEAD~2 > patch7 &&
 102        test_no_numbered patch7
 103
 104'
 105
 106test_done