Skip to content

Commit 7c2dfca

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9fadedd commit 7c2dfca

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

t/t0001-init.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,6 @@ 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
(

t/t5611-clone-config.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ 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 &&

t/test-lib-functions.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,3 +1543,10 @@ test_bitmap_traversal () {
15431543
test_cmp "$1.normalized" "$2.normalized" &&
15441544
rm -f "$1.normalized" "$2.normalized"
15451545
}
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+
}

0 commit comments

Comments
 (0)