aboutsummaryrefslogtreecommitdiffstats
path: root/diff-no-index.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-06-18 13:04:12 -0700
committerJunio C Hamano <gitster@pobox.com>2025-06-18 13:05:29 -0700
commitd094e05ea596145aa4362cf957f9d99663d4a2e3 (patch)
treedc8bd0e1897af60240e935f196f479536c49f1d1 /diff-no-index.c
parent09fb155f11128b505c227aae673de957c9388240 (diff)
downloadgit-d094e05ea596145aa4362cf957f9d99663d4a2e3.tar.gz
diff-no-index: do not reference .d_type member of struct dirent
Some platforms like AIX lack .d_type member in "struct dirent"; use the DTYPE(e) macro instead of a direct reference to e->d_type and when it yields DT_UNKNOWN, find the real type with get_dtype(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff-no-index.c')
-rw-r--r--diff-no-index.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/diff-no-index.c b/diff-no-index.c
index 4aeeb98cfa..88ae4cee56 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -41,12 +41,24 @@ static int read_directory_contents(const char *path, struct string_list *list,
while ((e = readdir_skip_dot_and_dotdot(dir))) {
if (pathspec) {
+ int is_dir = 0;
+
strbuf_setlen(&match, len);
strbuf_addstr(&match, e->d_name);
+ if (NOT_CONSTANT(DTYPE(e)) != DT_UNKNOWN) {
+ is_dir = (DTYPE(e) == DT_DIR);
+ } else {
+ struct strbuf pathbuf = STRBUF_INIT;
+
+ strbuf_addstr(&pathbuf, path);
+ strbuf_complete(&pathbuf, '/');
+ is_dir = get_dtype(e, &pathbuf, 0) == DT_DIR;
+ strbuf_release(&pathbuf);
+ }
if (!match_leading_pathspec(NULL, pathspec,
match.buf, match.len,
- 0, NULL, e->d_type == DT_DIR ? 1 : 0))
+ 0, NULL, is_dir))
continue;
}