{"thread":{"id":"57243","subject":"[PATCH] test-lib: unset trace2 parent envvars","startedAt":"2022-01-14T03:33:41Z","lastAt":"2022-02-01T21:22:25Z","messageCount":10,"participants":["Josh Steadmon","Junio C Hamano","Taylor Blau","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"446197","messageId":"82e51a52e20fbe13a5a898a0a2f6dbe1188e3fa3.1642116539.git.steadmon@google.com","threadId":"57243","inReplyTo":null,"subject":"[PATCH] test-lib: unset trace2 parent envvars","fromName":"Josh Steadmon","fromEmail":"steadmon@google.com","sentAt":"2022-01-14T03:33:36Z","receivedAt":"2022-01-14T03:33:41Z","isPatch":true,"sender":{"key":"steadmon@google.com","avatar":"https://avatars.githubusercontent.com/u/2654920?v=4"},"body":"The trace2 subsystem can inherit certain information from parent\nprocesses via environment variables; e.g., the parent command name and\nsession ID. This allows trace2 to note when a command is the child\nprocess of another Git process, and to adjust various pieces of output\naccordingly.\n\nThis behavior breaks certain tests that examine trace2 output when the\ntests run as a child of another git process, such as in `git rebase -x\n\"make test\"`.\n\nWhile we could fix this by unsetting the relevant variables in the\naffected tests (currently t0210, t0211, t0212, and t6421), this would\nleave other tests vulnerable to similar breakage if new test cases are\nadded which inspect trace2 output. So fix this in general by unsetting\nGIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in test-lib.sh.\n\nReported-by: Emily Shaffer <emilyshaffer@google.com>\nHelped-by: Jonathan Tan <jonathantanmy@google.com>\nSigned-off-by: Josh Steadmon <steadmon@google.com>\n---\n t/test-lib.sh | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 0f7a137c7d..e4716b0b86 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -449,6 +449,8 @@ unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n unset XDG_CACHE_HOME\n unset XDG_CONFIG_HOME\n unset GITPERLLIB\n+unset GIT_TRACE2_PARENT_NAME\n+unset GIT_TRACE2_PARENT_SID\n TEST_AUTHOR_LOCALNAME=author\n TEST_AUTHOR_DOMAIN=example.com\n GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}\n\nbase-commit: dcc0cd074f0c639a0df20461a301af6d45bd582e\n-- \n2.34.1.703.g22d0c6ccf7-goog\n\n"},{"id":"446203","messageId":"xmqq35lqetzw.fsf@gitster.g","threadId":"57243","inReplyTo":"82e51a52e20fbe13a5a898a0a2f6dbe1188e3fa3.1642116539.git.steadmon@google.com","subject":"Re: [PATCH] test-lib: unset trace2 parent envvars","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-14T06:01:07Z","receivedAt":"2022-01-14T06:01:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Josh Steadmon <steadmon@google.com> writes:\n\n> This behavior breaks certain tests that examine trace2 output when the\n> tests run as a child of another git process, such as in `git rebase -x\n> \"make test\"`.\n\nWell explained.  The paragraph makes it clear how easy to trigger\nand get bitten by this problem.\n\n> While we could fix this by unsetting the relevant variables in the\n> affected tests (currently t0210, t0211, t0212, and t6421), this would\n> leave other tests vulnerable to similar breakage if new test cases are\n> added which inspect trace2 output. So fix this in general by unsetting\n> GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in test-lib.sh.\n\nThis probably makes sense, but I wonder how it interacts with a user\nwho runs \"cd t && GIT_TRACE2=blah ./t0987-test-this.sh\" to trace the\nentire test script, though.\n\n> Reported-by: Emily Shaffer <emilyshaffer@google.com>\n> Helped-by: Jonathan Tan <jonathantanmy@google.com>\n> Signed-off-by: Josh Steadmon <steadmon@google.com>\n> ---\n>  t/test-lib.sh | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 0f7a137c7d..e4716b0b86 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -449,6 +449,8 @@ unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n>  unset XDG_CACHE_HOME\n>  unset XDG_CONFIG_HOME\n>  unset GITPERLLIB\n> +unset GIT_TRACE2_PARENT_NAME\n> +unset GIT_TRACE2_PARENT_SID\n\nHmph.  Have you noticed the more generic \"We want to unset almost\neverything that begins with GIT_, other than those selected few that\nare designed to be used to affect the tests\" above the part you\ntouched?\n\nI am wondering if we should tweak the list there, instead of special\ncasing these two and these two only. There is a pattern that allows\nanything that match \"^GIT_(other|TRACE|things)\", and I suspect that\nthe pattern is way too loose (i.e. it allows any garbage to follow,\nand by allowing \"TRACE\", it also catches \"TRACE2\" because the former\nis a prefix of the latter), which is a problem.\n"},{"id":"446452","messageId":"Yecv7H5rrdMnRJBs@google.com","threadId":"57243","inReplyTo":"xmqq35lqetzw.fsf@gitster.g","subject":"Re: [PATCH] test-lib: unset trace2 parent envvars","fromName":"Josh Steadmon","fromEmail":"steadmon@google.com","sentAt":"2022-01-18T21:23:56Z","receivedAt":"2022-01-18T21:24:05Z","isPatch":true,"sender":{"key":"steadmon@google.com","avatar":"https://avatars.githubusercontent.com/u/2654920?v=4"},"body":"On 2022.01.13 22:01, Junio C Hamano wrote:\n> Josh Steadmon <steadmon@google.com> writes:\n> \n> > This behavior breaks certain tests that examine trace2 output when the\n> > tests run as a child of another git process, such as in `git rebase -x\n> > \"make test\"`.\n> \n> Well explained.  The paragraph makes it clear how easy to trigger\n> and get bitten by this problem.\n> \n> > While we could fix this by unsetting the relevant variables in the\n> > affected tests (currently t0210, t0211, t0212, and t6421), this would\n> > leave other tests vulnerable to similar breakage if new test cases are\n> > added which inspect trace2 output. So fix this in general by unsetting\n> > GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in test-lib.sh.\n> \n> This probably makes sense, but I wonder how it interacts with a user\n> who runs \"cd t && GIT_TRACE2=blah ./t0987-test-this.sh\" to trace the\n> entire test script, though.\n\nThere shouldn't be any problems with this specific use case. I don't see\na valid reason for a test runner to fake GIT_TRACE2_PARENT_{NAME,SID}\nthough. None of the TRACE2 modes require using any of the PARENT\nvariables.\n\n\n> > Reported-by: Emily Shaffer <emilyshaffer@google.com>\n> > Helped-by: Jonathan Tan <jonathantanmy@google.com>\n> > Signed-off-by: Josh Steadmon <steadmon@google.com>\n> > ---\n> >  t/test-lib.sh | 2 ++\n> >  1 file changed, 2 insertions(+)\n> >\n> > diff --git a/t/test-lib.sh b/t/test-lib.sh\n> > index 0f7a137c7d..e4716b0b86 100644\n> > --- a/t/test-lib.sh\n> > +++ b/t/test-lib.sh\n> > @@ -449,6 +449,8 @@ unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n> >  unset XDG_CACHE_HOME\n> >  unset XDG_CONFIG_HOME\n> >  unset GITPERLLIB\n> > +unset GIT_TRACE2_PARENT_NAME\n> > +unset GIT_TRACE2_PARENT_SID\n> \n> Hmph.  Have you noticed the more generic \"We want to unset almost\n> everything that begins with GIT_, other than those selected few that\n> are designed to be used to affect the tests\" above the part you\n> touched?\n> \n> I am wondering if we should tweak the list there, instead of special\n> casing these two and these two only. There is a pattern that allows\n> anything that match \"^GIT_(other|TRACE|things)\", and I suspect that\n> the pattern is way too loose (i.e. it allows any garbage to follow,\n> and by allowing \"TRACE\", it also catches \"TRACE2\" because the former\n> is a prefix of the latter), which is a problem.\n\nYes, due to the number of different TRACE2 modes, I figured it was\ncleaner to allow them by default and then explicitly unset the ones that\ncause trouble for trace parsing tests. But if you prefer to lock down\nthe list, I can send an alternate fix.\n\n\nThanks,\nJosh\n"},{"id":"446453","messageId":"YecxIJpaAzXRjGJG@nand.local","threadId":"57243","inReplyTo":"xmqq35lqetzw.fsf@gitster.g","subject":"Re: [PATCH] test-lib: unset trace2 parent envvars","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-01-18T21:29:04Z","receivedAt":"2022-01-18T21:29:08Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Thu, Jan 13, 2022 at 10:01:07PM -0800, Junio C Hamano wrote:\n> Josh Steadmon <steadmon@google.com> writes:\n>\n> > This behavior breaks certain tests that examine trace2 output when the\n> > tests run as a child of another git process, such as in `git rebase -x\n> > \"make test\"`.\n>\n> Well explained.  The paragraph makes it clear how easy to trigger\n> and get bitten by this problem.\n>\n> > While we could fix this by unsetting the relevant variables in the\n> > affected tests (currently t0210, t0211, t0212, and t6421), this would\n> > leave other tests vulnerable to similar breakage if new test cases are\n> > added which inspect trace2 output. So fix this in general by unsetting\n> > GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in test-lib.sh.\n>\n> This probably makes sense, but I wonder how it interacts with a user\n> who runs \"cd t && GIT_TRACE2=blah ./t0987-test-this.sh\" to trace the\n> entire test script, though.\n>\n> > Reported-by: Emily Shaffer <emilyshaffer@google.com>\n> > Helped-by: Jonathan Tan <jonathantanmy@google.com>\n> > Signed-off-by: Josh Steadmon <steadmon@google.com>\n> > ---\n> >  t/test-lib.sh | 2 ++\n> >  1 file changed, 2 insertions(+)\n> >\n> > diff --git a/t/test-lib.sh b/t/test-lib.sh\n> > index 0f7a137c7d..e4716b0b86 100644\n> > --- a/t/test-lib.sh\n> > +++ b/t/test-lib.sh\n> > @@ -449,6 +449,8 @@ unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n> >  unset XDG_CACHE_HOME\n> >  unset XDG_CONFIG_HOME\n> >  unset GITPERLLIB\n> > +unset GIT_TRACE2_PARENT_NAME\n> > +unset GIT_TRACE2_PARENT_SID\n>\n> Hmph.  Have you noticed the more generic \"We want to unset almost\n> everything that begins with GIT_, other than those selected few that\n> are designed to be used to affect the tests\" above the part you\n> touched?\n>\n> I am wondering if we should tweak the list there, instead of special\n> casing these two and these two only. There is a pattern that allows\n> anything that match \"^GIT_(other|TRACE|things)\", and I suspect that\n> the pattern is way too loose (i.e. it allows any garbage to follow,\n> and by allowing \"TRACE\", it also catches \"TRACE2\" because the former\n> is a prefix of the latter), which is a problem.\n\nI was thinking the same thing, but I suspect that this may truly be\ndifferent. That list says we should be able to keep anything that looks\nlike GIT_TRACE in our environment. So the same should be true of\nTRACE2-related variables, I'd think.\n\nBut the PARENT_NAME and PARENT_SID variables are (as far as I can tell\nfrom reading around) internal variables that help us piece together the\nnames of the Git commands we ran.\n\nIn other words, excluding all TRACE2 variables goes too far since it\nprevents us from being able to `GIT_TRACE2=1 make test`. But we would\nwant to clear out any internal TRACE2 variables such as PARENT_NAME and\nPARENT_SID.\n\nThanks,\nTaylor\n"},{"id":"446456","messageId":"xmqq4k60sogk.fsf@gitster.g","threadId":"57243","inReplyTo":"Yecv7H5rrdMnRJBs@google.com","subject":"Re: [PATCH] test-lib: unset trace2 parent envvars","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-18T21:50:35Z","receivedAt":"2022-01-18T21:50:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Josh Steadmon <steadmon@google.com> writes:\n\n> Yes, due to the number of different TRACE2 modes, I figured it was\n> cleaner to allow them by default and then explicitly unset the ones that\n> cause trouble for trace parsing tests.\n\nI think I would agree that it is a better solution, and the design\nbehind it (which makes me say it is better) should be recorded in\nthe log message (and possibly in-code comment near the place we\nreset them) to help future developers who may add more TRACE2\nvariables.\n\nThanks.\n\n\n\n"},{"id":"447007","messageId":"2b5e573c22f226cbdb07d931d470a37bca7ffe2b.1643234866.git.steadmon@google.com","threadId":"57243","inReplyTo":"82e51a52e20fbe13a5a898a0a2f6dbe1188e3fa3.1642116539.git.steadmon@google.com","subject":"[PATCH v2] test-lib: unset trace2 parent envvars","fromName":"Josh Steadmon","fromEmail":"steadmon@google.com","sentAt":"2022-01-26T22:10:53Z","receivedAt":"2022-01-26T22:11:01Z","isPatch":true,"sender":{"key":"steadmon@google.com","avatar":"https://avatars.githubusercontent.com/u/2654920?v=4"},"body":"The trace2 subsystem can inherit certain information from parent\nprocesses via environment variables; e.g., the parent command name and\nsession ID. This allows trace2 to note when a command is the child\nprocess of another Git process, and to adjust various pieces of output\naccordingly.\n\nThis behavior breaks certain tests that examine trace2 output when the\ntests run as a child of another git process, such as in `git rebase -x\n\"make test\"`.\n\nWhile we could fix this by unsetting the relevant variables in the\naffected tests (currently t0210, t0211, t0212, and t6421), this would\nleave other tests vulnerable to similar breakage if new test cases are\nadded which inspect trace2 output.\n\nIn t/test-lib.sh, we keep a pattern of permitted GIT_* environment\nvariables. Variables matching /^GIT_TRACE.*/ are currently allowed via\nthis pattern. We want to preserve this behavior, because it can be\nuseful to collect trace output over the entire test suite. Instead of\nmodifying the allow-pattern, we instead fix this issue by unsetting only\nthe GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in t/test-lib.sh.\n\nReported-by: Emily Shaffer <emilyshaffer@google.com>\nSigned-off-by: Josh Steadmon <steadmon@google.com>\n---\nUpdated commit message and added code comments to explain why we keep\n\"TRACE\" in the allow pattern.\n\n t/test-lib.sh | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 0f7a137c7d..faf25ba1b2 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -432,7 +432,7 @@ EDITOR=:\n unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n \tmy @env = keys %ENV;\n \tmy $ok = join(\"|\", qw(\n-\t\tTRACE\n+\t\tTRACE\t# Allow tracing in general, but see unsets below.\n \t\tDEBUG\n \t\tTEST\n \t\t.*_TEST\n@@ -449,6 +449,10 @@ unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n unset XDG_CACHE_HOME\n unset XDG_CONFIG_HOME\n unset GITPERLLIB\n+# Unset trace environment variables that can interfere with trace output used in\n+# certain tests.\n+unset GIT_TRACE2_PARENT_NAME\n+unset GIT_TRACE2_PARENT_SID\n TEST_AUTHOR_LOCALNAME=author\n TEST_AUTHOR_DOMAIN=example.com\n GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}\n\nbase-commit: dcc0cd074f0c639a0df20461a301af6d45bd582e\n-- \n2.35.0.rc0.227.g00780c9af4-goog\n\n"},{"id":"447008","messageId":"YfHHAXjReQoMhjdl@google.com","threadId":"57243","inReplyTo":"xmqq4k60sogk.fsf@gitster.g","subject":"Re: [PATCH] test-lib: unset trace2 parent envvars","fromName":"Josh Steadmon","fromEmail":"steadmon@google.com","sentAt":"2022-01-26T22:11:13Z","receivedAt":"2022-01-26T22:11:22Z","isPatch":true,"sender":{"key":"steadmon@google.com","avatar":"https://avatars.githubusercontent.com/u/2654920?v=4"},"body":"On 2022.01.18 13:50, Junio C Hamano wrote:\n> Josh Steadmon <steadmon@google.com> writes:\n> \n> > Yes, due to the number of different TRACE2 modes, I figured it was\n> > cleaner to allow them by default and then explicitly unset the ones that\n> > cause trouble for trace parsing tests.\n> \n> I think I would agree that it is a better solution, and the design\n> behind it (which makes me say it is better) should be recorded in\n> the log message (and possibly in-code comment near the place we\n> reset them) to help future developers who may add more TRACE2\n> variables.\n> \n> Thanks.\n\nFixed in V2. Thanks!\n"},{"id":"447034","messageId":"220127.86r18tdeve.gmgdl@evledraar.gmail.com","threadId":"57243","inReplyTo":"2b5e573c22f226cbdb07d931d470a37bca7ffe2b.1643234866.git.steadmon@google.com","subject":"Re: [PATCH v2] test-lib: unset trace2 parent envvars","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-01-27T03:23:10Z","receivedAt":"2022-01-27T03:41:49Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Jan 26 2022, Josh Steadmon wrote:\n\n> The trace2 subsystem can inherit certain information from parent\n> processes via environment variables; e.g., the parent command name and\n> session ID. This allows trace2 to note when a command is the child\n> process of another Git process, and to adjust various pieces of output\n> accordingly.\n>\n> This behavior breaks certain tests that examine trace2 output when the\n> tests run as a child of another git process, such as in `git rebase -x\n> \"make test\"`.\n>\n> While we could fix this by unsetting the relevant variables in the\n> affected tests (currently t0210, t0211, t0212, and t6421), this would\n> leave other tests vulnerable to similar breakage if new test cases are\n> added which inspect trace2 output.\n>\n> In t/test-lib.sh, we keep a pattern of permitted GIT_* environment\n> variables. Variables matching /^GIT_TRACE.*/ are currently allowed via\n> this pattern. We want to preserve this behavior, because it can be\n> useful to collect trace output over the entire test suite. Instead of\n> modifying the allow-pattern, we instead fix this issue by unsetting only\n> the GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in t/test-lib.sh.\n>\n> Reported-by: Emily Shaffer <emilyshaffer@google.com>\n> Signed-off-by: Josh Steadmon <steadmon@google.com>\n> ---\n> Updated commit message and added code comments to explain why we keep\n> \"TRACE\" in the allow pattern.\n>\n>  t/test-lib.sh | 6 +++++-\n>  1 file changed, 5 insertions(+), 1 deletion(-)\n>\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 0f7a137c7d..faf25ba1b2 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -432,7 +432,7 @@ EDITOR=:\n>  unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n>  \tmy @env = keys %ENV;\n>  \tmy $ok = join(\"|\", qw(\n> -\t\tTRACE\n> +\t\tTRACE\t# Allow tracing in general, but see unsets below.\n\nI think it would be good to turn that -e into a -we, which would tell\nyou why this doesn't work the way you think:\n\n    Possible attempt to put comments in qw() list at -e line 14.\n    Possible attempt to separate words with commas at -e line 14.\n\nI.e. you added one string \"#\" to the array, and a string \"Allow\" etc.\n\nI think replacing it with this would be clearer, and means that...\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 0f7a137c7d8..9a7611f412f 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -432,7 +432,7 @@ EDITOR=:\n unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n \tmy @env = keys %ENV;\n \tmy $ok = join(\"|\", qw(\n-\t\tTRACE\n+\t\tTRACE(?!2_(?:PARENT_NAME|PARENT_SID)$)\n \t\tDEBUG\n \t\tTEST\n \t\t.*_TEST\n\n\n>  \t\tDEBUG\n>  \t\tTEST\n>  \t\t.*_TEST\n> @@ -449,6 +449,10 @@ unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n>  unset XDG_CACHE_HOME\n>  unset XDG_CONFIG_HOME\n>  unset GITPERLLIB\n> +# Unset trace environment variables that can interfere with trace output used in\n> +# certain tests.\n> +unset GIT_TRACE2_PARENT_NAME\n> +unset GIT_TRACE2_PARENT_SID\n>  TEST_AUTHOR_LOCALNAME=author\n>  TEST_AUTHOR_DOMAIN=example.com\n>  GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}\n>\n> base-commit: dcc0cd074f0c639a0df20461a301af6d45bd582e\n\n...you won't need this hunk, since it'll be obvious that we're\nspecifically excluding those variables.\n\nBut more generally I think it's best to replace this with the below,\ni.e. to also fold the nearby \"unset\" into this command which'll find\neverything we need to unset for us, since it was doing most of the work\nanyway.\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 0f7a137c7d8..ff4d4a553be 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -426,13 +426,12 @@ export LANG LC_ALL PAGER TZ COLUMNS\n EDITOR=:\n \n # A call to \"unset\" with no arguments causes at least Solaris 10\n-# /usr/xpg4/bin/sh and /bin/ksh to bail out.  So keep the unsets\n-# deriving from the command substitution clustered with the other\n-# ones.\n-unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n+# /usr/xpg4/bin/sh and /bin/ksh to bail out.  So we'll need at least\n+# one unconditional variable here, which might as well be VISUAL.\n+unset VISUAL $(\"$PERL_PATH\" -we '\n \tmy @env = keys %ENV;\n \tmy $ok = join(\"|\", qw(\n-\t\tTRACE\n+\t\tTRACE(?!2_(?:PARENT_NAME|PARENT_SID)$)\n \t\tDEBUG\n \t\tTEST\n \t\t.*_TEST\n@@ -444,11 +443,20 @@ unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n \t\tTRACE_CURL\n \t));\n \tmy @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);\n+\tmy @nongit = qw(\n+\t\tCDPATH\n+\t\tEMAIL\n+\t\tGITPERLLIB\n+\t\tGREP_OPTIONS\n+\t\tLANGUAGE\n+\t\tUNZIP\n+\t\tXDG_CACHE_HOME\n+\t\tXDG_CONFIG_HOME\n+\t);\n+\tpush @vars => grep { exists $ENV{$_} } @nongit;\n \tprint join(\"\\n\", @vars);\n ')\n-unset XDG_CACHE_HOME\n-unset XDG_CONFIG_HOME\n-unset GITPERLLIB\n+\n TEST_AUTHOR_LOCALNAME=author\n TEST_AUTHOR_DOMAIN=example.com\n GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}\n@@ -524,13 +532,6 @@ else\n \t}\n fi\n \n-# Protect ourselves from common misconfiguration to export\n-# CDPATH into the environment\n-unset CDPATH\n-\n-unset GREP_OPTIONS\n-unset UNZIP\n-\n case $(echo $GIT_TRACE |tr \"[A-Z]\" \"[a-z]\") in\n 1|2|true)\n \tGIT_TRACE=4\n"},{"id":"447107","messageId":"xmqqlez12fsd.fsf@gitster.g","threadId":"57243","inReplyTo":"220127.86r18tdeve.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v2] test-lib: unset trace2 parent envvars","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-27T18:29:38Z","receivedAt":"2022-01-27T18:29:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>> index 0f7a137c7d..faf25ba1b2 100644\n>> --- a/t/test-lib.sh\n>> +++ b/t/test-lib.sh\n>> @@ -432,7 +432,7 @@ EDITOR=:\n>>  unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n>>  \tmy @env = keys %ENV;\n>>  \tmy $ok = join(\"|\", qw(\n>> -\t\tTRACE\n>> +\t\tTRACE\t# Allow tracing in general, but see unsets below.\n>\n> I think it would be good to turn that -e into a -we, which would tell\n> you why this doesn't work the way you think:\n>\n>     Possible attempt to put comments in qw() list at -e line 14.\n>     Possible attempt to separate words with commas at -e line 14.\n>\n> I.e. you added one string \"#\" to the array, and a string \"Allow\" etc.\n\nHaving an expert who can spot these things at first glance is handy\n;-).  Very much appreciated.\n\nIn any case, the previous iteration has been in 'next' long enough\nwithout causing trouble for those who use a variant based on 'next'\nat $DAYJOB, I presume, so my recommendation is to just let it\ngraduate first, and pursue your suggestion to do more things in this\nscriptlet (below, omitted) as a \"further improvement\" on top.\n\nThanks.\n"},{"id":"447464","messageId":"YfmkgeoSGdic83j4@google.com","threadId":"57243","inReplyTo":"220127.86r18tdeve.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v2] test-lib: unset trace2 parent envvars","fromName":"Josh Steadmon","fromEmail":"steadmon@google.com","sentAt":"2022-02-01T21:22:09Z","receivedAt":"2022-02-01T21:22:25Z","isPatch":true,"sender":{"key":"steadmon@google.com","avatar":"https://avatars.githubusercontent.com/u/2654920?v=4"},"body":"On 2022.01.27 04:23, Ævar Arnfjörð Bjarmason wrote:\n> \n> On Wed, Jan 26 2022, Josh Steadmon wrote:\n> \n> > The trace2 subsystem can inherit certain information from parent\n> > processes via environment variables; e.g., the parent command name and\n> > session ID. This allows trace2 to note when a command is the child\n> > process of another Git process, and to adjust various pieces of output\n> > accordingly.\n> >\n> > This behavior breaks certain tests that examine trace2 output when the\n> > tests run as a child of another git process, such as in `git rebase -x\n> > \"make test\"`.\n> >\n> > While we could fix this by unsetting the relevant variables in the\n> > affected tests (currently t0210, t0211, t0212, and t6421), this would\n> > leave other tests vulnerable to similar breakage if new test cases are\n> > added which inspect trace2 output.\n> >\n> > In t/test-lib.sh, we keep a pattern of permitted GIT_* environment\n> > variables. Variables matching /^GIT_TRACE.*/ are currently allowed via\n> > this pattern. We want to preserve this behavior, because it can be\n> > useful to collect trace output over the entire test suite. Instead of\n> > modifying the allow-pattern, we instead fix this issue by unsetting only\n> > the GIT_TRACE2_PARENT_NAME and GIT_TRACE2_PARENT_SID in t/test-lib.sh.\n> >\n> > Reported-by: Emily Shaffer <emilyshaffer@google.com>\n> > Signed-off-by: Josh Steadmon <steadmon@google.com>\n> > ---\n> > Updated commit message and added code comments to explain why we keep\n> > \"TRACE\" in the allow pattern.\n> >\n> >  t/test-lib.sh | 6 +++++-\n> >  1 file changed, 5 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/t/test-lib.sh b/t/test-lib.sh\n> > index 0f7a137c7d..faf25ba1b2 100644\n> > --- a/t/test-lib.sh\n> > +++ b/t/test-lib.sh\n> > @@ -432,7 +432,7 @@ EDITOR=:\n> >  unset VISUAL EMAIL LANGUAGE $(\"$PERL_PATH\" -e '\n> >  \tmy @env = keys %ENV;\n> >  \tmy $ok = join(\"|\", qw(\n> > -\t\tTRACE\n> > +\t\tTRACE\t# Allow tracing in general, but see unsets below.\n> \n> I think it would be good to turn that -e into a -we, which would tell\n> you why this doesn't work the way you think:\n> \n>     Possible attempt to put comments in qw() list at -e line 14.\n>     Possible attempt to separate words with commas at -e line 14.\n> \n> I.e. you added one string \"#\" to the array, and a string \"Allow\" etc.\n\nWhoops, yeah, thanks for the catch. I've forgotten most of the Perl I\never knew but should have seen that.\n"}]}