Subject: [PATCH 1/2] mingw: refactor test_path_is_hidden out to t/test-lib-functions.sh

From: Junio C Hamano <[email-masked]>
Date: Thu, 9 Apr 2020 13:11:28 -0700

Two scripts had a copy of the same helper function, which needed the
same fix at the same time.  Let's move it to a common place.

Signed-off-by: Junio C Hamano <[email-masked]>
---
 t/t0001-init.sh         | 13 +++----------
 t/t5611-clone-config.sh | 13 +++----------
 t/test-lib-functions.sh |  9 +++++++++
 3 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 2456688b28..6b2e2e3dc2 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -392,13 +392,6 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
 	test_path_is_dir realgitdir/refs
 '
 
-# Tests for the hidden file attribute on windows
-is_hidden () {
-	# Use the output of `attrib`, ignore the absolute path
-	case "$("$SYSTEMROOT"/system32/attrib "$1")" in *H*?:*) return 0;; esac
-	return 1
-}
-
 test_expect_success MINGW '.git hidden' '
 	rm -rf newdir &&
 	(
@@ -406,7 +399,7 @@ test_expect_success MINGW '.git hidden' '
 		mkdir newdir &&
 		cd newdir &&
 		git init &&
-		is_hidden .git
+		test_path_is_hidden .git
 	) &&
 	check_config newdir/.git false unset
 '
@@ -419,7 +412,7 @@ test_expect_success MINGW 'bare git dir not hidden' '
 		cd newdir &&
 		git --bare init
 	) &&
-	! is_hidden newdir
+	! test_path_is_hidden newdir
 '
 
 test_expect_success 'remote init from does not use config from cwd' '
@@ -456,7 +449,7 @@ test_expect_success MINGW 'core.hidedotfiles = false' '
 		sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
 		git -C newdir init
 	) &&
-	! is_hidden newdir/.git
+	! test_path_is_hidden newdir/.git
 '
 
 test_expect_success MINGW 'redirect std handles' '
diff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh
index 87b8073cd7..8e0fd39823 100755
--- a/t/t5611-clone-config.sh
+++ b/t/t5611-clone-config.sh
@@ -92,24 +92,17 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '
 	test_cmp expect actual
 '
 
-# Tests for the hidden file attribute on windows
-is_hidden () {
-	# Use the output of `attrib`, ignore the absolute path
-	case "$("$SYSTEMROOT"/system32/attrib "$1")" in *H*?:*) return 0;; esac
-	return 1
-}
-
 test_expect_success MINGW 'clone -c core.hideDotFiles' '
 	test_commit attributes .gitattributes "" &&
 	rm -rf child &&
 	git clone -c core.hideDotFiles=false . child &&
-	! is_hidden child/.gitattributes &&
+	! test_path_is_hidden child/.gitattributes &&
 	rm -rf child &&
 	git clone -c core.hideDotFiles=dotGitOnly . child &&
-	! is_hidden child/.gitattributes &&
+	! test_path_is_hidden child/.gitattributes &&
 	rm -rf child &&
 	git clone -c core.hideDotFiles=true . child &&
-	is_hidden child/.gitattributes
+	test_path_is_hidden child/.gitattributes
 '
 
 test_done
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 352c213d52..39b478e731 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -760,6 +760,15 @@ test_path_is_missing () {
 	fi
 }
 
+# Tests for the hidden file attribute on windows
+test_path_is_hidden () {
+	# Use the output of `attrib`, ignore the absolute path
+	case "$("$SYSTEMROOT"/system32/attrib "$1")" in
+	*H*?:*)		return 0;;
+	esac
+	return 1
+}
+
 # test_line_count checks that a file has the number of lines it
 # ought to. For example:
 #
-- 
2.26.0-106-g9fadedd637