{"thread":{"id":"48208","subject":"[PATCH] t2028: tighten grep expression to make \"move worktree\" test more robust","startedAt":"2018-04-03T09:26:28Z","lastAt":"2018-04-03T15:21:44Z","messageCount":2,"participants":["Eric Sunshine","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"343669","messageId":"20180403092541.43920-1-sunshine@sunshineco.com","threadId":"48208","inReplyTo":null,"subject":"[PATCH] t2028: tighten grep expression to make \"move worktree\" test more robust","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-04-03T09:25:41Z","receivedAt":"2018-04-03T09:26:28Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Following a rename of worktree \"source\" to \"destination\", the \"move\nworktree\" test uses grep to verify that the output of \"git worktree list\n--porcelain\" does not contain \"source\" (and does contain \"destination\").\nUnfortunately, the grep expression is too loose and can match\nunexpectedly. For example, if component of the test trash directory path\nmatches \"source\" (e.g. \"/home/me/sources/git/t/trash*\"), then the test\nwill be fooled into thinking that \"source\" still exists. Tighten the\nexpression to avoid such accidental matches.\n\nWhile at it, drop an unused variable (\"toplevel\") from the test and\ntighten a similarly too-loose expression in a related test.\n\nReported-by: Jens Krüger <Jens.Krueger@frm2.tum.de>\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n\nt2028 in 2.17.0 can be fooled into failing depending upon the path of\nthe test's trash directory. The problem is with the test being too\nloose, not with Git itself. Problem report and diagnosis here[1].\n\n[1]: https://public-inbox.org/git/26a00c2b-c588-68d5-7085-22310c20e6df@frm2.tum.de/T/#m994cdb29f141656b0ab48dd0d152432c7e86fc20\n\n t/t2028-worktree-move.sh | 7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh\nindex 5d5b3632ba..5f7d45b7b7 100755\n--- a/t/t2028-worktree-move.sh\n+++ b/t/t2028-worktree-move.sh\n@@ -72,12 +72,11 @@ test_expect_success 'move locked worktree' '\n '\n \n test_expect_success 'move worktree' '\n-\ttoplevel=\"$(pwd)\" &&\n \tgit worktree move source destination &&\n \ttest_path_is_missing source &&\n \tgit worktree list --porcelain >out &&\n-\tgrep \"^worktree.*/destination\" out &&\n-\t! grep \"^worktree.*/source\" out &&\n+\tgrep \"^worktree.*/destination$\" out &&\n+\t! grep \"^worktree.*/source$\" out &&\n \tgit -C destination log --format=%s >actual2 &&\n \techo init >expected2 &&\n \ttest_cmp expected2 actual2\n@@ -93,7 +92,7 @@ test_expect_success 'move worktree to another dir' '\n \ttest_when_finished \"git worktree move some-dir/destination destination\" &&\n \ttest_path_is_missing destination &&\n \tgit worktree list --porcelain >out &&\n-\tgrep \"^worktree.*/some-dir/destination\" out &&\n+\tgrep \"^worktree.*/some-dir/destination$\" out &&\n \tgit -C some-dir/destination log --format=%s >actual2 &&\n \techo init >expected2 &&\n \ttest_cmp expected2 actual2\n-- \n2.17.0.484.g0c8726318c\n\n"},{"id":"343700","messageId":"CACsJy8DszXXK2htRupg8FhdcSgYweCv4FPAA_ZG23YKGz7AG=Q@mail.gmail.com","threadId":"48208","inReplyTo":"20180403092541.43920-1-sunshine@sunshineco.com","subject":"Re: [PATCH] t2028: tighten grep expression to make \"move worktree\" test more robust","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-04-03T15:21:08Z","receivedAt":"2018-04-03T15:21:44Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Apr 3, 2018 at 11:25 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> Following a rename of worktree \"source\" to \"destination\", the \"move\n> worktree\" test uses grep to verify that the output of \"git worktree list\n> --porcelain\" does not contain \"source\" (and does contain \"destination\").\n> Unfortunately, the grep expression is too loose and can match\n> unexpectedly. For example, if component of the test trash directory path\n> matches \"source\" (e.g. \"/home/me/sources/git/t/trash*\"), then the test\n> will be fooled into thinking that \"source\" still exists. Tighten the\n> expression to avoid such accidental matches.\n>\n> While at it, drop an unused variable (\"toplevel\") from the test and\n> tighten a similarly too-loose expression in a related test.\n>\n> Reported-by: Jens Krüger <Jens.Krueger@frm2.tum.de>\n> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>\n> ---\n>\n> t2028 in 2.17.0 can be fooled into failing depending upon the path of\n> the test's trash directory. The problem is with the test being too\n> loose, not with Git itself. Problem report and diagnosis here[1].\n>\n> [1]: https://public-inbox.org/git/26a00c2b-c588-68d5-7085-22310c20e6df@frm2.tum.de/T/#m994cdb29f141656b0ab48dd0d152432c7e86fc20\n\nThanks both. It was great to scroll to the latest mails and saw that I\ndidn't have to do anything else :)\n-- \nDuy\n"}]}