Skip to content

Commit 8b39dfd

Browse files
committed
Merge branch 'js/mingw-is-hidden-test-fix'
A Windows-specific test element has been made more robust against misuse from both user's environment and programmer's errors. * js/mingw-is-hidden-test-fix: t: restrict `is_hidden` to be called only on Windows mingw: make test_path_is_hidden more robust t: consolidate the `is_hidden` functions
2 parents a41b41c + 176a66a commit 8b39dfd

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

t/t0001-init.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,21 +392,14 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
392392
test_path_is_dir realgitdir/refs
393393
'
394394

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-
402395
test_expect_success MINGW '.git hidden' '
403396
rm -rf newdir &&
404397
(
405398
sane_unset GIT_DIR GIT_WORK_TREE &&
406399
mkdir newdir &&
407400
cd newdir &&
408401
git init &&
409-
is_hidden .git
402+
test_path_is_hidden .git
410403
) &&
411404
check_config newdir/.git false unset
412405
'

t/t5611-clone-config.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,17 @@ test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '
9292
test_cmp expect actual
9393
'
9494

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-
10295
test_expect_success MINGW 'clone -c core.hideDotFiles' '
10396
test_commit attributes .gitattributes "" &&
10497
rm -rf child &&
10598
git clone -c core.hideDotFiles=false . child &&
106-
! is_hidden child/.gitattributes &&
99+
! test_path_is_hidden child/.gitattributes &&
107100
rm -rf child &&
108101
git clone -c core.hideDotFiles=dotGitOnly . child &&
109-
! is_hidden child/.gitattributes &&
102+
! test_path_is_hidden child/.gitattributes &&
110103
rm -rf child &&
111104
git clone -c core.hideDotFiles=true . child &&
112-
is_hidden child/.gitattributes
105+
test_path_is_hidden child/.gitattributes
113106
'
114107

115108
test_done

t/test-lib-functions.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,3 +1551,13 @@ test_bitmap_traversal () {
15511551
test_cmp "$1.normalized" "$2.normalized" &&
15521552
rm -f "$1.normalized" "$2.normalized"
15531553
}
1554+
1555+
# Tests for the hidden file attribute on Windows
1556+
test_path_is_hidden () {
1557+
test_have_prereq MINGW ||
1558+
BUG "test_path_is_hidden can only be used on Windows"
1559+
1560+
# Use the output of `attrib`, ignore the absolute path
1561+
case "$("$SYSTEMROOT"/system32/attrib "$1")" in *H*?:*) return 0;; esac
1562+
return 1
1563+
}

0 commit comments

Comments
 (0)