{"thread":{"id":"13477","subject":"[PATCH 1/3] rev-parse: add test script for \"--verify\"","startedAt":"2008-05-11T16:27:10Z","lastAt":"2008-05-11T18:35:33Z","messageCount":2,"participants":["Christian Couder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"76630","messageId":"20080511182710.f653991e.chriscool@tuxfamily.org","threadId":"13477","inReplyTo":null,"subject":"[PATCH 1/3] rev-parse: add test script for \"--verify\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-05-11T16:27:10Z","receivedAt":"2008-05-11T16:27:10Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This patch documents the current behavior of \"git rev-parse --verify\".\n\nThis command is tested both with and without the \"--quiet\" and\n\"--default\" options.\n\nThis shows some problems with the current behavior that will be fixed\nin latter patches:\n\n\t- in case of errors, there should be no good rev output on\n\tstdout,\n\t- with \"--default\" one test case is broken\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t1503-rev-parse-verify.sh |  114 +++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 114 insertions(+), 0 deletions(-)\n create mode 100755 t/t1503-rev-parse-verify.sh\n\ndiff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh\nnew file mode 100755\nindex 0000000..a0d14cb\n--- /dev/null\n+++ b/t/t1503-rev-parse-verify.sh\n@@ -0,0 +1,114 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Christian Couder\n+#\n+test_description='test git rev-parse --verify'\n+\n+exec </dev/null\n+\n+. ./test-lib.sh\n+\n+add_line_into_file()\n+{\n+    _line=$1\n+    _file=$2\n+\n+    if [ -f \"$_file\" ]; then\n+        echo \"$_line\" >> $_file || return $?\n+        MSG=\"Add <$_line> into <$_file>.\"\n+    else\n+        echo \"$_line\" > $_file || return $?\n+        git add $_file || return $?\n+        MSG=\"Create file <$_file> with <$_line> inside.\"\n+    fi\n+\n+    test_tick\n+    git-commit --quiet -m \"$MSG\" $_file\n+}\n+\n+HASH1=\n+HASH2=\n+HASH3=\n+HASH4=\n+\n+test_expect_success 'set up basic repo with 1 file (hello) and 4 commits' '\n+\tadd_line_into_file \"1: Hello World\" hello &&\n+\tHASH1=$(git rev-parse --verify HEAD) &&\n+\tadd_line_into_file \"2: A new day for git\" hello &&\n+\tHASH2=$(git rev-parse --verify HEAD) &&\n+\tadd_line_into_file \"3: Another new day for git\" hello &&\n+\tHASH3=$(git rev-parse --verify HEAD) &&\n+\tadd_line_into_file \"4: Ciao for now\" hello &&\n+\tHASH4=$(git rev-parse --verify HEAD)\n+'\n+\n+test_expect_success 'works with one good rev' '\n+\trev_hash1=$(git rev-parse --verify $HASH1) &&\n+\ttest \"$rev_hash1\" = \"$HASH1\" &&\n+\trev_hash2=$(git rev-parse --verify $HASH2) &&\n+\ttest \"$rev_hash2\" = \"$HASH2\" &&\n+\trev_hash3=$(git rev-parse --verify $HASH3) &&\n+\ttest \"$rev_hash3\" = \"$HASH3\" &&\n+\trev_hash4=$(git rev-parse --verify $HASH4) &&\n+\ttest \"$rev_hash4\" = \"$HASH4\" &&\n+\trev_master=$(git rev-parse --verify master) &&\n+\ttest \"$rev_master\" = \"$HASH4\" &&\n+\trev_head=$(git rev-parse --verify HEAD) &&\n+\ttest \"$rev_head\" = \"$HASH4\"\n+'\n+\n+test_expect_success 'fails with any bad rev or many good revs' '\n+\ttest_must_fail git rev-parse --verify 2>error &&\n+\tgrep \"single revision\" error &&\n+\ttest_must_fail git rev-parse --verify foo 2>error &&\n+\tgrep \"single revision\" error &&\n+\ttest_must_fail git rev-parse --verify HEAD bar 2>error &&\n+\tgrep \"single revision\" error &&\n+\ttest_must_fail git rev-parse --verify baz HEAD 2>error &&\n+\tgrep \"single revision\" error &&\n+\ttest_must_fail git rev-parse --verify $HASH2 HEAD 2>error &&\n+\tgrep \"single revision\" error\n+'\n+\n+test_expect_success 'fails silently when using -q' '\n+\ttest_must_fail git rev-parse --verify --quiet 2>error &&\n+\ttest -z \"$(cat error)\" &&\n+\ttest_must_fail git rev-parse -q --verify foo 2>error &&\n+\ttest -z \"$(cat error)\" &&\n+\ttest_must_fail git rev-parse --verify -q HEAD bar 2>error &&\n+\ttest -z \"$(cat error)\" &&\n+\ttest_must_fail git rev-parse --quiet --verify baz HEAD 2>error &&\n+\ttest -z \"$(cat error)\" &&\n+\ttest_must_fail git rev-parse -q --verify $HASH2 HEAD 2>error &&\n+\ttest -z \"$(cat error)\"\n+'\n+\n+test_expect_success '1 no stdout output on error' '\n+\ttest -z \"$(git rev-parse --verify)\" &&\n+\ttest -z \"$(git rev-parse --verify foo)\" &&\n+\ttest -z \"$(git rev-parse --verify baz HEAD)\"\n+'\n+\n+test_expect_failure '2 no stdout output on error' '\n+\ttest -z \"$(git rev-parse --verify HEAD bar)\"\n+'\n+\n+test_expect_failure '3 no stdout output on error' '\n+\ttest -z \"$(git rev-parse --verify $HASH2 HEAD)\"\n+'\n+\n+test_expect_success '1 with --default' '\n+\tgit rev-parse --verify --default master &&\n+\tgit rev-parse --verify --default master HEAD &&\n+\tgit rev-parse --default master --verify &&\n+\tgit rev-parse --default master --verify HEAD &&\n+\ttest_must_fail git rev-parse --verify foo --default master &&\n+\ttest_must_fail git rev-parse --default HEAD --verify bar &&\n+\ttest_must_fail git rev-parse --verify --default HEAD baz\n+'\n+\n+test_expect_failure '2 with --default' '\n+\tgit rev-parse --verify HEAD --default master\n+'\n+\n+test_done\n-- \n1.5.5.1.347.g86562\n"},{"id":"76650","messageId":"7v4p944rka.fsf@gitster.siamese.dyndns.org","threadId":"13477","inReplyTo":"20080511182710.f653991e.chriscool@tuxfamily.org","subject":"Re: [PATCH 1/3] rev-parse: add test script for \"--verify\"","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2008-05-11T18:35:33Z","receivedAt":"2008-05-11T18:35:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh\n> new file mode 100755\n> index 0000000..a0d14cb\n> --- /dev/null\n> +++ b/t/t1503-rev-parse-verify.sh\n> @@ -0,0 +1,114 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2008 Christian Couder\n> +#\n> +test_description='test git rev-parse --verify'\n> +\n> +exec </dev/null\n> +. ./test-lib.sh\n\nWho gets stuck by attempting to read from the stdin?  I am wondering if\nthat belongs to \"test-lib.sh\"...\n"}]}