Skip to content

Commit ea8bbf2

Browse files
matheustavaresgitster
authored andcommitted
t4129: don't fail if setgid is set in the test directory
The last test of t4129 creates a directory and expects its setgid bit (g+s) to be off. But this makes the test fail when the parent directory has the bit set, as setgid's state is inherited by newly created subdirectories. One way to solve this problem is to allow the presence of this bit when comparing the return of `test_modebits` with the expected value. But then we may have the same problem in the future when other tests start using `test_modebits` on directories (currently t4129 is the only one) and forget about setgid. Instead, let's make the helper function more robust with respect to the state of the setgid bit in the test directory by removing this bit from the returning value. There should be no problem with existing callers as no one currently expects this bit to be on. Note that the sticky bit (+t) and the setuid bit (u+s) are not inherited, so we don't have to worry about those. Reported-by: Kevin Daudt <[email protected]> Signed-off-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71ca53e commit ea8bbf2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

t/test-lib-functions.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,14 @@ test_chmod () {
367367
git update-index --add "--chmod=$@"
368368
}
369369

370-
# Get the modebits from a file or directory.
370+
# Get the modebits from a file or directory, ignoring the setgid bit (g+s).
371+
# This bit is inherited by subdirectories at their creation. So we remove it
372+
# from the returning string to prevent callers from having to worry about the
373+
# state of the bit in the test directory.
374+
#
371375
test_modebits () {
372-
ls -ld "$1" | sed -e 's|^\(..........\).*|\1|'
376+
ls -ld "$1" | sed -e 's|^\(..........\).*|\1|' \
377+
-e 's|^\(......\)S|\1-|' -e 's|^\(......\)s|\1x|'
373378
}
374379

375380
# Unset a configuration variable, but don't fail if it doesn't exist.

0 commit comments

Comments
 (0)