Fourth batch
[gitweb.git] / t / t6300-for-each-ref.sh
index e0496da812f34df16ef7c3417788f9096ddc1e0f..9c910ce746733cabaafd34adceeb59cf53dca1f7 100755 (executable)
@@ -83,6 +83,8 @@ test_atom head push:strip=1 remotes/myfork/master
 test_atom head push:strip=-1 master
 test_atom head objecttype commit
 test_atom head objectsize 171
+test_atom head objectsize:disk 138
+test_atom head deltabase 0000000000000000000000000000000000000000
 test_atom head objectname $(git rev-parse refs/heads/master)
 test_atom head objectname:short $(git rev-parse --short refs/heads/master)
 test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
@@ -124,6 +126,10 @@ test_atom tag upstream ''
 test_atom tag push ''
 test_atom tag objecttype tag
 test_atom tag objectsize 154
+test_atom tag objectsize:disk 138
+test_atom tag '*objectsize:disk' 138
+test_atom tag deltabase 0000000000000000000000000000000000000000
+test_atom tag '*deltabase' 0000000000000000000000000000000000000000
 test_atom tag objectname $(git rev-parse refs/tags/testtag)
 test_atom tag objectname:short $(git rev-parse --short refs/tags/testtag)
 test_atom head objectname:short=1 $(git rev-parse --short=1 refs/heads/master)
@@ -339,6 +345,32 @@ test_expect_success 'Verify descending sort' '
        test_cmp expected actual
 '
 
+cat >expected <<\EOF
+refs/tags/testtag
+refs/tags/testtag-2
+EOF
+
+test_expect_success 'exercise patterns with prefixes' '
+       git tag testtag-2 &&
+       test_when_finished "git tag -d testtag-2" &&
+       git for-each-ref --format="%(refname)" \
+               refs/tags/testtag refs/tags/testtag-2 >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+refs/tags/testtag
+refs/tags/testtag-2
+EOF
+
+test_expect_success 'exercise glob patterns with prefixes' '
+       git tag testtag-2 &&
+       test_when_finished "git tag -d testtag-2" &&
+       git for-each-ref --format="%(refname)" \
+               refs/tags/testtag "refs/tags/testtag-*" >actual &&
+       test_cmp expected actual
+'
+
 cat >expected <<\EOF
 'refs/heads/master'
 'refs/remotes/origin/master'
@@ -386,8 +418,15 @@ test_atom head upstream:track '[ahead 1]'
 test_atom head upstream:trackshort '>'
 test_atom head upstream:track,nobracket 'ahead 1'
 test_atom head upstream:nobracket,track 'ahead 1'
-test_atom head push:track '[ahead 1]'
-test_atom head push:trackshort '>'
+
+test_expect_success 'setup for push:track[short]' '
+       test_commit third &&
+       git update-ref refs/remotes/myfork/master master &&
+       git reset master~1
+'
+
+test_atom head push:track '[behind 1]'
+test_atom head push:trackshort '<'
 
 test_expect_success 'Check that :track[short] cannot be used with other atoms' '
        test_must_fail git for-each-ref --format="%(refname:track)" 2>/dev/null &&
@@ -414,8 +453,10 @@ test_expect_success 'Check for invalid refname format' '
 test_expect_success 'set up color tests' '
        cat >expected.color <<-EOF &&
        $(git rev-parse --short refs/heads/master) <GREEN>master<RESET>
+       $(git rev-parse --short refs/remotes/myfork/master) <GREEN>myfork/master<RESET>
        $(git rev-parse --short refs/remotes/origin/master) <GREEN>origin/master<RESET>
        $(git rev-parse --short refs/tags/testtag) <GREEN>testtag<RESET>
+       $(git rev-parse --short refs/tags/third) <GREEN>third<RESET>
        $(git rev-parse --short refs/tags/two) <GREEN>two<RESET>
        EOF
        sed "s/<[^>]*>//g" <expected.color >expected.bare &&
@@ -485,6 +526,25 @@ test_expect_success 'Check ambiguous head and tag refs II (loose)' '
        test_cmp expected actual
 '
 
+test_expect_success 'create tag without tagger' '
+       git tag -a -m "Broken tag" taggerless &&
+       git tag -f taggerless $(git cat-file tag taggerless |
+               sed -e "/^tagger /d" |
+               git hash-object --stdin -w -t tag)
+'
+
+test_atom refs/tags/taggerless type 'commit'
+test_atom refs/tags/taggerless tag 'taggerless'
+test_atom refs/tags/taggerless tagger ''
+test_atom refs/tags/taggerless taggername ''
+test_atom refs/tags/taggerless taggeremail ''
+test_atom refs/tags/taggerless taggerdate ''
+test_atom refs/tags/taggerless committer ''
+test_atom refs/tags/taggerless committername ''
+test_atom refs/tags/taggerless committeremail ''
+test_atom refs/tags/taggerless committerdate ''
+test_atom refs/tags/taggerless subject 'Broken tag'
+
 test_expect_success 'an unusual tag with an incomplete line' '
 
        git tag -m "bogo" bogo &&
@@ -715,6 +775,29 @@ test_expect_success 'basic atom: head contents:trailers' '
        test_cmp expect actual.clean
 '
 
+test_expect_success 'trailer parsing not fooled by --- line' '
+       git commit --allow-empty -F - <<-\EOF &&
+       this is the subject
+
+       This is the body. The message has a "---" line which would confuse a
+       message+patch parser. But here we know we have only a commit message,
+       so we get it right.
+
+       trailer: wrong
+       ---
+       This is more body.
+
+       trailer: right
+       EOF
+
+       {
+               echo "trailer: right" &&
+               echo
+       } >expect &&
+       git for-each-ref --format="%(trailers)" refs/heads/master >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'Add symbolic ref for the following tests' '
        git symbolic-ref refs/heads/sym refs/heads/master
 '
@@ -796,9 +879,8 @@ test_expect_success ':remotename and :remoteref' '
 '
 
 test_expect_success 'for-each-ref --ignore-case ignores case' '
-       >expect &&
        git for-each-ref --format="%(refname)" refs/heads/MASTER >actual &&
-       test_cmp expect actual &&
+       test_must_be_empty actual &&
 
        echo refs/heads/master >expect &&
        git for-each-ref --format="%(refname)" --ignore-case \