diff options
author | Victoria Dye <vdye@github.com> | 2023-10-09 23:58:55 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-10-10 00:53:13 +0200 |
commit | aa79636fe70247a19648d73e52a7774536100567 (patch) | |
tree | 8c98aea4e38c513512d92fea9e38fbf1f926ed3b /diagnose.c | |
parent | dir.[ch]: expose 'get_dtype' (diff) | |
download | git-aa79636fe70247a19648d73e52a7774536100567.tar.xz git-aa79636fe70247a19648d73e52a7774536100567.zip |
dir.[ch]: add 'follow_symlink' arg to 'get_dtype'
Add a 'follow_symlink' boolean option to 'get_type()'. If 'follow_symlink'
is enabled, DT_LNK (in addition to DT_UNKNOWN) d_types triggers the
stat-based d_type resolution, using 'stat' instead of 'lstat' to get the
type of the followed symlink. Note that symlinks are not followed
recursively, so a symlink pointing to another symlink will still resolve to
DT_LNK.
Update callers in 'diagnose.c' to specify 'follow_symlink = 0' to preserve
current behavior.
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diagnose.c')
-rw-r--r-- | diagnose.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/diagnose.c b/diagnose.c index fc4d344bd6..4d096c857f 100644 --- a/diagnose.c +++ b/diagnose.c @@ -81,7 +81,7 @@ static int count_files(struct strbuf *path) return 0; while ((e = readdir_skip_dot_and_dotdot(dir)) != NULL) - if (get_dtype(e, path) == DT_REG) + if (get_dtype(e, path, 0) == DT_REG) count++; closedir(dir); @@ -110,7 +110,7 @@ static void loose_objs_stats(struct strbuf *buf, const char *path) base_path_len = count_path.len; while ((e = readdir_skip_dot_and_dotdot(dir)) != NULL) - if (get_dtype(e, &count_path) == DT_DIR && + if (get_dtype(e, &count_path, 0) == DT_DIR && strlen(e->d_name) == 2 && !hex_to_bytes(&c, e->d_name, 1)) { strbuf_setlen(&count_path, base_path_len); @@ -155,7 +155,7 @@ static int add_directory_to_archiver(struct strvec *archiver_args, strbuf_add_absolute_path(&abspath, at_root ? "." : path); strbuf_addch(&abspath, '/'); - dtype = get_dtype(e, &abspath); + dtype = get_dtype(e, &abspath, 0); strbuf_setlen(&buf, len); strbuf_addstr(&buf, e->d_name); |