Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 407f2e9

Browse files
committed
test: Fix stat() test to mask out unwanted bits
Haiku and Hurd both pass extra bits in struct stat::st_mode.
1 parent c756448 commit 407f2e9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/checkout/index.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,12 @@ void test_checkout_index__options_dir_modes(void)
294294
(void)p_umask(um = p_umask(022));
295295

296296
cl_git_pass(p_stat("./testrepo/a", &st));
297-
cl_assert_equal_i_fmt(st.st_mode, (GIT_FILEMODE_TREE | 0701) & ~um, "%07o");
297+
/* Haiku & Hurd use other mode bits, so we must mask them out */
298+
cl_assert_equal_i_fmt(st.st_mode & (S_IFMT | 07777), (GIT_FILEMODE_TREE | 0701) & ~um, "%07o");
298299

299300
/* File-mode test, since we're on the 'dir' branch */
300301
cl_git_pass(p_stat("./testrepo/a/b.txt", &st));
301-
cl_assert_equal_i_fmt(st.st_mode, GIT_FILEMODE_BLOB_EXECUTABLE & ~um, "%07o");
302+
cl_assert_equal_i_fmt(st.st_mode & (S_IFMT | 07777), GIT_FILEMODE_BLOB_EXECUTABLE & ~um, "%07o");
302303

303304
git_commit_free(commit);
304305
}

0 commit comments

Comments
 (0)