Skip to content

Commit 567dc41

Browse files
committed
Merge branch 'jc/diff-no-index-with-pathspec-fix'
Recent code added a direct access to the d_type member in "struct dirent", but some platforms lack it, which has been corrected. * jc/diff-no-index-with-pathspec-fix: diff-no-index: do not reference .d_type member of struct dirent
2 parents 4c9a5d7 + d094e05 commit 567dc41

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

diff-no-index.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,24 @@ static int read_directory_contents(const char *path, struct string_list *list,
4141

4242
while ((e = readdir_skip_dot_and_dotdot(dir))) {
4343
if (pathspec) {
44+
int is_dir = 0;
45+
4446
strbuf_setlen(&match, len);
4547
strbuf_addstr(&match, e->d_name);
48+
if (NOT_CONSTANT(DTYPE(e)) != DT_UNKNOWN) {
49+
is_dir = (DTYPE(e) == DT_DIR);
50+
} else {
51+
struct strbuf pathbuf = STRBUF_INIT;
52+
53+
strbuf_addstr(&pathbuf, path);
54+
strbuf_complete(&pathbuf, '/');
55+
is_dir = get_dtype(e, &pathbuf, 0) == DT_DIR;
56+
strbuf_release(&pathbuf);
57+
}
4658

4759
if (!match_leading_pathspec(NULL, pathspec,
4860
match.buf, match.len,
49-
0, NULL, e->d_type == DT_DIR ? 1 : 0))
61+
0, NULL, is_dir))
5062
continue;
5163
}
5264

0 commit comments

Comments
 (0)