{"thread":{"id":"48552","subject":"[PATCH v2] t: make many tests depend less on the refs being files","startedAt":"2018-05-23T05:25:30Z","lastAt":"2018-05-25T11:22:09Z","messageCount":7,"participants":["Christian Couder","Junio C Hamano","Michael Haggerty","Jeff King"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"348352","messageId":"20180523052517.4443-1-chriscool@tuxfamily.org","threadId":"48552","inReplyTo":null,"subject":"[PATCH v2] t: make many tests depend less on the refs being files","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2018-05-23T05:25:17Z","receivedAt":"2018-05-23T05:25:30Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"From: David Turner <dturner@twopensource.com>\n\nMany tests are very focused on the file system representation of the\nloose and packed refs code. As there are plans to implement other\nref storage systems, let's migrate these tests to a form that test\nthe intent of the refs storage system instead of it internals.\n\nThis will make clear to readers that these tests do not depend on\nwhich ref backend is used.\n\nThe internals of the loose refs backend are still tested in\nt1400-update-ref.sh, whereas the tests changed in this patch focus\non testing other aspects.\n\nThis patch just takes care of many low hanging fruits. It does not\ntry to completely solves the issue.\n\nHelped-by: Stefan Beller <sbeller@google.com>\nHelped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: David Turner <dturner@twopensource.com>\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/lib-t6000.sh                   |  6 +++---\n t/t1401-symbolic-ref.sh          |  2 +-\n t/t3200-branch.sh                | 18 +++++++++---------\n t/t3903-stash.sh                 |  2 +-\n t/t5500-fetch-pack.sh            | 10 +++++-----\n t/t5510-fetch.sh                 |  6 +++---\n t/t6010-merge-base.sh            |  2 +-\n t/t7201-co.sh                    |  2 +-\n t/t9104-git-svn-follow-parent.sh |  3 ++-\n 9 files changed, 26 insertions(+), 25 deletions(-)\n\ndiff --git a/t/lib-t6000.sh b/t/lib-t6000.sh\nindex 3f2d873fec..b0ed4767e3 100644\n--- a/t/lib-t6000.sh\n+++ b/t/lib-t6000.sh\n@@ -4,11 +4,11 @@ mkdir -p .git/refs/tags\n \n >sed.script\n \n-# Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags\n+# Answer the sha1 has associated with the tag. The tag must exist under refs/tags\n tag () {\n \t_tag=$1\n-\ttest -f \".git/refs/tags/$_tag\" || error \"tag: \\\"$_tag\\\" does not exist\"\n-\tcat \".git/refs/tags/$_tag\"\n+\tgit rev-parse --verify \"refs/tags/$_tag\" ||\n+\terror \"tag: \\\"$_tag\\\" does not exist\"\n }\n \n # Generate a commit using the text specified to make it unique and the tree\ndiff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh\nindex 9e782a8122..a4ebb0b65f 100755\n--- a/t/t1401-symbolic-ref.sh\n+++ b/t/t1401-symbolic-ref.sh\n@@ -65,7 +65,7 @@ reset_to_sane\n test_expect_success 'symbolic-ref fails to delete real ref' '\n \techo \"fatal: Cannot delete refs/heads/foo, not a symbolic ref\" >expect &&\n \ttest_must_fail git symbolic-ref -d refs/heads/foo >actual 2>&1 &&\n-\ttest_path_is_file .git/refs/heads/foo &&\n+\tgit rev-parse --verify refs/heads/foo &&\n \ttest_cmp expect actual\n '\n reset_to_sane\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex c0ef946811..222dc2c377 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -234,34 +234,34 @@ test_expect_success 'git branch -M master2 master2 should work when master is ch\n \n test_expect_success 'git branch -v -d t should work' '\n \tgit branch t &&\n-\ttest_path_is_file .git/refs/heads/t &&\n+\tgit rev-parse --verify refs/heads/t &&\n \tgit branch -v -d t &&\n-\ttest_path_is_missing .git/refs/heads/t\n+\ttest_must_fail git rev-parse --verify refs/heads/t\n '\n \n test_expect_success 'git branch -v -m t s should work' '\n \tgit branch t &&\n-\ttest_path_is_file .git/refs/heads/t &&\n+\tgit rev-parse --verify refs/heads/t &&\n \tgit branch -v -m t s &&\n-\ttest_path_is_missing .git/refs/heads/t &&\n-\ttest_path_is_file .git/refs/heads/s &&\n+\ttest_must_fail git rev-parse --verify refs/heads/t &&\n+\tgit rev-parse --verify refs/heads/s &&\n \tgit branch -d s\n '\n \n test_expect_success 'git branch -m -d t s should fail' '\n \tgit branch t &&\n-\ttest_path_is_file .git/refs/heads/t &&\n+\tgit rev-parse refs/heads/t &&\n \ttest_must_fail git branch -m -d t s &&\n \tgit branch -d t &&\n-\ttest_path_is_missing .git/refs/heads/t\n+\ttest_must_fail git rev-parse refs/heads/t\n '\n \n test_expect_success 'git branch --list -d t should fail' '\n \tgit branch t &&\n-\ttest_path_is_file .git/refs/heads/t &&\n+\tgit rev-parse refs/heads/t &&\n \ttest_must_fail git branch --list -d t &&\n \tgit branch -d t &&\n-\ttest_path_is_missing .git/refs/heads/t\n+\ttest_must_fail git rev-parse refs/heads/t\n '\n \n test_expect_success 'git branch --list -v with --abbrev' '\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex aefde7b172..1f871d3cca 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -726,7 +726,7 @@ test_expect_success 'store updates stash ref and reflog' '\n \tgit reset --hard &&\n \t! grep quux bazzy &&\n \tgit stash store -m quuxery $STASH_ID &&\n-\ttest $(cat .git/refs/stash) = $STASH_ID &&\n+\ttest $(git rev-parse stash) = $STASH_ID &&\n \tgit reflog --format=%H stash| grep $STASH_ID &&\n \tgit stash pop &&\n \tgrep quux bazzy\ndiff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\nindex 0680dec808..d4f435155f 100755\n--- a/t/t5500-fetch-pack.sh\n+++ b/t/t5500-fetch-pack.sh\n@@ -30,7 +30,7 @@ add () {\n \ttest_tick &&\n \tcommit=$(echo \"$text\" | git commit-tree $tree $parents) &&\n \teval \"$name=$commit; export $name\" &&\n-\techo $commit > .git/refs/heads/$branch &&\n+\tgit update-ref \"refs/heads/$branch\" \"$commit\" &&\n \teval ${branch}TIP=$commit\n }\n \n@@ -45,10 +45,10 @@ pull_to_client () {\n \n \t\t\tcase \"$heads\" in\n \t\t\t    *A*)\n-\t\t\t\t    echo $ATIP > .git/refs/heads/A;;\n+\t\t\t\t    git update-ref refs/heads/A \"$ATIP\";;\n \t\t\tesac &&\n \t\t\tcase \"$heads\" in *B*)\n-\t\t\t    echo $BTIP > .git/refs/heads/B;;\n+\t\t\t    git update-ref refs/heads/B \"$BTIP\";;\n \t\t\tesac &&\n \t\t\tgit symbolic-ref HEAD refs/heads/$(echo $heads \\\n \t\t\t\t| sed -e \"s/^\\(.\\).*$/\\1/\") &&\n@@ -92,8 +92,8 @@ test_expect_success 'setup' '\n \t\tcur=$(($cur+1))\n \tdone &&\n \tadd B1 $A1 &&\n-\techo $ATIP > .git/refs/heads/A &&\n-\techo $BTIP > .git/refs/heads/B &&\n+\tgit update-ref refs/heads/A \"$ATIP\" &&\n+\tgit update-ref refs/heads/B \"$BTIP\" &&\n \tgit symbolic-ref HEAD refs/heads/B\n '\n \ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex ae5a530a2d..e402aee6a2 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -63,7 +63,7 @@ test_expect_success \"fetch test\" '\n \tgit commit -a -m \"updated by origin\" &&\n \tcd two &&\n \tgit fetch &&\n-\ttest -f .git/refs/heads/one &&\n+\tgit rev-parse --verify refs/heads/one &&\n \tmine=$(git rev-parse refs/heads/one) &&\n \this=$(cd ../one && git rev-parse refs/heads/master) &&\n \ttest \"z$mine\" = \"z$his\"\n@@ -73,8 +73,8 @@ test_expect_success \"fetch test for-merge\" '\n \tcd \"$D\" &&\n \tcd three &&\n \tgit fetch &&\n-\ttest -f .git/refs/heads/two &&\n-\ttest -f .git/refs/heads/one &&\n+\tgit rev-parse --verify refs/heads/two &&\n+\tgit rev-parse --verify refs/heads/one &&\n \tmaster_in_two=$(cd ../two && git rev-parse master) &&\n \tone_in_two=$(cd ../two && git rev-parse one) &&\n \t{\ndiff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh\nindex 31db7b5f91..aa2d360ce3 100755\n--- a/t/t6010-merge-base.sh\n+++ b/t/t6010-merge-base.sh\n@@ -34,7 +34,7 @@ doit () {\n \n \tcommit=$(echo $NAME | git commit-tree $T $PARENTS) &&\n \n-\techo $commit >.git/refs/tags/$NAME &&\n+\tgit update-ref \"refs/tags/$NAME\" \"$commit\" &&\n \techo $commit\n }\n \ndiff --git a/t/t7201-co.sh b/t/t7201-co.sh\nindex 76c223c967..ab9da61da3 100755\n--- a/t/t7201-co.sh\n+++ b/t/t7201-co.sh\n@@ -65,7 +65,7 @@ test_expect_success setup '\n test_expect_success \"checkout from non-existing branch\" '\n \n \tgit checkout -b delete-me master &&\n-\trm .git/refs/heads/delete-me &&\n+\tgit update-ref -d --no-deref refs/heads/delete-me &&\n \ttest refs/heads/delete-me = \"$(git symbolic-ref HEAD)\" &&\n \tgit checkout master &&\n \ttest refs/heads/master = \"$(git symbolic-ref HEAD)\"\ndiff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh\nindex a735fa3717..9c49b6c1fe 100755\n--- a/t/t9104-git-svn-follow-parent.sh\n+++ b/t/t9104-git-svn-follow-parent.sh\n@@ -215,7 +215,8 @@ test_expect_success \"multi-fetch continues to work\" \"\n \t\"\n \n test_expect_success \"multi-fetch works off a 'clean' repository\" '\n-\trm -r \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" \"$GIT_DIR/logs\" &&\n+\trm -rf \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" &&\n+\tgit reflog expire --all --expire=all &&\n \tmkdir \"$GIT_DIR/svn\" &&\n \tgit svn multi-fetch\n \t'\n-- \n2.17.0.764.gc4bd0c3328\n\n"},{"id":"348356","messageId":"xmqqo9h6vr85.fsf@gitster-ct.c.googlers.com","threadId":"48552","inReplyTo":"20180523052517.4443-1-chriscool@tuxfamily.org","subject":"Re: [PATCH v2] t: make many tests depend less on the refs being files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-05-23T06:08:42Z","receivedAt":"2018-05-23T06:08:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <christian.couder@gmail.com> writes:\n\n> The internals of the loose refs backend are still tested in\n> t1400-update-ref.sh, whereas the tests changed in this patch focus\n> on testing other aspects.\n>\n> This patch just takes care of many low hanging fruits. It does not\n> try to completely solves the issue.\n\nThanks.  All conversions in this patch look correct to me.\n\nWill queue.\n"},{"id":"348526","messageId":"615f57ad-7591-128a-0c42-660312d34ca2@alum.mit.edu","threadId":"48552","inReplyTo":"20180523052517.4443-1-chriscool@tuxfamily.org","subject":"Re: [PATCH v2] t: make many tests depend less on the refs being files","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2018-05-25T08:48:04Z","receivedAt":"2018-05-25T08:48:28Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 05/23/2018 07:25 AM, Christian Couder wrote:\n> From: David Turner <dturner@twopensource.com>\n> \n> Many tests are very focused on the file system representation of the\n> loose and packed refs code. As there are plans to implement other\n> ref storage systems, let's migrate these tests to a form that test\n> the intent of the refs storage system instead of it internals.\n> [...]\n> \n> diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh\n> index 9e782a8122..a4ebb0b65f 100755\n> --- a/t/t1401-symbolic-ref.sh\n> +++ b/t/t1401-symbolic-ref.sh\n> @@ -65,7 +65,7 @@ reset_to_sane\n>  test_expect_success 'symbolic-ref fails to delete real ref' '\n>  \techo \"fatal: Cannot delete refs/heads/foo, not a symbolic ref\" >expect &&\n>  \ttest_must_fail git symbolic-ref -d refs/heads/foo >actual 2>&1 &&\n> -\ttest_path_is_file .git/refs/heads/foo &&\n> +\tgit rev-parse --verify refs/heads/foo &&\n>  \ttest_cmp expect actual\n>  '\n>  reset_to_sane\n\nShould t1401 be considered a backend-agnostic test, or is it needed to\nensure that symbolic refs are written correctly in the files backend?\n\n> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\n> index c0ef946811..222dc2c377 100755\n> --- a/t/t3200-branch.sh\n> +++ b/t/t3200-branch.sh\n> @@ -234,34 +234,34 @@ test_expect_success 'git branch -M master2 master2 should work when master is ch\n>  \n>  test_expect_success 'git branch -v -d t should work' '\n>  \tgit branch t &&\n> -\ttest_path_is_file .git/refs/heads/t &&\n> +\tgit rev-parse --verify refs/heads/t &&\n>  \tgit branch -v -d t &&\n> -\ttest_path_is_missing .git/refs/heads/t\n> +\ttest_must_fail git rev-parse --verify refs/heads/t\n>  '\n>  \n>  test_expect_success 'git branch -v -m t s should work' '\n>  \tgit branch t &&\n> -\ttest_path_is_file .git/refs/heads/t &&\n> +\tgit rev-parse --verify refs/heads/t &&\n>  \tgit branch -v -m t s &&\n> -\ttest_path_is_missing .git/refs/heads/t &&\n> -\ttest_path_is_file .git/refs/heads/s &&\n> +\ttest_must_fail git rev-parse --verify refs/heads/t &&\n> +\tgit rev-parse --verify refs/heads/s &&\n>  \tgit branch -d s\n>  '\n>  \n>  test_expect_success 'git branch -m -d t s should fail' '\n>  \tgit branch t &&\n> -\ttest_path_is_file .git/refs/heads/t &&\n> +\tgit rev-parse refs/heads/t &&\n>  \ttest_must_fail git branch -m -d t s &&\n>  \tgit branch -d t &&\n> -\ttest_path_is_missing .git/refs/heads/t\n> +\ttest_must_fail git rev-parse refs/heads/t\n>  '\n>  \n>  test_expect_success 'git branch --list -d t should fail' '\n>  \tgit branch t &&\n> -\ttest_path_is_file .git/refs/heads/t &&\n> +\tgit rev-parse refs/heads/t &&\n>  \ttest_must_fail git branch --list -d t &&\n>  \tgit branch -d t &&\n> -\ttest_path_is_missing .git/refs/heads/t\n> +\ttest_must_fail git rev-parse refs/heads/t\n>  '\n>  \n>  test_expect_success 'git branch --list -v with --abbrev' '\n> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\n> index aefde7b172..1f871d3cca 100755\n> --- a/t/t3903-stash.sh\n> +++ b/t/t3903-stash.sh\n> @@ -726,7 +726,7 @@ test_expect_success 'store updates stash ref and reflog' '\n>  \tgit reset --hard &&\n>  \t! grep quux bazzy &&\n>  \tgit stash store -m quuxery $STASH_ID &&\n> -\ttest $(cat .git/refs/stash) = $STASH_ID &&\n> +\ttest $(git rev-parse stash) = $STASH_ID &&\n>  \tgit reflog --format=%H stash| grep $STASH_ID &&\n>  \tgit stash pop &&\n>  \tgrep quux bazzy\n> diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\n> index 0680dec808..d4f435155f 100755\n> --- a/t/t5500-fetch-pack.sh\n> +++ b/t/t5500-fetch-pack.sh\n> @@ -30,7 +30,7 @@ add () {\n>  \ttest_tick &&\n>  \tcommit=$(echo \"$text\" | git commit-tree $tree $parents) &&\n>  \teval \"$name=$commit; export $name\" &&\n> -\techo $commit > .git/refs/heads/$branch &&\n> +\tgit update-ref \"refs/heads/$branch\" \"$commit\" &&\n>  \teval ${branch}TIP=$commit\n>  }\n>  \n> @@ -45,10 +45,10 @@ pull_to_client () {\n>  \n>  \t\t\tcase \"$heads\" in\n>  \t\t\t    *A*)\n> -\t\t\t\t    echo $ATIP > .git/refs/heads/A;;\n> +\t\t\t\t    git update-ref refs/heads/A \"$ATIP\";;\n>  \t\t\tesac &&\n>  \t\t\tcase \"$heads\" in *B*)\n> -\t\t\t    echo $BTIP > .git/refs/heads/B;;\n> +\t\t\t    git update-ref refs/heads/B \"$BTIP\";;\n>  \t\t\tesac &&\n>  \t\t\tgit symbolic-ref HEAD refs/heads/$(echo $heads \\\n>  \t\t\t\t| sed -e \"s/^\\(.\\).*$/\\1/\") &&\n> @@ -92,8 +92,8 @@ test_expect_success 'setup' '\n>  \t\tcur=$(($cur+1))\n>  \tdone &&\n>  \tadd B1 $A1 &&\n> -\techo $ATIP > .git/refs/heads/A &&\n> -\techo $BTIP > .git/refs/heads/B &&\n> +\tgit update-ref refs/heads/A \"$ATIP\" &&\n> +\tgit update-ref refs/heads/B \"$BTIP\" &&\n>  \tgit symbolic-ref HEAD refs/heads/B\n>  '\n>  \n> diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\n> index ae5a530a2d..e402aee6a2 100755\n> --- a/t/t5510-fetch.sh\n> +++ b/t/t5510-fetch.sh\n> @@ -63,7 +63,7 @@ test_expect_success \"fetch test\" '\n>  \tgit commit -a -m \"updated by origin\" &&\n>  \tcd two &&\n>  \tgit fetch &&\n> -\ttest -f .git/refs/heads/one &&\n> +\tgit rev-parse --verify refs/heads/one &&\n>  \tmine=$(git rev-parse refs/heads/one) &&\n>  \this=$(cd ../one && git rev-parse refs/heads/master) &&\n>  \ttest \"z$mine\" = \"z$his\"\n> @@ -73,8 +73,8 @@ test_expect_success \"fetch test for-merge\" '\n>  \tcd \"$D\" &&\n>  \tcd three &&\n>  \tgit fetch &&\n> -\ttest -f .git/refs/heads/two &&\n> -\ttest -f .git/refs/heads/one &&\n> +\tgit rev-parse --verify refs/heads/two &&\n> +\tgit rev-parse --verify refs/heads/one &&\n>  \tmaster_in_two=$(cd ../two && git rev-parse master) &&\n>  \tone_in_two=$(cd ../two && git rev-parse one) &&\n>  \t{\n> diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh\n> index 31db7b5f91..aa2d360ce3 100755\n> --- a/t/t6010-merge-base.sh\n> +++ b/t/t6010-merge-base.sh\n> @@ -34,7 +34,7 @@ doit () {\n>  \n>  \tcommit=$(echo $NAME | git commit-tree $T $PARENTS) &&\n>  \n> -\techo $commit >.git/refs/tags/$NAME &&\n> +\tgit update-ref \"refs/tags/$NAME\" \"$commit\" &&\n>  \techo $commit\n>  }\n>  \n> diff --git a/t/t7201-co.sh b/t/t7201-co.sh\n> index 76c223c967..ab9da61da3 100755\n> --- a/t/t7201-co.sh\n> +++ b/t/t7201-co.sh\n> @@ -65,7 +65,7 @@ test_expect_success setup '\n>  test_expect_success \"checkout from non-existing branch\" '\n>  \n>  \tgit checkout -b delete-me master &&\n> -\trm .git/refs/heads/delete-me &&\n> +\tgit update-ref -d --no-deref refs/heads/delete-me &&\n>  \ttest refs/heads/delete-me = \"$(git symbolic-ref HEAD)\" &&\n>  \tgit checkout master &&\n>  \ttest refs/heads/master = \"$(git symbolic-ref HEAD)\"\n> diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh\n> index a735fa3717..9c49b6c1fe 100755\n> --- a/t/t9104-git-svn-follow-parent.sh\n> +++ b/t/t9104-git-svn-follow-parent.sh\n> @@ -215,7 +215,8 @@ test_expect_success \"multi-fetch continues to work\" \"\n>  \t\"\n>  \n>  test_expect_success \"multi-fetch works off a 'clean' repository\" '\n> -\trm -r \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" \"$GIT_DIR/logs\" &&\n> +\trm -rf \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" &&\n> +\tgit reflog expire --all --expire=all &&\n>  \tmkdir \"$GIT_DIR/svn\" &&\n>  \tgit svn multi-fetch\n>  \t'\n> \n\n`rm -rf \"$GIT_DIR/refs/remotes\"` is not kosher. I think it can be written\n\n    printf 'option no-deref\\ndelete %s\\n' $(git for-each-ref\n--format='%(refname)' refs/remotes) | git update-ref --stdin\n\nas long as the number of references doesn't exceed command-line limits.\nThis will also take care of the reflogs. Another alternative would be to\nwrite it as a loop.\n\nMichael\n"},{"id":"348528","messageId":"20180525085906.GA2948@sigill.intra.peff.net","threadId":"48552","inReplyTo":"615f57ad-7591-128a-0c42-660312d34ca2@alum.mit.edu","subject":"Re: [PATCH v2] t: make many tests depend less on the refs being files","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-05-25T08:59:06Z","receivedAt":"2018-05-25T08:59:11Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, May 25, 2018 at 10:48:04AM +0200, Michael Haggerty wrote:\n\n> >  test_expect_success \"multi-fetch works off a 'clean' repository\" '\n> > -\trm -r \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" \"$GIT_DIR/logs\" &&\n> > +\trm -rf \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" &&\n> > +\tgit reflog expire --all --expire=all &&\n> >  \tmkdir \"$GIT_DIR/svn\" &&\n> >  \tgit svn multi-fetch\n> >  \t'\n> > \n> \n> `rm -rf \"$GIT_DIR/refs/remotes\"` is not kosher. I think it can be written\n> \n>     printf 'option no-deref\\ndelete %s\\n' $(git for-each-ref\n> --format='%(refname)' refs/remotes) | git update-ref --stdin\n> \n> as long as the number of references doesn't exceed command-line limits.\n> This will also take care of the reflogs. Another alternative would be to\n> write it as a loop.\n\nPerhaps:\n\n  git for-each-ref --format=\"option no-deref%0adelete %(refname)\" refs/remotes |\n  git update-ref --stdin\n\n-Peff\n"},{"id":"348529","messageId":"CAMy9T_E_wO-XKn-BoVpnoUn8cGsmE4z11AzbqW+7Ppo=P9zcDg@mail.gmail.com","threadId":"48552","inReplyTo":"20180525085906.GA2948@sigill.intra.peff.net","subject":"Re: [PATCH v2] t: make many tests depend less on the refs being files","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2018-05-25T09:05:54Z","receivedAt":"2018-05-25T09:06:02Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On Fri, May 25, 2018 at 10:59 AM, Jeff King <peff@peff.net> wrote:\n> On Fri, May 25, 2018 at 10:48:04AM +0200, Michael Haggerty wrote:\n>\n>> >  test_expect_success \"multi-fetch works off a 'clean' repository\" '\n>> > -   rm -r \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" \"$GIT_DIR/logs\" &&\n>> > +   rm -rf \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" &&\n>> > +   git reflog expire --all --expire=all &&\n>> >     mkdir \"$GIT_DIR/svn\" &&\n>> >     git svn multi-fetch\n>> >     '\n>> >\n>>\n>> `rm -rf \"$GIT_DIR/refs/remotes\"` is not kosher. I think it can be written\n>>\n>>     printf 'option no-deref\\ndelete %s\\n' $(git for-each-ref\n>> --format='%(refname)' refs/remotes) | git update-ref --stdin\n>>\n>> as long as the number of references doesn't exceed command-line limits.\n>> This will also take care of the reflogs. Another alternative would be to\n>> write it as a loop.\n>\n> Perhaps:\n>\n>   git for-each-ref --format=\"option no-deref%0adelete %(refname)\" refs/remotes |\n>   git update-ref --stdin\n\nAh yes, that's nicer. I tried with `\\n`, but that's not supported\n(wouldn't it be nice if it were?). I didn't think to try `%0a` (let\nalone look in the documentation!)\n\nMichael\n"},{"id":"348536","messageId":"CAP8UFD3hqQ_F0yafS6v6GWvN7zYomM-=fsZKotP9r-9Xc4qJ+g@mail.gmail.com","threadId":"48552","inReplyTo":"615f57ad-7591-128a-0c42-660312d34ca2@alum.mit.edu","subject":"Re: [PATCH v2] t: make many tests depend less on the refs being files","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2018-05-25T11:21:05Z","receivedAt":"2018-05-25T11:21:10Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Fri, May 25, 2018 at 10:48 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote:\n> On 05/23/2018 07:25 AM, Christian Couder wrote:\n>>\n>> diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh\n>> index 9e782a8122..a4ebb0b65f 100755\n>> --- a/t/t1401-symbolic-ref.sh\n>> +++ b/t/t1401-symbolic-ref.sh\n>> @@ -65,7 +65,7 @@ reset_to_sane\n>>  test_expect_success 'symbolic-ref fails to delete real ref' '\n>>       echo \"fatal: Cannot delete refs/heads/foo, not a symbolic ref\" >expect &&\n>>       test_must_fail git symbolic-ref -d refs/heads/foo >actual 2>&1 &&\n>> -     test_path_is_file .git/refs/heads/foo &&\n>> +     git rev-parse --verify refs/heads/foo &&\n>>       test_cmp expect actual\n>>  '\n>>  reset_to_sane\n>\n> Should t1401 be considered a backend-agnostic test, or is it needed to\n> ensure that symbolic refs are written correctly in the files backend?\n\nI don't know. And I am ok to go either way. Another possibility would\nbe to split in two parts.\n"},{"id":"348537","messageId":"CAP8UFD2gPoOqFbp18c3UFzp9XpGM8qrojzXsN1s4sXBEhCaF6g@mail.gmail.com","threadId":"48552","inReplyTo":"CAMy9T_E_wO-XKn-BoVpnoUn8cGsmE4z11AzbqW+7Ppo=P9zcDg@mail.gmail.com","subject":"Re: [PATCH v2] t: make many tests depend less on the refs being files","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2018-05-25T11:22:05Z","receivedAt":"2018-05-25T11:22:09Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Fri, May 25, 2018 at 11:05 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote:\n> On Fri, May 25, 2018 at 10:59 AM, Jeff King <peff@peff.net> wrote:\n>> On Fri, May 25, 2018 at 10:48:04AM +0200, Michael Haggerty wrote:\n>>\n>>> >  test_expect_success \"multi-fetch works off a 'clean' repository\" '\n>>> > -   rm -r \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" \"$GIT_DIR/logs\" &&\n>>> > +   rm -rf \"$GIT_DIR/svn\" \"$GIT_DIR/refs/remotes\" &&\n>>> > +   git reflog expire --all --expire=all &&\n>>> >     mkdir \"$GIT_DIR/svn\" &&\n>>> >     git svn multi-fetch\n>>> >     '\n>>> >\n>>>\n>>> `rm -rf \"$GIT_DIR/refs/remotes\"` is not kosher. I think it can be written\n>>>\n>>>     printf 'option no-deref\\ndelete %s\\n' $(git for-each-ref\n>>> --format='%(refname)' refs/remotes) | git update-ref --stdin\n>>>\n>>> as long as the number of references doesn't exceed command-line limits.\n>>> This will also take care of the reflogs. Another alternative would be to\n>>> write it as a loop.\n>>\n>> Perhaps:\n>>\n>>   git for-each-ref --format=\"option no-deref%0adelete %(refname)\" refs/remotes |\n>>   git update-ref --stdin\n>\n> Ah yes, that's nicer. I tried with `\\n`, but that's not supported\n> (wouldn't it be nice if it were?). I didn't think to try `%0a` (let\n> alone look in the documentation!)\n\nThanks both for this suggestion. I plan to use it in another patch.\n"}]}