Merge branch 'wc/diff'
[gitweb.git] / t / t7004-tag.sh
index c4fa4461f764dd936f231dae3905605b0ed0c28a..09d56e0839f042a74bee5c13ab251f19fcc2c76e 100755 (executable)
@@ -185,18 +185,17 @@ cba
 EOF
 test_expect_success \
        'listing tags with substring as pattern must print those matching' '
-       git-tag -l a > actual &&
+       git-tag -l "*a*" > actual &&
        git diff expect actual
 '
 
 cat >expect <<EOF
 v0.2.1
 v1.0.1
-v1.1.3
 EOF
 test_expect_success \
-       'listing tags with substring as pattern must print those matching' '
-       git-tag -l .1 > actual &&
+       'listing tags with a suffix as pattern must print those matching' '
+       git-tag -l "*.1" > actual &&
        git diff expect actual
 '
 
@@ -205,37 +204,36 @@ t210
 t211
 EOF
 test_expect_success \
-       'listing tags with substring as pattern must print those matching' '
-       git-tag -l t21 > actual &&
+       'listing tags with a prefix as pattern must print those matching' '
+       git-tag -l "t21*" > actual &&
        git diff expect actual
 '
 
 cat >expect <<EOF
 a1
-aa1
 EOF
 test_expect_success \
-       'listing tags using a name as pattern must print those matching' '
+       'listing tags using a name as pattern must print that one matching' '
        git-tag -l a1 > actual &&
        git diff expect actual
 '
 
 cat >expect <<EOF
 v1.0
-v1.0.1
 EOF
 test_expect_success \
-       'listing tags using a name as pattern must print those matching' '
+       'listing tags using a name as pattern must print that one matching' '
        git-tag -l v1.0 > actual &&
        git diff expect actual
 '
 
 cat >expect <<EOF
+v1.0.1
 v1.1.3
 EOF
 test_expect_success \
        'listing tags with ? in the pattern should print those matching' '
-       git-tag -l "1.1?" > actual &&
+       git-tag -l "v1.?.?" > actual &&
        git diff expect actual
 '
 
@@ -341,20 +339,14 @@ test_expect_success \
 '
 
 test_expect_success \
-       'trying to create tags giving many -m or -F options should fail' '
+       'trying to create tags giving both -m or -F options should fail' '
        echo "message file 1" >msgfile1 &&
        echo "message file 2" >msgfile2 &&
        ! tag_exists msgtag &&
-       ! git-tag -m "message 1" -m "message 2" msgtag &&
-       ! tag_exists msgtag &&
-       ! git-tag -F msgfile1 -F msgfile2 msgtag &&
-       ! tag_exists msgtag &&
        ! git-tag -m "message 1" -F msgfile1 msgtag &&
        ! tag_exists msgtag &&
        ! git-tag -F msgfile1 -m "message 1" msgtag &&
        ! tag_exists msgtag &&
-       ! git-tag -F msgfile1 -m "message 1" -F msgfile2 msgtag &&
-       ! tag_exists msgtag &&
        ! git-tag -m "message 1" -F msgfile1 -m "message 2" msgtag &&
        ! tag_exists msgtag
 '
@@ -648,6 +640,46 @@ test_expect_success 'creating a signed tag with -m message should succeed' '
        git diff expect actual
 '
 
+get_tag_header u-signed-tag $commit commit $time >expect
+echo 'Another message' >>expect
+echo '-----BEGIN PGP SIGNATURE-----' >>expect
+test_expect_success 'sign with a given key id' '
+
+       git tag -u committer@example.com -m "Another message" u-signed-tag &&
+       get_tag_msg u-signed-tag >actual &&
+       git diff expect actual
+
+'
+
+test_expect_success 'sign with an unknown id (1)' '
+
+       ! git tag -u author@example.com -m "Another message" o-signed-tag
+
+'
+
+test_expect_success 'sign with an unknown id (2)' '
+
+       ! git tag -u DEADBEEF -m "Another message" o-signed-tag
+
+'
+
+cat >fakeeditor <<'EOF'
+#!/bin/sh
+test -n "$1" && exec >"$1"
+echo A signed tag message
+echo from a fake editor.
+EOF
+chmod +x fakeeditor
+
+get_tag_header implied-sign $commit commit $time >expect
+./fakeeditor >>expect
+echo '-----BEGIN PGP SIGNATURE-----' >>expect
+test_expect_success '-u implies signed tag' '
+       GIT_EDITOR=./fakeeditor git-tag -u CDDE430D implied-sign &&
+       get_tag_msg implied-sign >actual &&
+       git diff expect actual
+'
+
 cat >sigmsgfile <<EOF
 Another signed tag
 message in a file.
@@ -675,6 +707,15 @@ test_expect_success 'creating a signed tag with -F - should succeed' '
        git diff expect actual
 '
 
+get_tag_header implied-annotate $commit commit $time >expect
+./fakeeditor >>expect
+echo '-----BEGIN PGP SIGNATURE-----' >>expect
+test_expect_success '-s implies annotated tag' '
+       GIT_EDITOR=./fakeeditor git-tag -s implied-annotate &&
+       get_tag_msg implied-annotate >actual &&
+       git diff expect actual
+'
+
 test_expect_success \
        'trying to create a signed tag with non-existing -F file should fail' '
        ! test -f nonexistingfile &&
@@ -992,6 +1033,13 @@ test_expect_success \
        git diff expect actual
 '
 
+# try to sign with bad user.signingkey
+git config user.signingkey BobTheMouse
+test_expect_failure \
+       'git-tag -s fails if gpg is misconfigured' \
+       'git tag -s -m tail tag-gpg-failure'
+git config --unset user.signingkey
+
 # try to verify without gpg:
 
 rm -rf gpghome
@@ -999,4 +1047,30 @@ test_expect_failure \
        'verify signed tag fails when public key is not present' \
        'git-tag -v signed-tag'
 
+test_expect_failure \
+       'git-tag -a fails if tag annotation is empty' '
+       GIT_EDITOR=cat git tag -a initial-comment
+'
+
+test_expect_success \
+       'message in editor has initial comment' '
+       GIT_EDITOR=cat git tag -a initial-comment > actual
+       # check the first line --- should be empty
+       first=$(sed -e 1q <actual) &&
+       test -z "$first" &&
+       # remove commented lines from the remainder -- should be empty
+       rest=$(sed -e 1d -e '/^#/d' <actual) &&
+       test -z "$rest"
+'
+
+get_tag_header reuse $commit commit $time >expect
+echo "An annotation to be reused" >> expect
+test_expect_success \
+       'overwriting an annoted tag should use its previous body' '
+       git tag -a -m "An annotation to be reused" reuse &&
+       GIT_EDITOR=true git tag -f -a reuse &&
+       get_tag_msg reuse >actual &&
+       git diff expect actual
+'
+
 test_done