diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-06-25 14:07:36 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-06-25 14:07:36 -0700 |
| commit | 567dc419b2990915e044c6eab841bb5353d83b4d (patch) | |
| tree | e8967ad32975d61fa2e31bb4eceff353f974a6c3 | |
| parent | Merge branch 'ps/maintenance-ref-lock' (diff) | |
| parent | diff-no-index: do not reference .d_type member of struct dirent (diff) | |
| download | git-567dc419b2990915e044c6eab841bb5353d83b4d.tar.gz git-567dc419b2990915e044c6eab841bb5353d83b4d.zip | |
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
| -rw-r--r-- | diff-no-index.c | 14 |
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; } |
