@matheusbsbs / matheus-bagliano / commits / 7c2dfca7e8
Fork 0

t: consolidate the `is_hidden` functions

The `is_hidden` function can be used (only on Windows) to determine whether a directory or file have their `hidden` flag set. This function is duplicated between two test scripts. It is better to move it into `test-lib-functions.sh` so that it is reused. This patch is best viewed with `--color-moved`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Apr 11, 2020 at 13:40 UTC 7c2dfca7e81538b3d979b85b5bd023358d4d79eb
3 files changed +7 -14
t/t0001-init.sh
-7
@@ -392,13 +392,6 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
392 test_path_is_dir realgitdir/refs
393 '
394
395 -# Tests for the hidden file attribute on windows
396 -is_hidden () {
397 - # Use the output of `attrib`, ignore the absolute path
398 - case "$(attrib "$1")" in *H*?:*) return 0;; esac
399 - return 1
400 -}
401 -
395 test_expect_success MINGW '.git hidden' '
396 rm -rf newdir &&
397 (
t/t5611-clone-config.sh
-7
@@ -92,13 +92,6 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '
92 test_cmp expect actual
93 '
94
95 -# Tests for the hidden file attribute on windows
96 -is_hidden () {
97 - # Use the output of `attrib`, ignore the absolute path
98 - case "$(attrib "$1")" in *H*?:*) return 0;; esac
99 - return 1
100 -}
101 -
95 test_expect_success MINGW 'clone -c core.hideDotFiles' '
96 test_commit attributes .gitattributes "" &&
97 rm -rf child &&
t/test-lib-functions.sh
+7
@@ -1543,3 +1543,10 @@ test_bitmap_traversal () {
1543 test_cmp "$1.normalized" "$2.normalized" &&
1544 rm -f "$1.normalized" "$2.normalized"
1545 }
1546 +
1547 +# Tests for the hidden file attribute on windows
1548 +is_hidden () {
1549 + # Use the output of `attrib`, ignore the absolute path
1550 + case "$(attrib "$1")" in *H*?:*) return 0;; esac
1551 + return 1
1552 +}