t / t6006-rev-list-format.shon commit apply: get rid of --index-info in favor of --build-fake-ancestor (7a98869)
   1#!/bin/sh
   2
   3test_description='git rev-list --pretty=format test'
   4
   5. ./test-lib.sh
   6
   7test_tick
   8test_expect_success 'setup' '
   9touch foo && git add foo && git-commit -m "added foo" &&
  10  echo changed >foo && git-commit -a -m "changed foo"
  11'
  12
  13# usage: test_format name format_string <expected_output
  14test_format() {
  15        cat >expect.$1
  16        test_expect_success "format $1" "
  17git rev-list --pretty=format:$2 master >output.$1 &&
  18git diff expect.$1 output.$1
  19"
  20}
  21
  22test_format hash %H%n%h <<'EOF'
  23commit 131a310eb913d107dd3c09a65d1651175898735d
  24131a310eb913d107dd3c09a65d1651175898735d
  25131a310
  26commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
  2786c75cfd708a0e5868dc876ed5b8bb66c80b4873
  2886c75cf
  29EOF
  30
  31test_format tree %T%n%t <<'EOF'
  32commit 131a310eb913d107dd3c09a65d1651175898735d
  33fe722612f26da5064c32ca3843aa154bdb0b08a0
  34fe72261
  35commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
  364d5fcadc293a348e88f777dc0920f11e7d71441c
  374d5fcad
  38EOF
  39
  40test_format parents %P%n%p <<'EOF'
  41commit 131a310eb913d107dd3c09a65d1651175898735d
  4286c75cfd708a0e5868dc876ed5b8bb66c80b4873
  4386c75cf
  44commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
  45
  46
  47EOF
  48
  49# we don't test relative here
  50test_format author %an%n%ae%n%ad%n%aD%n%at <<'EOF'
  51commit 131a310eb913d107dd3c09a65d1651175898735d
  52A U Thor
  53author@example.com
  54Thu Apr 7 15:13:13 2005 -0700
  55Thu, 7 Apr 2005 15:13:13 -0700
  561112911993
  57commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
  58A U Thor
  59author@example.com
  60Thu Apr 7 15:13:13 2005 -0700
  61Thu, 7 Apr 2005 15:13:13 -0700
  621112911993
  63EOF
  64
  65test_format committer %cn%n%ce%n%cd%n%cD%n%ct <<'EOF'
  66commit 131a310eb913d107dd3c09a65d1651175898735d
  67C O Mitter
  68committer@example.com
  69Thu Apr 7 15:13:13 2005 -0700
  70Thu, 7 Apr 2005 15:13:13 -0700
  711112911993
  72commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
  73C O Mitter
  74committer@example.com
  75Thu Apr 7 15:13:13 2005 -0700
  76Thu, 7 Apr 2005 15:13:13 -0700
  771112911993
  78EOF
  79
  80test_format encoding %e <<'EOF'
  81commit 131a310eb913d107dd3c09a65d1651175898735d
  82<unknown>
  83commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
  84<unknown>
  85EOF
  86
  87test_format subject %s <<'EOF'
  88commit 131a310eb913d107dd3c09a65d1651175898735d
  89changed foo
  90commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
  91added foo
  92EOF
  93
  94test_format body %b <<'EOF'
  95commit 131a310eb913d107dd3c09a65d1651175898735d
  96<unknown>
  97commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
  98<unknown>
  99EOF
 100
 101test_format colors %Credfoo%Cgreenbar%Cbluebaz%Cresetxyzzy <<'EOF'
 102commit 131a310eb913d107dd3c09a65d1651175898735d
 103\e[31mfoo\e[32mbar\e[34mbaz\e[mxyzzy
 104commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
 105\e[31mfoo\e[32mbar\e[34mbaz\e[mxyzzy
 106EOF
 107
 108cat >commit-msg <<'EOF'
 109Test printing of complex bodies
 110
 111This commit message is much longer than the others,
 112and it will be encoded in iso8859-1. We should therefore
 113include an iso8859 character: ¡bueno!
 114EOF
 115test_expect_success 'setup complex body' '
 116git config i18n.commitencoding iso8859-1 &&
 117  echo change2 >foo && git-commit -a -F commit-msg
 118'
 119
 120test_format complex-encoding %e <<'EOF'
 121commit f58db70b055c5718631e5c61528b28b12090cdea
 122iso8859-1
 123commit 131a310eb913d107dd3c09a65d1651175898735d
 124<unknown>
 125commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
 126<unknown>
 127EOF
 128
 129test_format complex-subject %s <<'EOF'
 130commit f58db70b055c5718631e5c61528b28b12090cdea
 131Test printing of complex bodies
 132commit 131a310eb913d107dd3c09a65d1651175898735d
 133changed foo
 134commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
 135added foo
 136EOF
 137
 138test_format complex-body %b <<'EOF'
 139commit f58db70b055c5718631e5c61528b28b12090cdea
 140This commit message is much longer than the others,
 141and it will be encoded in iso8859-1. We should therefore
 142include an iso8859 character: ¡bueno!
 143
 144commit 131a310eb913d107dd3c09a65d1651175898735d
 145<unknown>
 146commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
 147<unknown>
 148EOF
 149
 150test_done