2011-05-09 17:33:30 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='blame output in various formats on a simple case'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
echo a >file &&
|
2015-03-20 13:07:15 +03:00
|
|
|
git add file &&
|
2011-05-09 17:33:30 +04:00
|
|
|
test_tick &&
|
|
|
|
git commit -m one &&
|
|
|
|
echo b >>file &&
|
|
|
|
echo c >>file &&
|
|
|
|
echo d >>file &&
|
|
|
|
test_tick &&
|
2017-07-26 22:06:31 +03:00
|
|
|
git commit -a -m two &&
|
|
|
|
ID1=$(git rev-parse HEAD^) &&
|
|
|
|
shortID1="^$(git rev-parse HEAD^ |cut -c 1-17)" &&
|
|
|
|
ID2=$(git rev-parse HEAD) &&
|
|
|
|
shortID2="$(git rev-parse HEAD |cut -c 1-18)"
|
2011-05-09 17:33:30 +04:00
|
|
|
'
|
|
|
|
|
2017-07-26 22:06:31 +03:00
|
|
|
cat >expect <<EOF
|
|
|
|
$shortID1 (A U Thor 2005-04-07 15:13:13 -0700 1) a
|
|
|
|
$shortID2 (A U Thor 2005-04-07 15:14:13 -0700 2) b
|
|
|
|
$shortID2 (A U Thor 2005-04-07 15:14:13 -0700 3) c
|
|
|
|
$shortID2 (A U Thor 2005-04-07 15:14:13 -0700 4) d
|
2011-05-09 17:33:30 +04:00
|
|
|
EOF
|
|
|
|
test_expect_success 'normal blame output' '
|
2017-07-26 22:06:31 +03:00
|
|
|
git blame --abbrev=17 file >actual &&
|
2011-05-09 17:33:30 +04:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2017-07-26 22:06:31 +03:00
|
|
|
COMMIT1="author A U Thor
|
2011-05-09 17:33:30 +04:00
|
|
|
author-mail <author@example.com>
|
|
|
|
author-time 1112911993
|
|
|
|
author-tz -0700
|
|
|
|
committer C O Mitter
|
|
|
|
committer-mail <committer@example.com>
|
|
|
|
committer-time 1112911993
|
|
|
|
committer-tz -0700
|
|
|
|
summary one
|
|
|
|
boundary
|
2017-07-26 22:06:31 +03:00
|
|
|
filename file"
|
|
|
|
COMMIT2="author A U Thor
|
2011-05-09 17:33:30 +04:00
|
|
|
author-mail <author@example.com>
|
|
|
|
author-time 1112912053
|
|
|
|
author-tz -0700
|
|
|
|
committer C O Mitter
|
|
|
|
committer-mail <committer@example.com>
|
|
|
|
committer-time 1112912053
|
|
|
|
committer-tz -0700
|
|
|
|
summary two
|
2017-07-26 22:06:31 +03:00
|
|
|
previous $ID1 file
|
|
|
|
filename file"
|
2011-05-09 17:33:30 +04:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
$ID1 1 1 1
|
|
|
|
$COMMIT1
|
|
|
|
a
|
|
|
|
$ID2 2 2 3
|
|
|
|
$COMMIT2
|
|
|
|
b
|
|
|
|
$ID2 3 3
|
|
|
|
c
|
|
|
|
$ID2 4 4
|
|
|
|
d
|
|
|
|
EOF
|
|
|
|
test_expect_success 'blame --porcelain output' '
|
|
|
|
git blame --porcelain file >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-05-09 17:34:42 +04:00
|
|
|
cat >expect <<EOF
|
|
|
|
$ID1 1 1 1
|
|
|
|
$COMMIT1
|
|
|
|
a
|
|
|
|
$ID2 2 2 3
|
|
|
|
$COMMIT2
|
|
|
|
b
|
|
|
|
$ID2 3 3
|
|
|
|
$COMMIT2
|
|
|
|
c
|
|
|
|
$ID2 4 4
|
|
|
|
$COMMIT2
|
|
|
|
d
|
|
|
|
EOF
|
|
|
|
test_expect_success 'blame --line-porcelain output' '
|
|
|
|
git blame --line-porcelain file >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2016-06-22 23:20:20 +03:00
|
|
|
test_expect_success '--porcelain detects first non-blank line as subject' '
|
|
|
|
(
|
|
|
|
GIT_INDEX_FILE=.git/tmp-index &&
|
|
|
|
export GIT_INDEX_FILE &&
|
|
|
|
echo "This is it" >single-file &&
|
|
|
|
git add single-file &&
|
|
|
|
tree=$(git write-tree) &&
|
|
|
|
commit=$(printf "%s\n%s\n%s\n\n\n \noneline\n\nbody\n" \
|
|
|
|
"tree $tree" \
|
|
|
|
"author A <a@b.c> 123456789 +0000" \
|
|
|
|
"committer C <c@d.e> 123456789 +0000" |
|
|
|
|
git hash-object -w -t commit --stdin) &&
|
|
|
|
git blame --porcelain $commit -- single-file >output &&
|
|
|
|
grep "^summary oneline$" output
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2011-05-09 17:33:30 +04:00
|
|
|
test_done
|