t / t8008-blame-formats.shon commit Merge branch 'ma/bisect-leakfix' (f116163)
   1#!/bin/sh
   2
   3test_description='blame output in various formats on a simple case'
   4. ./test-lib.sh
   5
   6test_expect_success 'setup' '
   7        echo a >file &&
   8        git add file &&
   9        test_tick &&
  10        git commit -m one &&
  11        echo b >>file &&
  12        echo c >>file &&
  13        echo d >>file &&
  14        test_tick &&
  15        git commit -a -m two &&
  16        ID1=$(git rev-parse HEAD^) &&
  17        shortID1="^$(git rev-parse HEAD^ |cut -c 1-17)" &&
  18        ID2=$(git rev-parse HEAD) &&
  19        shortID2="$(git rev-parse HEAD |cut -c 1-18)"
  20'
  21
  22cat >expect <<EOF
  23$shortID1 (A U Thor 2005-04-07 15:13:13 -0700 1) a
  24$shortID2 (A U Thor 2005-04-07 15:14:13 -0700 2) b
  25$shortID2 (A U Thor 2005-04-07 15:14:13 -0700 3) c
  26$shortID2 (A U Thor 2005-04-07 15:14:13 -0700 4) d
  27EOF
  28test_expect_success 'normal blame output' '
  29        git blame --abbrev=17 file >actual &&
  30        test_cmp expect actual
  31'
  32
  33COMMIT1="author A U Thor
  34author-mail <author@example.com>
  35author-time 1112911993
  36author-tz -0700
  37committer C O Mitter
  38committer-mail <committer@example.com>
  39committer-time 1112911993
  40committer-tz -0700
  41summary one
  42boundary
  43filename file"
  44COMMIT2="author A U Thor
  45author-mail <author@example.com>
  46author-time 1112912053
  47author-tz -0700
  48committer C O Mitter
  49committer-mail <committer@example.com>
  50committer-time 1112912053
  51committer-tz -0700
  52summary two
  53previous $ID1 file
  54filename file"
  55
  56cat >expect <<EOF
  57$ID1 1 1 1
  58$COMMIT1
  59        a
  60$ID2 2 2 3
  61$COMMIT2
  62        b
  63$ID2 3 3
  64        c
  65$ID2 4 4
  66        d
  67EOF
  68test_expect_success 'blame --porcelain output' '
  69        git blame --porcelain file >actual &&
  70        test_cmp expect actual
  71'
  72
  73cat >expect <<EOF
  74$ID1 1 1 1
  75$COMMIT1
  76        a
  77$ID2 2 2 3
  78$COMMIT2
  79        b
  80$ID2 3 3
  81$COMMIT2
  82        c
  83$ID2 4 4
  84$COMMIT2
  85        d
  86EOF
  87test_expect_success 'blame --line-porcelain output' '
  88        git blame --line-porcelain file >actual &&
  89        test_cmp expect actual
  90'
  91
  92test_expect_success '--porcelain detects first non-blank line as subject' '
  93        (
  94                GIT_INDEX_FILE=.git/tmp-index &&
  95                export GIT_INDEX_FILE &&
  96                echo "This is it" >single-file &&
  97                git add single-file &&
  98                tree=$(git write-tree) &&
  99                commit=$(printf "%s\n%s\n%s\n\n\n  \noneline\n\nbody\n" \
 100                        "tree $tree" \
 101                        "author A <a@b.c> 123456789 +0000" \
 102                        "committer C <c@d.e> 123456789 +0000" |
 103                git hash-object -w -t commit --stdin) &&
 104                git blame --porcelain $commit -- single-file >output &&
 105                grep "^summary oneline$" output
 106        )
 107'
 108
 109test_done