{"thread":{"id":"53194","subject":"[PATCH] mingw: make is_hidden tests in t0001/t5611 more robust","startedAt":"2020-04-08T19:34:40Z","lastAt":"2020-04-11T21:28:47Z","messageCount":15,"participants":["Johannes Schindelin via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"395092","messageId":"pull.603.git.1586374474512.gitgitgadget@gmail.com","threadId":"53194","inReplyTo":null,"subject":"[PATCH] mingw: make is_hidden tests in t0001/t5611 more robust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-08T19:34:34Z","receivedAt":"2020-04-08T19:34:40Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWe should not actually expect the first `attrib.exe` in the PATH to\nbe the one we are looking for. Or that it is in the PATH, for that\nmatter.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n    Make the tests that test core.hideDotFiles more robust\n    \n    We have this feature on Windows where the files starting with a dot can\n    be marked hidden (whether a file is hidden by default or not is a matter\n    of naming convention on Unix, but it is an explicit flag on Windows).\n    This patch improves the regression tests of this feature, and it has\n    been carried in Git for Windows for over three years.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-603%2Fdscho%2Frobustify-is-hidden-tests-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-603/dscho/robustify-is-hidden-tests-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/603\n\n t/t0001-init.sh         | 2 +-\n t/t5611-clone-config.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 26f82063267..2456688b281 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -395,7 +395,7 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '\n # Tests for the hidden file attribute on windows\n is_hidden () {\n \t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n+\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n \treturn 1\n }\n \ndiff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh\nindex 60c1ba951b7..87b8073cd74 100755\n--- a/t/t5611-clone-config.sh\n+++ b/t/t5611-clone-config.sh\n@@ -95,7 +95,7 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '\n # Tests for the hidden file attribute on windows\n is_hidden () {\n \t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n+\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n \treturn 1\n }\n \n\nbase-commit: 9fadedd637b312089337d73c3ed8447e9f0aa775\n-- \ngitgitgadget\n"},{"id":"395102","messageId":"xmqqmu7locys.fsf@gitster.c.googlers.com","threadId":"53194","inReplyTo":"pull.603.git.1586374474512.gitgitgadget@gmail.com","subject":"Re: [PATCH] mingw: make is_hidden tests in t0001/t5611 more robust","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-08T21:59:55Z","receivedAt":"2020-04-08T22:00:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> diff --git a/t/t0001-init.sh b/t/t0001-init.sh\n> index 26f82063267..2456688b281 100755\n> --- a/t/t0001-init.sh\n> +++ b/t/t0001-init.sh\n> @@ -395,7 +395,7 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '\n>  # Tests for the hidden file attribute on windows\n>  is_hidden () {\n>  \t# Use the output of `attrib`, ignore the absolute path\n> -\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n> +\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n>  \treturn 1\n>  }\n\nI wondered if this (and the other one) want to be in test-lib but I\nam on the fence.  All three tests that call this helper in t0001 are\nprotected with MINGW prerequisite, but until I realized it, the call\nto \"attrib\" (whether it is given as a full path or relies on $PATH\nlookup) looked like a portability nightmare waiting to happen.  It\nwould make it even worse if we moved the above as-is to test-lib, as\nit is harder to see what the callers are doing once we did so.\n\nWith a change like this, however\n\n\tis_hidden () {\n\t\tif ! test_have_prereq MINGW\n\t\tthen\n\t\t\tBUG \"use of is_hidden outside MINGW prerequisite\"\n\t\tfi\n\t\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in \n\t\t*H*?:*)\treturn 0 ;;\n\t\t*)\treturn 1 ;;\n\t\tesac\n\t}\n\nI think it is OK to consolidate these two copies into one in test-lib\n\nThanks.\n\n\n> diff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh\n> index 60c1ba951b7..87b8073cd74 100755\n> --- a/t/t5611-clone-config.sh\n> +++ b/t/t5611-clone-config.sh\n> @@ -95,7 +95,7 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '\n>  # Tests for the hidden file attribute on windows\n>  is_hidden () {\n>  \t# Use the output of `attrib`, ignore the absolute path\n> -\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n> +\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n>  \treturn 1\n>  }\n>  \n>\n> base-commit: 9fadedd637b312089337d73c3ed8447e9f0aa775\n"},{"id":"395140","messageId":"20200409201129.82608-1-gitster@pobox.com","threadId":"53194","inReplyTo":"xmqqmu7locys.fsf@gitster.c.googlers.com","subject":"[PATCH 0/2] make \"is_hidden\" even more robust","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-09T20:11:27Z","receivedAt":"2020-04-09T20:11:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Here are two patches on top of \"mingw: make is_hidden tests in\nt0001/t5611 more robust\" from yesterday to clean up the code by\nconsolidating two copies and make it harder to misuse.\n\nJunio C Hamano (2):\n  mingw: refactor test_path_is_hidden out to t/test-lib-functions.sh\n  t: protect against use of test_path_is_hidden outside MINGW\n\n t/t0001-init.sh         | 13 +++----------\n t/t5611-clone-config.sh | 13 +++----------\n t/test-lib-functions.sh | 14 ++++++++++++++\n 3 files changed, 20 insertions(+), 20 deletions(-)\n\n-- \n2.26.0-106-g9fadedd637\n\n"},{"id":"395141","messageId":"20200409201129.82608-2-gitster@pobox.com","threadId":"53194","inReplyTo":"20200409201129.82608-1-gitster@pobox.com","subject":"[PATCH 1/2] mingw: refactor test_path_is_hidden out to t/test-lib-functions.sh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-09T20:11:28Z","receivedAt":"2020-04-09T20:11:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Two scripts had a copy of the same helper function, which needed the\nsame fix at the same time.  Let's move it to a common place.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t0001-init.sh         | 13 +++----------\n t/t5611-clone-config.sh | 13 +++----------\n t/test-lib-functions.sh |  9 +++++++++\n 3 files changed, 15 insertions(+), 20 deletions(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 2456688b28..6b2e2e3dc2 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -392,13 +392,6 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '\n \ttest_path_is_dir realgitdir/refs\n '\n \n-# Tests for the hidden file attribute on windows\n-is_hidden () {\n-\t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n-\treturn 1\n-}\n-\n test_expect_success MINGW '.git hidden' '\n \trm -rf newdir &&\n \t(\n@@ -406,7 +399,7 @@ test_expect_success MINGW '.git hidden' '\n \t\tmkdir newdir &&\n \t\tcd newdir &&\n \t\tgit init &&\n-\t\tis_hidden .git\n+\t\ttest_path_is_hidden .git\n \t) &&\n \tcheck_config newdir/.git false unset\n '\n@@ -419,7 +412,7 @@ test_expect_success MINGW 'bare git dir not hidden' '\n \t\tcd newdir &&\n \t\tgit --bare init\n \t) &&\n-\t! is_hidden newdir\n+\t! test_path_is_hidden newdir\n '\n \n test_expect_success 'remote init from does not use config from cwd' '\n@@ -456,7 +449,7 @@ test_expect_success MINGW 'core.hidedotfiles = false' '\n \t\tsane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&\n \t\tgit -C newdir init\n \t) &&\n-\t! is_hidden newdir/.git\n+\t! test_path_is_hidden newdir/.git\n '\n \n test_expect_success MINGW 'redirect std handles' '\ndiff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh\nindex 87b8073cd7..8e0fd39823 100755\n--- a/t/t5611-clone-config.sh\n+++ b/t/t5611-clone-config.sh\n@@ -92,24 +92,17 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '\n \ttest_cmp expect actual\n '\n \n-# Tests for the hidden file attribute on windows\n-is_hidden () {\n-\t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n-\treturn 1\n-}\n-\n test_expect_success MINGW 'clone -c core.hideDotFiles' '\n \ttest_commit attributes .gitattributes \"\" &&\n \trm -rf child &&\n \tgit clone -c core.hideDotFiles=false . child &&\n-\t! is_hidden child/.gitattributes &&\n+\t! test_path_is_hidden child/.gitattributes &&\n \trm -rf child &&\n \tgit clone -c core.hideDotFiles=dotGitOnly . child &&\n-\t! is_hidden child/.gitattributes &&\n+\t! test_path_is_hidden child/.gitattributes &&\n \trm -rf child &&\n \tgit clone -c core.hideDotFiles=true . child &&\n-\tis_hidden child/.gitattributes\n+\ttest_path_is_hidden child/.gitattributes\n '\n \n test_done\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 352c213d52..39b478e731 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -760,6 +760,15 @@ test_path_is_missing () {\n \tfi\n }\n \n+# Tests for the hidden file attribute on windows\n+test_path_is_hidden () {\n+\t# Use the output of `attrib`, ignore the absolute path\n+\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in\n+\t*H*?:*)\t\treturn 0;;\n+\tesac\n+\treturn 1\n+}\n+\n # test_line_count checks that a file has the number of lines it\n # ought to. For example:\n #\n-- \n2.26.0-106-g9fadedd637\n\n"},{"id":"395142","messageId":"20200409201129.82608-3-gitster@pobox.com","threadId":"53194","inReplyTo":"20200409201129.82608-1-gitster@pobox.com","subject":"[PATCH 2/2] t: protect against use of test_path_is_hidden outside MINGW","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-09T20:11:29Z","receivedAt":"2020-04-09T20:11:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This test helper function is meant to test if the \"hidden\"\natttribute is set (or unset) as expected on Windows, and use of it\noutside MINGW prerequisite is an error.  Ensure we have the prereq\nand trigger a BUG otherwise.\n\nIt is tempting to instead replace its implementation with something\nlike\n\n\tif test_have_prereq MINGW\n\tthen\n\t\t... current Windows specific code ...\n\telse\n\t\t# ls without -a/-A hides paths that begin with a dot\n\t\tcase \"$(basename \"$1\")\" in\n\t\t.*) return 0 ;;\n\t\tesac\n\tfi\n\treturn 1\n\nbut one test in t0001 is designed specifically that with an option\n\"repository/.git\" of a newly created repository is *not* hidden on\nWindows, which means that it is impossible to make that feature work\non POSIX systems and the above won't test what we want to test.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/test-lib-functions.sh | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 39b478e731..ad54863166 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -762,6 +762,11 @@ test_path_is_missing () {\n \n # Tests for the hidden file attribute on windows\n test_path_is_hidden () {\n+\tif ! test_have_prereq MINGW\n+\tthen\n+\t\tBUG \"use of test_path_is_hidden without MINGW prerequisite\"\n+\tfi\n+\n \t# Use the output of `attrib`, ignore the absolute path\n \tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in\n \t*H*?:*)\t\treturn 0;;\n-- \n2.26.0-106-g9fadedd637\n\n"},{"id":"395171","messageId":"fc4202cb5484e0e24babc20959e1c78d3dc2c156.1586516583.git.gitgitgadget@gmail.com","threadId":"53194","inReplyTo":"pull.603.v2.git.1586516583.gitgitgadget@gmail.com","subject":"[PATCH v2 2/3] mingw: make test_path_is_hidden tests in t0001/t5611 more robust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-10T11:03:02Z","receivedAt":"2020-04-10T11:03:09Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThis function uses Windows' system tool `attrib` to determine the state\nof the hidden flag of a file or directory.\n\nWe should not actually expect the first `attrib.exe` in the PATH to\nbe the one we are looking for. Or that it is in the PATH, for that\nmatter.\n\nLet's use the full path to the tool instead.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/test-lib-functions.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 09a2479fd38..09e2cebb456 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1550,6 +1550,6 @@ test_path_is_hidden () {\n \tBUG \"test_path_is_hidden can only be used on Windows\"\n \n \t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n+\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n \treturn 1\n }\n-- \ngitgitgadget\n\n"},{"id":"395172","messageId":"pull.603.v2.git.1586516583.gitgitgadget@gmail.com","threadId":"53194","inReplyTo":"pull.603.git.1586374474512.gitgitgadget@gmail.com","subject":"[PATCH v2 0/3] Make the tests that test core.hideDotFiles more robust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-10T11:03:00Z","receivedAt":"2020-04-10T11:03:09Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"We have this feature on Windows where the files starting with a dot can be\nmarked hidden (whether a file is hidden by default or not is a matter of\nnaming convention on Unix, but it is an explicit flag on Windows). This\npatch improves the regression tests of this feature, and it has been carried\nin Git for Windows for over three years.\n\nJunio, I'm sorry that I did not get to send v2 yesterday, and that you spent\ntime on the two add-on patches even after I finalized this second iteration\n(but I was first waiting for the PR build to pass and while that happened, I\ngot stuck in meeting after meeting).\n\nChanges since v1:\n\n * A preparatory patch now moves and renames is_hidden to \n   test-lib-functions.sh\n * A typo in the function's comment is fixed, while at it.\n\nJohannes Schindelin (3):\n  t: consolidate the `is_hidden` functions\n  mingw: make test_path_is_hidden tests in t0001/t5611 more robust\n  t: fix casing of the operating system `Windows`\n\n t/t0001-init.sh         |  9 +--------\n t/t5611-clone-config.sh | 13 +++----------\n t/test-lib-functions.sh | 10 ++++++++++\n 3 files changed, 14 insertions(+), 18 deletions(-)\n\n\nbase-commit: 9fadedd637b312089337d73c3ed8447e9f0aa775\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-603%2Fdscho%2Frobustify-is-hidden-tests-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-603/dscho/robustify-is-hidden-tests-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/603\n\nRange-diff vs v1:\n\n -:  ----------- > 1:  dd81ea68d6b t: consolidate the `is_hidden` functions\n 1:  889f7c21333 ! 2:  fc4202cb548 mingw: make is_hidden tests in t0001/t5611 more robust\n     @@ Metadata\n      Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n      \n       ## Commit message ##\n     -    mingw: make is_hidden tests in t0001/t5611 more robust\n     +    mingw: make test_path_is_hidden tests in t0001/t5611 more robust\n     +\n     +    This function uses Windows' system tool `attrib` to determine the state\n     +    of the hidden flag of a file or directory.\n      \n          We should not actually expect the first `attrib.exe` in the PATH to\n          be the one we are looking for. Or that it is in the PATH, for that\n          matter.\n      \n     +    Let's use the full path to the tool instead.\n     +\n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n     - ## t/t0001-init.sh ##\n     -@@ t/t0001-init.sh: test_expect_success SYMLINKS 're-init to move gitdir symlink' '\n     - # Tests for the hidden file attribute on windows\n     - is_hidden () {\n     - \t# Use the output of `attrib`, ignore the absolute path\n     --\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n     -+\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n     - \treturn 1\n     - }\n     + ## t/test-lib-functions.sh ##\n     +@@ t/test-lib-functions.sh: test_path_is_hidden () {\n     + \tBUG \"test_path_is_hidden can only be used on Windows\"\n       \n     -\n     - ## t/t5611-clone-config.sh ##\n     -@@ t/t5611-clone-config.sh: test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '\n     - # Tests for the hidden file attribute on windows\n     - is_hidden () {\n       \t# Use the output of `attrib`, ignore the absolute path\n      -\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n      +\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n       \treturn 1\n       }\n     - \n -:  ----------- > 3:  d0c0767a2aa t: fix casing of the operating system `Windows`\n\n-- \ngitgitgadget\n"},{"id":"395173","messageId":"d0c0767a2aad765297ec82db84c41fec37eba3ec.1586516583.git.gitgitgadget@gmail.com","threadId":"53194","inReplyTo":"pull.603.v2.git.1586516583.gitgitgadget@gmail.com","subject":"[PATCH v2 3/3] t: fix casing of the operating system `Windows`","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-10T11:03:03Z","receivedAt":"2020-04-10T11:03:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe lower-case `windows` refers to something different.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/test-lib-functions.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 09e2cebb456..139647a6341 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1544,7 +1544,7 @@ test_bitmap_traversal () {\n \trm -f \"$1.normalized\" \"$2.normalized\"\n }\n \n-# Tests for the hidden file attribute on windows\n+# Tests for the hidden file attribute on Windows\n test_path_is_hidden () {\n \ttest_have_prereq MINGW ||\n \tBUG \"test_path_is_hidden can only be used on Windows\"\n-- \ngitgitgadget\n"},{"id":"395174","messageId":"dd81ea68d6b74c3031565a472d622d8db1f896bd.1586516583.git.gitgitgadget@gmail.com","threadId":"53194","inReplyTo":"pull.603.v2.git.1586516583.gitgitgadget@gmail.com","subject":"[PATCH v2 1/3] t: consolidate the `is_hidden` functions","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-10T11:03:01Z","receivedAt":"2020-04-10T11:03:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe `is_hidden` function can be used (only on Windows) to determine\nwhether a directory or file have their `hidden` flag set.\n\nThis function is duplicated between two test scripts. It is better to\nmove it into `test-lib-functions.sh` so that it is reused.\n\nTo make it safer to use, we specifically test for the `MINGW` prereq\nnow, so that it is not used on a non-Windows platform by mistake.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t0001-init.sh         |  9 +--------\n t/t5611-clone-config.sh | 13 +++----------\n t/test-lib-functions.sh | 10 ++++++++++\n 3 files changed, 14 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 26f82063267..1edd5aeb8f0 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -392,13 +392,6 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '\n \ttest_path_is_dir realgitdir/refs\n '\n \n-# Tests for the hidden file attribute on windows\n-is_hidden () {\n-\t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n-\treturn 1\n-}\n-\n test_expect_success MINGW '.git hidden' '\n \trm -rf newdir &&\n \t(\n@@ -406,7 +399,7 @@ test_expect_success MINGW '.git hidden' '\n \t\tmkdir newdir &&\n \t\tcd newdir &&\n \t\tgit init &&\n-\t\tis_hidden .git\n+\t\ttest_path_is_hidden .git\n \t) &&\n \tcheck_config newdir/.git false unset\n '\ndiff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh\nindex 60c1ba951b7..8e0fd398236 100755\n--- a/t/t5611-clone-config.sh\n+++ b/t/t5611-clone-config.sh\n@@ -92,24 +92,17 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '\n \ttest_cmp expect actual\n '\n \n-# Tests for the hidden file attribute on windows\n-is_hidden () {\n-\t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n-\treturn 1\n-}\n-\n test_expect_success MINGW 'clone -c core.hideDotFiles' '\n \ttest_commit attributes .gitattributes \"\" &&\n \trm -rf child &&\n \tgit clone -c core.hideDotFiles=false . child &&\n-\t! is_hidden child/.gitattributes &&\n+\t! test_path_is_hidden child/.gitattributes &&\n \trm -rf child &&\n \tgit clone -c core.hideDotFiles=dotGitOnly . child &&\n-\t! is_hidden child/.gitattributes &&\n+\t! test_path_is_hidden child/.gitattributes &&\n \trm -rf child &&\n \tgit clone -c core.hideDotFiles=true . child &&\n-\tis_hidden child/.gitattributes\n+\ttest_path_is_hidden child/.gitattributes\n '\n \n test_done\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 352c213d52e..09a2479fd38 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1543,3 +1543,13 @@ test_bitmap_traversal () {\n \ttest_cmp \"$1.normalized\" \"$2.normalized\" &&\n \trm -f \"$1.normalized\" \"$2.normalized\"\n }\n+\n+# Tests for the hidden file attribute on windows\n+test_path_is_hidden () {\n+\ttest_have_prereq MINGW ||\n+\tBUG \"test_path_is_hidden can only be used on Windows\"\n+\n+\t# Use the output of `attrib`, ignore the absolute path\n+\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n+\treturn 1\n+}\n-- \ngitgitgadget\n\n"},{"id":"395175","messageId":"xmqq5ze7lhi6.fsf@gitster.c.googlers.com","threadId":"53194","inReplyTo":"pull.603.v2.git.1586516583.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 0/3] Make the tests that test core.hideDotFiles more robust","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-10T11:14:41Z","receivedAt":"2020-04-10T11:14:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> Junio, I'm sorry that I did not get to send v2 yesterday, and that you spent\n> time on the two add-on patches even after I finalized this second iteration\n> (but I was first waiting for the PR build to pass and while that happened, I\n> got stuck in meeting after meeting).\n\nHeh, mails cross all the time, so there is not much to be sorry, and\nit is not a race, and it's not much of an issue who sent an\nequivalent patch to the list first ;-)\n\nA few issues I noticed that are not worth pointing out inline with\nthe patches are\n\n [1/3] The \"consolidate\" is a bit uneven.  It keeps the 'windows'\n       (lowercase) to pretend to be a pure code movement, while\n       adding the \"prereq or die\" that makes it an impure code\n       movement.  If I were doing this, this step would be pure code\n       movement, and [3/3] would have the \"prereq or die\" as its\n       main theme, i.e. make sure it is hard to misuse.  [3/3] would\n       also do \"s/windows/Windows/\" as \"while at it\".\n\n [2/3] The test numbers on the title is no longer relevant, and I\n       would suggest retitling this step.  No matter which test uses\n       it currently, or any new uses added in the future to other\n       tests, with this patch the helper is more robust, and it was\n       the point of [1/3].\n \nThanks.\n"},{"id":"395278","messageId":"8650936b8d4e975cd5260cfe312cf79b36c2dcc5.1586612423.git.gitgitgadget@gmail.com","threadId":"53194","inReplyTo":"pull.603.v3.git.1586612422.gitgitgadget@gmail.com","subject":"[PATCH v3 2/3] mingw: make test_path_is_hidden more robust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-11T13:40:21Z","receivedAt":"2020-04-11T13:40:29Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThis function uses Windows' system tool `attrib` to determine the state\nof the hidden flag of a file or directory.\n\nWe should not actually expect the first `attrib.exe` in the PATH to\nbe the one we are looking for. Or that it is in the PATH, for that\nmatter.\n\nLet's use the full path to the tool instead.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/test-lib-functions.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 7a7e7a38312..2f81463a240 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1547,6 +1547,6 @@ test_bitmap_traversal () {\n # Tests for the hidden file attribute on windows\n is_hidden () {\n \t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n+\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n \treturn 1\n }\n-- \ngitgitgadget\n\n"},{"id":"395279","messageId":"pull.603.v3.git.1586612422.gitgitgadget@gmail.com","threadId":"53194","inReplyTo":"pull.603.v2.git.1586516583.gitgitgadget@gmail.com","subject":"[PATCH v3 0/3] Make the tests that test core.hideDotFiles more robust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-11T13:40:19Z","receivedAt":"2020-04-11T13:40:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"We have this feature on Windows where the files starting with a dot can be\nmarked hidden (whether a file is hidden by default or not is a matter of\nnaming convention on Unix, but it is an explicit flag on Windows). This\npatch improves the regression tests of this feature, and it has been carried\nin Git for Windows for over three years.\n\nJunio, I followed your advice, and did one more thing: the function is now\nrenamed also only in 3/3.\n\nChanges since v2:\n\n * The first patch is now a true code move, no edits are snuck in.\n * The typo fix, the function rename, and the prereq check are now all done\n   as a \"cleanup\" patch (the third one).\n\nChanges since v1:\n\n * A preparatory patch now moves and renames is_hidden to \n   test-lib-functions.sh\n * A typo in the function's comment is fixed, while at it.\n\nJohannes Schindelin (3):\n  t: consolidate the `is_hidden` functions\n  mingw: make test_path_is_hidden more robust\n  t: restrict `is_hidden` to be called only on Windows\n\n t/t0001-init.sh         |  9 +--------\n t/t5611-clone-config.sh | 13 +++----------\n t/test-lib-functions.sh | 10 ++++++++++\n 3 files changed, 14 insertions(+), 18 deletions(-)\n\n\nbase-commit: 9fadedd637b312089337d73c3ed8447e9f0aa775\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-603%2Fdscho%2Frobustify-is-hidden-tests-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-603/dscho/robustify-is-hidden-tests-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/603\n\nRange-diff vs v2:\n\n 1:  dd81ea68d6b ! 1:  f13f9f78cda t: consolidate the `is_hidden` functions\n     @@ Commit message\n          This function is duplicated between two test scripts. It is better to\n          move it into `test-lib-functions.sh` so that it is reused.\n      \n     -    To make it safer to use, we specifically test for the `MINGW` prereq\n     -    now, so that it is not used on a non-Windows platform by mistake.\n     +    This patch is best viewed with `--color-moved`.\n      \n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n     @@ t/t0001-init.sh: test_expect_success SYMLINKS 're-init to move gitdir symlink' '\n       test_expect_success MINGW '.git hidden' '\n       \trm -rf newdir &&\n       \t(\n     -@@ t/t0001-init.sh: test_expect_success MINGW '.git hidden' '\n     - \t\tmkdir newdir &&\n     - \t\tcd newdir &&\n     - \t\tgit init &&\n     --\t\tis_hidden .git\n     -+\t\ttest_path_is_hidden .git\n     - \t) &&\n     - \tcheck_config newdir/.git false unset\n     - '\n      \n       ## t/t5611-clone-config.sh ##\n      @@ t/t5611-clone-config.sh: test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '\n     @@ t/t5611-clone-config.sh: test_expect_success 'clone -c remote.<remote>.fetch=<re\n       test_expect_success MINGW 'clone -c core.hideDotFiles' '\n       \ttest_commit attributes .gitattributes \"\" &&\n       \trm -rf child &&\n     - \tgit clone -c core.hideDotFiles=false . child &&\n     --\t! is_hidden child/.gitattributes &&\n     -+\t! test_path_is_hidden child/.gitattributes &&\n     - \trm -rf child &&\n     - \tgit clone -c core.hideDotFiles=dotGitOnly . child &&\n     --\t! is_hidden child/.gitattributes &&\n     -+\t! test_path_is_hidden child/.gitattributes &&\n     - \trm -rf child &&\n     - \tgit clone -c core.hideDotFiles=true . child &&\n     --\tis_hidden child/.gitattributes\n     -+\ttest_path_is_hidden child/.gitattributes\n     - '\n     - \n     - test_done\n      \n       ## t/test-lib-functions.sh ##\n      @@ t/test-lib-functions.sh: test_bitmap_traversal () {\n     @@ t/test-lib-functions.sh: test_bitmap_traversal () {\n       }\n      +\n      +# Tests for the hidden file attribute on windows\n     -+test_path_is_hidden () {\n     -+\ttest_have_prereq MINGW ||\n     -+\tBUG \"test_path_is_hidden can only be used on Windows\"\n     -+\n     ++is_hidden () {\n      +\t# Use the output of `attrib`, ignore the absolute path\n      +\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n      +\treturn 1\n 2:  fc4202cb548 ! 2:  8650936b8d4 mingw: make test_path_is_hidden tests in t0001/t5611 more robust\n     @@ Metadata\n      Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n      \n       ## Commit message ##\n     -    mingw: make test_path_is_hidden tests in t0001/t5611 more robust\n     +    mingw: make test_path_is_hidden more robust\n      \n          This function uses Windows' system tool `attrib` to determine the state\n          of the hidden flag of a file or directory.\n     @@ Commit message\n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n       ## t/test-lib-functions.sh ##\n     -@@ t/test-lib-functions.sh: test_path_is_hidden () {\n     - \tBUG \"test_path_is_hidden can only be used on Windows\"\n     - \n     +@@ t/test-lib-functions.sh: test_bitmap_traversal () {\n     + # Tests for the hidden file attribute on windows\n     + is_hidden () {\n       \t# Use the output of `attrib`, ignore the absolute path\n      -\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n      +\tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n 3:  d0c0767a2aa < -:  ----------- t: fix casing of the operating system `Windows`\n -:  ----------- > 3:  b2604459917 t: restrict `is_hidden` to be called only on Windows\n\n-- \ngitgitgadget\n"},{"id":"395281","messageId":"b26044599172b72d920f2d2ea6854daefcd16bc1.1586612423.git.gitgitgadget@gmail.com","threadId":"53194","inReplyTo":"pull.603.v3.git.1586612422.gitgitgadget@gmail.com","subject":"[PATCH v3 3/3] t: restrict `is_hidden` to be called only on Windows","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-11T13:40:22Z","receivedAt":"2020-04-11T13:40:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe function won't work anywhere else, so let's mark it as an explicit\nbug if it is called on a non-Windows platform.\n\nLet's also rename the function to avoid cluttering the global namespace\nwith an overly-generic function name.\n\nWhile at it, we also fix the code comment above that function: the\nlower-case `windows` refers to something different than `Windows`.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t0001-init.sh         | 2 +-\n t/t5611-clone-config.sh | 6 +++---\n t/test-lib-functions.sh | 7 +++++--\n 3 files changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 9cc919d8d1a..1edd5aeb8f0 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -399,7 +399,7 @@ test_expect_success MINGW '.git hidden' '\n \t\tmkdir newdir &&\n \t\tcd newdir &&\n \t\tgit init &&\n-\t\tis_hidden .git\n+\t\ttest_path_is_hidden .git\n \t) &&\n \tcheck_config newdir/.git false unset\n '\ndiff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh\nindex c861e12ea44..8e0fd398236 100755\n--- a/t/t5611-clone-config.sh\n+++ b/t/t5611-clone-config.sh\n@@ -96,13 +96,13 @@ test_expect_success MINGW 'clone -c core.hideDotFiles' '\n \ttest_commit attributes .gitattributes \"\" &&\n \trm -rf child &&\n \tgit clone -c core.hideDotFiles=false . child &&\n-\t! is_hidden child/.gitattributes &&\n+\t! test_path_is_hidden child/.gitattributes &&\n \trm -rf child &&\n \tgit clone -c core.hideDotFiles=dotGitOnly . child &&\n-\t! is_hidden child/.gitattributes &&\n+\t! test_path_is_hidden child/.gitattributes &&\n \trm -rf child &&\n \tgit clone -c core.hideDotFiles=true . child &&\n-\tis_hidden child/.gitattributes\n+\ttest_path_is_hidden child/.gitattributes\n '\n \n test_done\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 2f81463a240..139647a6341 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1544,8 +1544,11 @@ test_bitmap_traversal () {\n \trm -f \"$1.normalized\" \"$2.normalized\"\n }\n \n-# Tests for the hidden file attribute on windows\n-is_hidden () {\n+# Tests for the hidden file attribute on Windows\n+test_path_is_hidden () {\n+\ttest_have_prereq MINGW ||\n+\tBUG \"test_path_is_hidden can only be used on Windows\"\n+\n \t# Use the output of `attrib`, ignore the absolute path\n \tcase \"$(\"$SYSTEMROOT\"/system32/attrib \"$1\")\" in *H*?:*) return 0;; esac\n \treturn 1\n-- \ngitgitgadget\n"},{"id":"395280","messageId":"f13f9f78cda9d883be7c59417b1da662e02045d6.1586612423.git.gitgitgadget@gmail.com","threadId":"53194","inReplyTo":"pull.603.v3.git.1586612422.gitgitgadget@gmail.com","subject":"[PATCH v3 1/3] t: consolidate the `is_hidden` functions","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-04-11T13:40:20Z","receivedAt":"2020-04-11T13:40:33Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe `is_hidden` function can be used (only on Windows) to determine\nwhether a directory or file have their `hidden` flag set.\n\nThis function is duplicated between two test scripts. It is better to\nmove it into `test-lib-functions.sh` so that it is reused.\n\nThis patch is best viewed with `--color-moved`.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t0001-init.sh         | 7 -------\n t/t5611-clone-config.sh | 7 -------\n t/test-lib-functions.sh | 7 +++++++\n 3 files changed, 7 insertions(+), 14 deletions(-)\n\ndiff --git a/t/t0001-init.sh b/t/t0001-init.sh\nindex 26f82063267..9cc919d8d1a 100755\n--- a/t/t0001-init.sh\n+++ b/t/t0001-init.sh\n@@ -392,13 +392,6 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '\n \ttest_path_is_dir realgitdir/refs\n '\n \n-# Tests for the hidden file attribute on windows\n-is_hidden () {\n-\t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n-\treturn 1\n-}\n-\n test_expect_success MINGW '.git hidden' '\n \trm -rf newdir &&\n \t(\ndiff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh\nindex 60c1ba951b7..c861e12ea44 100755\n--- a/t/t5611-clone-config.sh\n+++ b/t/t5611-clone-config.sh\n@@ -92,13 +92,6 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '\n \ttest_cmp expect actual\n '\n \n-# Tests for the hidden file attribute on windows\n-is_hidden () {\n-\t# Use the output of `attrib`, ignore the absolute path\n-\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n-\treturn 1\n-}\n-\n test_expect_success MINGW 'clone -c core.hideDotFiles' '\n \ttest_commit attributes .gitattributes \"\" &&\n \trm -rf child &&\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 352c213d52e..7a7e7a38312 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -1543,3 +1543,10 @@ test_bitmap_traversal () {\n \ttest_cmp \"$1.normalized\" \"$2.normalized\" &&\n \trm -f \"$1.normalized\" \"$2.normalized\"\n }\n+\n+# Tests for the hidden file attribute on windows\n+is_hidden () {\n+\t# Use the output of `attrib`, ignore the absolute path\n+\tcase \"$(attrib \"$1\")\" in *H*?:*) return 0;; esac\n+\treturn 1\n+}\n-- \ngitgitgadget\n\n"},{"id":"395284","messageId":"xmqqmu7hhfvq.fsf@gitster.c.googlers.com","threadId":"53194","inReplyTo":"pull.603.v3.git.1586612422.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 0/3] Make the tests that test core.hideDotFiles more robust","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-04-11T21:27:53Z","receivedAt":"2020-04-11T21:28:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> We have this feature on Windows where the files starting with a dot can be\n> marked hidden (whether a file is hidden by default or not is a matter of\n> naming convention on Unix, but it is an explicit flag on Windows). This\n> patch improves the regression tests of this feature, and it has been carried\n> in Git for Windows for over three years.\n>\n> Junio, I followed your advice, and did one more thing: the function is now\n> renamed also only in 3/3.\n\nLooks good.  \n\nI would have renamed it when making it global, exactly for the\nreason you stated in [3/3], but it's not like we would merge only\nthe first two without the fixup, so it does not matter in practice\n(as long as other people won't pick up a bad habit from the example,\nthat is).\n\nThanks.  Let's start merging a lot of things down to 'next'.\n"}]}