{"thread":{"id":"13485","subject":"[PATCH 1/3 v2] rev-parse: add test script for \"--verify\"","startedAt":"2008-05-12T03:41:42Z","lastAt":"2008-05-12T05:34:13Z","messageCount":2,"participants":["Christian Couder"],"isPatch":true,"patchVersion":2,"patchTotal":3},"messages":[{"id":"76672","messageId":"20080512054142.5e524e6f.chriscool@tuxfamily.org","threadId":"13485","inReplyTo":null,"subject":"[PATCH 1/3 v2] rev-parse: add test script for \"--verify\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-05-12T03:41:42Z","receivedAt":"2008-05-12T03:41:42Z","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\nThe setup code in this patch comes from \"t6030-bisect-porcelain.sh\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t1503-rev-parse-verify.sh |  112 +++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 112 insertions(+), 0 deletions(-)\n create mode 100755 t/t1503-rev-parse-verify.sh\n\n\tJunio wrote:\n\t> > +exec </dev/null\n\t> > +. ./test-lib.sh\n\t>\n\t> Who gets stuck by attempting to read from the stdin?  I am wondering if\n\t> that belongs to \"test-lib.sh\"...\n\n\tI copy pasted the setup code from \"t6030-bisect-porcelain.sh\" and that's\n\twhere \"exec </dev/null\" comes from.\n\n\tI removed it in this new version and added a line to the commit message.\n\n\tThanks.\n\ndiff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh\nnew file mode 100755\nindex 0000000..90f0801\n--- /dev/null\n+++ b/t/t1503-rev-parse-verify.sh\n@@ -0,0 +1,112 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Christian Couder\n+#\n+test_description='test git rev-parse --verify'\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.345.g69ef\n"},{"id":"76675","messageId":"200805120734.13353.chriscool@tuxfamily.org","threadId":"13485","inReplyTo":"20080512054142.5e524e6f.chriscool@tuxfamily.org","subject":"Re: [PATCH 1/3 v2] rev-parse: add test script for \"--verify\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-05-12T05:34:13Z","receivedAt":"2008-05-12T05:34:13Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le lundi 12 mai 2008, Christian Couder a écrit :\n>\n> \tJunio wrote:\n> \t> > +exec </dev/null\n> \t> > +. ./test-lib.sh\n> \t>\n> \t> Who gets stuck by attempting to read from the stdin?  I am wondering\n> \t> if that belongs to \"test-lib.sh\"...\n>\n> \tI copy pasted the setup code from \"t6030-bisect-porcelain.sh\" and that's\n> \twhere \"exec </dev/null\" comes from.\n>\n> \tI removed it in this new version and added a line to the commit message.\n\nOoops, I just saw that you already commited the first version.\n\nThanks again,\nChristian.\n"}]}