{"thread":{"id":"50345","subject":"[PATCH v3 1/3] Add tests for describe with --work-tree","startedAt":"2019-01-29T05:22:05Z","lastAt":"2019-01-30T12:44:48Z","messageCount":15,"participants":["Sebastian Staudt","Jeff King","Junio C Hamano","Eric Sunshine"],"isPatch":true,"patchVersion":3,"patchTotal":3},"messages":[{"id":"367929","messageId":"20190129051859.12830-1-koraktor@gmail.com","threadId":"50345","inReplyTo":null,"subject":"[PATCH v3 1/3] Add tests for describe with --work-tree","fromName":"Sebastian Staudt","fromEmail":"koraktor@gmail.com","sentAt":"2019-01-29T05:18:57Z","receivedAt":"2019-01-29T05:22:05Z","isPatch":true,"sender":{"key":"koraktor@gmail.com","avatar":"https://avatars.githubusercontent.com/u/66112?v=4"},"body":"The dirty ones are already passing, but just because describe is comparing\nwith the wrong working tree.\n\nSigned-off-by: Sebastian Staudt <koraktor@gmail.com>\n---\n t/t6120-describe.sh | 33 +++++++++++++++++++++++++++++++++\n 1 file changed, 33 insertions(+)\n\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex d639d94696..c863c4f600 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -145,14 +145,38 @@ check_describe A-* HEAD\n \n check_describe \"A-*[0-9a-f]\" --dirty\n \n+test_expect_success 'describe --dirty with --work-tree' \"\n+\t(\n+\t\tcd '$TEST_DIRECTORY' &&\n+\t\tgit --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --dirty >'$TRASH_DIRECTORY/out'\n+\t) &&\n+\tgrep 'A-\\d\\+-g[0-9a-f]\\+' '$TRASH_DIRECTORY/out'\n+\"\n+\n test_expect_success 'set-up dirty work tree' '\n \techo >>file\n '\n \n check_describe \"A-*[0-9a-f]-dirty\" --dirty\n \n+test_expect_success 'describe --dirty with --work-tree' \"\n+\t(\n+\t\tcd '$TEST_DIRECTORY' &&\n+\t\tgit --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --dirty >'$TRASH_DIRECTORY/out'\n+\t) &&\n+\tgrep 'A-\\d\\+-g[0-9a-f]\\+-dirty' '$TRASH_DIRECTORY/out'\n+\"\n+\n check_describe \"A-*[0-9a-f].mod\" --dirty=.mod\n \n+test_expect_success 'describe --dirty=.mod with --work-tree' \"\n+\t(\n+\t\tcd '$TEST_DIRECTORY' &&\n+\t\tgit --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --dirty=.mod >'$TRASH_DIRECTORY/out'\n+\t) &&\n+\tgrep 'A-\\d\\+-g[0-9a-f]\\+.mod' '$TRASH_DIRECTORY/out'\n+\"\n+\n test_expect_success 'describe --dirty HEAD' '\n \ttest_must_fail git describe --dirty HEAD\n '\n@@ -303,12 +327,21 @@ test_expect_success 'describe chokes on severely broken submodules' '\n \tmv .git/modules/sub1/ .git/modules/sub_moved &&\n \ttest_must_fail git describe --dirty\n '\n+\n test_expect_success 'describe ignoring a broken submodule' '\n \tgit describe --broken >out &&\n \ttest_when_finished \"mv .git/modules/sub_moved .git/modules/sub1\" &&\n \tgrep broken out\n '\n \n+test_expect_success 'describe with --work-tree ignoring a broken submodule' \"\n+\t(\n+\t\tcd '$TEST_DIRECTORY' &&\n+\t\tgit --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --broken >'$TRASH_DIRECTORY/out'\n+\t) &&\n+\tgrep broken '$TRASH_DIRECTORY/out'\n+\"\n+\n test_expect_success 'describe a blob at a directly tagged commit' '\n \techo \"make it a unique blob\" >file &&\n \tgit add file && git commit -m \"content in file\" &&\n-- \n2.20.1\n\n"},{"id":"367930","messageId":"20190129051859.12830-2-koraktor@gmail.com","threadId":"50345","inReplyTo":"20190129051859.12830-1-koraktor@gmail.com","subject":"[PATCH v3 2/3] Setup working tree in describe","fromName":"Sebastian Staudt","fromEmail":"koraktor@gmail.com","sentAt":"2019-01-29T05:18:58Z","receivedAt":"2019-01-29T05:22:07Z","isPatch":true,"sender":{"key":"koraktor@gmail.com","avatar":"https://avatars.githubusercontent.com/u/66112?v=4"},"body":"This ensures the given working tree is used for --dirty.\n\nThe implementation of --broken uses diff-index which calls\nsetup_work_tree() itself.\n\nSigned-off-by: Sebastian Staudt <koraktor@gmail.com>\n---\n builtin/describe.c | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex cc118448ee..b5b7abdc8f 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -629,6 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \t\t\tstruct argv_array args = ARGV_ARRAY_INIT;\n \t\t\tint fd, result;\n \n+\t\t\tsetup_work_tree();\n \t\t\tread_cache();\n \t\t\trefresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,\n \t\t\t\t      NULL, NULL, NULL);\n-- \n2.20.1\n\n"},{"id":"367931","messageId":"20190129051859.12830-3-koraktor@gmail.com","threadId":"50345","inReplyTo":"20190129051859.12830-1-koraktor@gmail.com","subject":"[PATCH v3 3/3] Add test for describe with a bare repository","fromName":"Sebastian Staudt","fromEmail":"koraktor@gmail.com","sentAt":"2019-01-29T05:18:59Z","receivedAt":"2019-01-29T05:22:08Z","isPatch":true,"sender":{"key":"koraktor@gmail.com","avatar":"https://avatars.githubusercontent.com/u/66112?v=4"},"body":"This ensures that nothing breaks the basic functionality of describe for\nbare repositories. Please note that --broken and --dirty need a working\ntree.\n\nSigned-off-by: Sebastian Staudt <koraktor@gmail.com>\n---\n t/t6120-describe.sh | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex c863c4f600..f7539a2650 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -418,4 +418,9 @@ test_expect_success 'describe complains about missing object' '\n \ttest_must_fail git describe $ZERO_OID\n '\n \n+test_expect_success 'describe works from outside repo using --git-dir' \"\n+  git clone --bare '$TRASH_DIRECTORY' '$TRASH_DIRECTORY/bare' &&\n+  git --git-dir '$TRASH_DIRECTORY/bare' describe\n+\"\n+\n test_done\n-- \n2.20.1\n\n"},{"id":"367954","messageId":"20190129130031.GA22211@sigill.intra.peff.net","threadId":"50345","inReplyTo":"20190129051859.12830-1-koraktor@gmail.com","subject":"Re: [PATCH v3 1/3] Add tests for describe with --work-tree","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-01-29T13:00:32Z","receivedAt":"2019-01-29T13:00:35Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jan 29, 2019 at 06:18:57AM +0100, Sebastian Staudt wrote:\n\n> The dirty ones are already passing, but just because describe is comparing\n> with the wrong working tree.\n> \n> Signed-off-by: Sebastian Staudt <koraktor@gmail.com>\n> ---\n>  t/t6120-describe.sh | 33 +++++++++++++++++++++++++++++++++\n>  1 file changed, 33 insertions(+)\n> \n> diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\n> index d639d94696..c863c4f600 100755\n> --- a/t/t6120-describe.sh\n> +++ b/t/t6120-describe.sh\n> @@ -145,14 +145,38 @@ check_describe A-* HEAD\n>  \n>  check_describe \"A-*[0-9a-f]\" --dirty\n>  \n> +test_expect_success 'describe --dirty with --work-tree' \"\n\nThis should be marked as test_expect_failure, I think, because it does\nnot yet pass (and then flipped s/failure/success/ in the next patch).\n\n> +\t(\n> +\t\tcd '$TEST_DIRECTORY' &&\n> +\t\tgit --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --dirty >'$TRASH_DIRECTORY/out'\n> +\t) &&\n\nThe quoting you've done here is unusual for our test suite, and not\nquite as robust. You've put the whole test snippet into double-quotes,\nwhich means that $TRASH_DIRECTORY, etc, will be expanded before we eval\nthe code.\n\nBy putting single-quotes around $TRASH_DIRECTORY, that makes it work\nwhen the path contains a space. But it would fail if somebody's\nfilesystem path contains a single-quote.\n\nThe usual style is to put the whole snippet into single-quotes, and then\ndouble-quote as appropriate within it. Like:\n\n  test_expect_failure 'describe --dirty with --work-tree' '\n\t(\n\t\tcd \"$TEST_DIRECTORY\" &&\n\t\tgit --git-dir \"$TRASH_DIRECTORY/.git\" ...etc\n\nThose variables will be expanded when test_expect_failure eval's the\nsnippet.\n\n> +\tgrep 'A-\\d\\+-g[0-9a-f]\\+' '$TRASH_DIRECTORY/out'\n\nUsing \"\\d\" isn't portable.\n\nThis regex is pretty broad. What are we checking here? If I understand\nthe previous discussion, we just care that it doesn't have \"dirty\" in\nit, right? I don't think this regex does that, because it doesn't anchor\nthe end of string.\n\nIf that's indeed what we're checking, then an easier check is perhaps:\n\n  ! grep dirty ...\n\nAs a side note, you can also shorten your references to \"out\" by\nreferring to it from the trash directory itself. I.e.:\n\n  (\n\tcd \"$TEST_DIRECTORY\" &&\n\tgit --git-dir=\"$TRASH_DIRECTORY/.git\" --work-tree \"$TRASH_DIRECTORY\" \\\n\t  describe --dirty\n  ) >out &&\n  ! grep dirty out\n\nSame thing, but IMHO a little easier to read.\n\n>  check_describe \"A-*[0-9a-f]-dirty\" --dirty\n>  \n> +test_expect_success 'describe --dirty with --work-tree' \"\n> [...]\n\nSame comments apply to the other blocks you added.\n\nOther than those mechanical things, though, what the tests are actually\ntrying to do seems quite reasonable to me.\n\n-Peff\n"},{"id":"367955","messageId":"20190129131151.GB22211@sigill.intra.peff.net","threadId":"50345","inReplyTo":"20190129051859.12830-2-koraktor@gmail.com","subject":"Re: [PATCH v3 2/3] Setup working tree in describe","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-01-29T13:11:51Z","receivedAt":"2019-01-29T13:11:55Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jan 29, 2019 at 06:18:58AM +0100, Sebastian Staudt wrote:\n\n> Subject: Re: [PATCH v3 2/3] Setup working tree in describe\n\nWe usually write subjects as \"area: do some thing\" which is a little\neasier when scanning big lists of \"git log --oneline\".\n\nI think it's key, too, that we only do this for the --dirty case, not\nalways. So maybe:\n\n  describe: setup working tree for --dirty\n\nor something?\n\n> This ensures the given working tree is used for --dirty.\n\nThere's been a lot of digging and discussion on the list about what\nhappens if we don't do this. Could we summarize it here?\n\nPerhaps:\n\n  We don't use NEED_WORK_TREE when running the git-describe builtin,\n  since you should be able to describe a commit even in a bare\n  repository. However, the --dirty flag does need a working tree. Since\n  we don't call setup_work_tree(), it uses whatever directory we happen\n  to be in. That's unlikely to match our index, meaning we'd say \"dirty\"\n  even when the real working tree is clean.\n\n  We can fix that by calling setup_work_tree() once we know that the\n  user has asked for --dirty.\n\n> The implementation of --broken uses diff-index which calls\n> setup_work_tree() itself.\n\nIf I hadn't just read the rest of the thread, I'd probably wonder why we\nare talking about --broken at all. Maybe:\n\n  The --broken option similarly needs a working tree. But because the\n  current implementation calls an external diff-index to do the work,\n  we don't have to bother setting up the working tree in the\n  git-describe process.\n\n> diff --git a/builtin/describe.c b/builtin/describe.c\n> index cc118448ee..b5b7abdc8f 100644\n> --- a/builtin/describe.c\n> +++ b/builtin/describe.c\n> @@ -629,6 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n>  \t\t\tstruct argv_array args = ARGV_ARRAY_INIT;\n>  \t\t\tint fd, result;\n>  \n> +\t\t\tsetup_work_tree();\n>  \t\t\tread_cache();\n>  \t\t\trefresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,\n>  \t\t\t\t      NULL, NULL, NULL);\n\nThe patch itself looks good. :)\n\n-Peff\n"},{"id":"367956","messageId":"20190129131243.GC22211@sigill.intra.peff.net","threadId":"50345","inReplyTo":"20190129051859.12830-3-koraktor@gmail.com","subject":"Re: [PATCH v3 3/3] Add test for describe with a bare repository","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-01-29T13:12:43Z","receivedAt":"2019-01-29T13:12:47Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jan 29, 2019 at 06:18:59AM +0100, Sebastian Staudt wrote:\n\n> This ensures that nothing breaks the basic functionality of describe for\n> bare repositories. Please note that --broken and --dirty need a working\n> tree.\n\nMakes sense.\n\n> +test_expect_success 'describe works from outside repo using --git-dir' \"\n> +  git clone --bare '$TRASH_DIRECTORY' '$TRASH_DIRECTORY/bare' &&\n> +  git --git-dir '$TRASH_DIRECTORY/bare' describe\n> +\"\n\nWhat the test is doing seems sane, but the same quoting comments from\nthe earlier patch apply.\n\n-Peff\n"},{"id":"368020","messageId":"xmqqr2cv8isf.fsf@gitster-ct.c.googlers.com","threadId":"50345","inReplyTo":"20190129131151.GB22211@sigill.intra.peff.net","subject":"Re: [PATCH v3 2/3] Setup working tree in describe","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-01-29T17:39:44Z","receivedAt":"2019-01-29T17:39:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Jan 29, 2019 at 06:18:58AM +0100, Sebastian Staudt wrote:\n>\n>> Subject: Re: [PATCH v3 2/3] Setup working tree in describe\n>\n> We usually write subjects as \"area: do some thing\" which is a little\n> easier when scanning big lists of \"git log --oneline\".\n>\n> I think it's key, too, that we only do this for the --dirty case, not\n> always. So maybe:\n>\n>   describe: setup working tree for --dirty\n>\n> or something?\n\nThanks as always for being an excellent reviewer who not just\nreviews but also gives good suggestions.\n\n>> This ensures the given working tree is used for --dirty.\n>\n> There's been a lot of digging and discussion on the list about what\n> happens if we don't do this. Could we summarize it here?\n>\n> Perhaps:\n>\n>   We don't use NEED_WORK_TREE when running the git-describe builtin,\n>   since you should be able to describe a commit even in a bare\n>   repository. However, the --dirty flag does need a working tree. Since\n>   we don't call setup_work_tree(), it uses whatever directory we happen\n>   to be in. That's unlikely to match our index, meaning we'd say \"dirty\"\n>   even when the real working tree is clean.\n>\n>   We can fix that by calling setup_work_tree() once we know that the\n>   user has asked for --dirty.\n>\n>> The implementation of --broken uses diff-index which calls\n>> setup_work_tree() itself.\n>\n> If I hadn't just read the rest of the thread, I'd probably wonder why we\n> are talking about --broken at all. Maybe:\n>\n>   The --broken option similarly needs a working tree. But because the\n>   current implementation calls an external diff-index to do the work,\n>   we don't have to bother setting up the working tree in the\n>   git-describe process.\n>\n>> diff --git a/builtin/describe.c b/builtin/describe.c\n>> index cc118448ee..b5b7abdc8f 100644\n>> --- a/builtin/describe.c\n>> +++ b/builtin/describe.c\n>> @@ -629,6 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n>>  \t\t\tstruct argv_array args = ARGV_ARRAY_INIT;\n>>  \t\t\tint fd, result;\n>>  \n>> +\t\t\tsetup_work_tree();\n>>  \t\t\tread_cache();\n>>  \t\t\trefresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,\n>>  \t\t\t\t      NULL, NULL, NULL);\n>\n> The patch itself looks good. :)\n>\n> -Peff\n"},{"id":"368022","messageId":"xmqqmunj8ifc.fsf@gitster-ct.c.googlers.com","threadId":"50345","inReplyTo":"20190129130031.GA22211@sigill.intra.peff.net","subject":"Re: [PATCH v3 1/3] Add tests for describe with --work-tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-01-29T17:47:35Z","receivedAt":"2019-01-29T17:48:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> The usual style is to put the whole snippet into single-quotes, and then\n> double-quote as appropriate within it. Like:\n>\n>   test_expect_failure 'describe --dirty with --work-tree' '\n> \t(\n> \t\tcd \"$TEST_DIRECTORY\" &&\n> \t\tgit --git-dir \"$TRASH_DIRECTORY/.git\" ...etc\n>\n> Those variables will be expanded when test_expect_failure eval's the\n> snippet.\n\nGood.\n\n>> +\tgrep 'A-\\d\\+-g[0-9a-f]\\+' '$TRASH_DIRECTORY/out'\n>\n> Using \"\\d\" isn't portable.\n\nTrue, but not just \\d.  I think using \\ before special characters to\nforce an otherwise basic regular expression to be ERE (i.e. \\+ at\nthe end) is a GNUism.\n\n> This regex is pretty broad. What are we checking here? If I understand\n> the previous discussion, we just care that it doesn't have \"dirty\" in\n> it, right? I don't think this regex does that, because it doesn't anchor\n> the end of string.\n>\n> If that's indeed what we're checking, then an easier check is perhaps:\n>\n>   ! grep dirty ...\n\nGood.\n"},{"id":"368044","messageId":"CAPig+cRUCmaiYqKG6ON==g1sFph-hz6nK5fTYc-9w2JaNFmdLA@mail.gmail.com","threadId":"50345","inReplyTo":"20190129131151.GB22211@sigill.intra.peff.net","subject":"Re: [PATCH v3 2/3] Setup working tree in describe","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-01-29T20:53:40Z","receivedAt":"2019-01-29T20:53:53Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jan 29, 2019 at 8:12 AM Jeff King <peff@peff.net> wrote:\n> On Tue, Jan 29, 2019 at 06:18:58AM +0100, Sebastian Staudt wrote:\n> > This ensures the given working tree is used for --dirty.\n>\n> There's been a lot of digging and discussion on the list about what\n> happens if we don't do this. Could we summarize it here?\n>\n> Perhaps:\n>\n>   We don't use NEED_WORK_TREE when running the git-describe builtin,\n>   since you should be able to describe a commit even in a bare\n>   repository. However, the --dirty flag does need a working tree. Since\n>   we don't call setup_work_tree(), it uses whatever directory we happen\n>   to be in. That's unlikely to match our index, meaning we'd say \"dirty\"\n>   even when the real working tree is clean.\n>\n>   We can fix that by calling setup_work_tree() once we know that the\n>   user has asked for --dirty.\n\nI have not particularly been following this thread, but this proposed\ncommit message does an excellent job of summarizing and explaining the\nissue and making the fix obvious (so, now I don't have to go back and\nread the entire thread).\n\n> > The implementation of --broken uses diff-index which calls\n> > setup_work_tree() itself.\n>\n> If I hadn't just read the rest of the thread, I'd probably wonder why we\n> are talking about --broken at all. Maybe:\n>\n>   The --broken option similarly needs a working tree. But because the\n>   current implementation calls an external diff-index to do the work,\n>   we don't have to bother setting up the working tree in the\n>   git-describe process.\n\nThis rewrite left me slightly in the dark since I had to infer that\ngit-diff-index calls setup_work_tree() itself. Perhaps:\n\n    ...an external diff-index to do the work, which itself calls\n    setup_work_tree(), we don't have to bother...\n\nBut that's minor.\n"},{"id":"368058","messageId":"20190129223529.GB1895@sigill.intra.peff.net","threadId":"50345","inReplyTo":"CAPig+cRUCmaiYqKG6ON==g1sFph-hz6nK5fTYc-9w2JaNFmdLA@mail.gmail.com","subject":"Re: [PATCH v3 2/3] Setup working tree in describe","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-01-29T22:35:30Z","receivedAt":"2019-01-29T22:35:35Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jan 29, 2019 at 03:53:40PM -0500, Eric Sunshine wrote:\n\n> > > The implementation of --broken uses diff-index which calls\n> > > setup_work_tree() itself.\n> >\n> > If I hadn't just read the rest of the thread, I'd probably wonder why we\n> > are talking about --broken at all. Maybe:\n> >\n> >   The --broken option similarly needs a working tree. But because the\n> >   current implementation calls an external diff-index to do the work,\n> >   we don't have to bother setting up the working tree in the\n> >   git-describe process.\n> \n> This rewrite left me slightly in the dark since I had to infer that\n> git-diff-index calls setup_work_tree() itself. Perhaps:\n> \n>     ...an external diff-index to do the work, which itself calls\n>     setup_work_tree(), we don't have to bother...\n> \n> But that's minor.\n\nYeah, my reasoning was that we handed off to diff-index, so if it\ndoesn't work, then it has its own bug. ;) But I agree it is probably\nbetter to just be explicit.\n\n-Peff\n"},{"id":"368106","messageId":"CA+xP2Sb1--LQJs+GXqKVE3FjNHujSn6Q-Ow=-LEHtRLcFJJMGA@mail.gmail.com","threadId":"50345","inReplyTo":"xmqqmunj8ifc.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v3 1/3] Add tests for describe with --work-tree","fromName":"Sebastian Staudt","fromEmail":"koraktor@gmail.com","sentAt":"2019-01-30T10:23:14Z","receivedAt":"2019-01-30T10:23:55Z","isPatch":true,"sender":{"key":"koraktor@gmail.com","avatar":"https://avatars.githubusercontent.com/u/66112?v=4"},"body":"Am Di., 29. Jan. 2019 um 18:47 Uhr schrieb Junio C Hamano <gitster@pobox.com>:\n>\n> Jeff King <peff@peff.net> writes:\n>\n> > The usual style is to put the whole snippet into single-quotes, and then\n> > double-quote as appropriate within it. Like:\n> >\n> >   test_expect_failure 'describe --dirty with --work-tree' '\n> >       (\n> >               cd \"$TEST_DIRECTORY\" &&\n> >               git --git-dir \"$TRASH_DIRECTORY/.git\" ...etc\n> >\n> > Those variables will be expanded when test_expect_failure eval's the\n> > snippet.\n>\n> Good.\n\nOk, thanks. I’ll change this in the next reroll.\n\n>\n> >> +    grep 'A-\\d\\+-g[0-9a-f]\\+' '$TRASH_DIRECTORY/out'\n> >\n> > Using \"\\d\" isn't portable.\n>\n> True, but not just \\d.  I think using \\ before special characters to\n> force an otherwise basic regular expression to be ERE (i.e. \\+ at\n> the end) is a GNUism.\n>\n\nI guess I’ll use the even broader but apparently more portable A-*[0-9a-f]\nthen. It’s used in the other checks, so this should be OK?\n\n> > This regex is pretty broad. What are we checking here? If I understand\n> > the previous discussion, we just care that it doesn't have \"dirty\" in\n> > it, right? I don't think this regex does that, because it doesn't anchor\n> > the end of string.\n> >\n> > If that's indeed what we're checking, then an easier check is perhaps:\n> >\n> >   ! grep dirty ...\n>\n> Good.\n\nThis was copied and pasted from the existing check for describe with a\nclean working tree. So this should be changed, too.\n"},{"id":"368107","messageId":"CA+xP2SZnmTHGd5rB8BtXMNnCoz0SEFdgT-vcgRttJxBdA04ciA@mail.gmail.com","threadId":"50345","inReplyTo":"20190129131243.GC22211@sigill.intra.peff.net","subject":"Re: [PATCH v3 3/3] Add test for describe with a bare repository","fromName":"Sebastian Staudt","fromEmail":"koraktor@gmail.com","sentAt":"2019-01-30T10:23:36Z","receivedAt":"2019-01-30T10:24:16Z","isPatch":true,"sender":{"key":"koraktor@gmail.com","avatar":"https://avatars.githubusercontent.com/u/66112?v=4"},"body":"Am Di., 29. Jan. 2019 um 14:12 Uhr schrieb Jeff King <peff@peff.net>:\n>\n> On Tue, Jan 29, 2019 at 06:18:59AM +0100, Sebastian Staudt wrote:\n>\n> > This ensures that nothing breaks the basic functionality of describe for\n> > bare repositories. Please note that --broken and --dirty need a working\n> > tree.\n>\n> Makes sense.\n>\n> > +test_expect_success 'describe works from outside repo using --git-dir' \"\n> > +  git clone --bare '$TRASH_DIRECTORY' '$TRASH_DIRECTORY/bare' &&\n> > +  git --git-dir '$TRASH_DIRECTORY/bare' describe\n> > +\"\n>\n> What the test is doing seems sane, but the same quoting comments from\n> the earlier patch apply.\n>\n\nOk, thanks.\n\n> -Peff\n"},{"id":"368108","messageId":"CA+xP2Sa9mSaBaYgY4LiAwaqX_YN75NV0qA=sTy0D6X1q=SjQeg@mail.gmail.com","threadId":"50345","inReplyTo":"20190129223529.GB1895@sigill.intra.peff.net","subject":"Re: [PATCH v3 2/3] Setup working tree in describe","fromName":"Sebastian Staudt","fromEmail":"koraktor@gmail.com","sentAt":"2019-01-30T10:31:15Z","receivedAt":"2019-01-30T10:31:55Z","isPatch":true,"sender":{"key":"koraktor@gmail.com","avatar":"https://avatars.githubusercontent.com/u/66112?v=4"},"body":"Am Di., 29. Jan. 2019 um 23:35 Uhr schrieb Jeff King <peff@peff.net>:\n>\n> On Tue, Jan 29, 2019 at 03:53:40PM -0500, Eric Sunshine wrote:\n>\n> > > > The implementation of --broken uses diff-index which calls\n> > > > setup_work_tree() itself.\n> > >\n> > > If I hadn't just read the rest of the thread, I'd probably wonder why we\n> > > are talking about --broken at all. Maybe:\n> > >\n> > >   The --broken option similarly needs a working tree. But because the\n> > >   current implementation calls an external diff-index to do the work,\n> > >   we don't have to bother setting up the working tree in the\n> > >   git-describe process.\n> >\n> > This rewrite left me slightly in the dark since I had to infer that\n> > git-diff-index calls setup_work_tree() itself. Perhaps:\n> >\n> >     ...an external diff-index to do the work, which itself calls\n> >     setup_work_tree(), we don't have to bother...\n> >\n> > But that's minor.\n>\n> Yeah, my reasoning was that we handed off to diff-index, so if it\n> doesn't work, then it has its own bug. ;) But I agree it is probably\n> better to just be explicit.\n\nThanks for that valuable feedback.\nIs there some trailer like \"Co-authored-commit-message-by:\"? ;)\n\n>\n> -Peff\n"},{"id":"368127","messageId":"20190130124331.GA2273@sigill.intra.peff.net","threadId":"50345","inReplyTo":"CA+xP2Sb1--LQJs+GXqKVE3FjNHujSn6Q-Ow=-LEHtRLcFJJMGA@mail.gmail.com","subject":"Re: [PATCH v3 1/3] Add tests for describe with --work-tree","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-01-30T12:43:32Z","receivedAt":"2019-01-30T12:43:37Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jan 30, 2019 at 11:23:14AM +0100, Sebastian Staudt wrote:\n\n> > >> +    grep 'A-\\d\\+-g[0-9a-f]\\+' '$TRASH_DIRECTORY/out'\n> > >\n> > > Using \"\\d\" isn't portable.\n> >\n> > True, but not just \\d.  I think using \\ before special characters to\n> > force an otherwise basic regular expression to be ERE (i.e. \\+ at\n> > the end) is a GNUism.\n> >\n> \n> I guess I’ll use the even broader but apparently more portable A-*[0-9a-f]\n> then. It’s used in the other checks, so this should be OK?\n\nYeah, that is OK, as long as you use it with `case` like check_describe\ndoes. Because it's a glob and not a regex, you do not have to worry\nabout the anchoring issue.\n\nOr if you mean to do an anchored but more general regex like:\n\n  ^A-.*[0-9a-f]$\n\nthat is OK, too.\n\n> > > If that's indeed what we're checking, then an easier check is perhaps:\n> > >\n> > >   ! grep dirty ...\n> >\n> > Good.\n> \n> This was copied and pasted from the existing check for describe with a\n> clean working tree. So this should be changed, too.\n\nI do think that makes what we're checking more obvious, so I wouldn't\nmind seeing the other tests converted to use this. But it may be hard if\nthey are relying on check_describe().\n\nI'm OK with anything that works and is robust. :)\n\n-Peff\n"},{"id":"368128","messageId":"20190130124441.GB2273@sigill.intra.peff.net","threadId":"50345","inReplyTo":"CA+xP2Sa9mSaBaYgY4LiAwaqX_YN75NV0qA=sTy0D6X1q=SjQeg@mail.gmail.com","subject":"Re: [PATCH v3 2/3] Setup working tree in describe","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-01-30T12:44:42Z","receivedAt":"2019-01-30T12:44:48Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jan 30, 2019 at 11:31:15AM +0100, Sebastian Staudt wrote:\n\n> > Yeah, my reasoning was that we handed off to diff-index, so if it\n> > doesn't work, then it has its own bug. ;) But I agree it is probably\n> > better to just be explicit.\n> \n> Thanks for that valuable feedback.\n> Is there some trailer like \"Co-authored-commit-message-by:\"? ;)\n\nWe often say \"Helped-by\", but I am OK with or without that in this case.\nTo me, making suggestions like this is all just part of review. :)\n\n-Peff\n"}]}