Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/dir.h
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2023-10-10 00:58:55 +0300
committerJunio C Hamano <gitster@pobox.com>2023-10-10 01:53:13 +0300
commitaa79636fe70247a19648d73e52a7774536100567 (patch)
tree8c98aea4e38c513512d92fea9e38fbf1f926ed3b /dir.h
parent6dc10043338bbb29ffd7f8fc431f37b0fed08ae6 (diff)
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 'dir.h')
-rw-r--r--dir.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/dir.h b/dir.h
index 28c630ce80..98aa85fcc0 100644
--- a/dir.h
+++ b/dir.h
@@ -368,11 +368,16 @@ struct dirent *readdir_skip_dot_and_dotdot(DIR *dirp);
* stat.st_mode using the path to the dirent's containing directory (path) and
* the name of the dirent itself.
*
+ * If 'follow_symlink' is 1, this function will attempt to follow DT_LNK types
+ * using 'stat'. Links are *not* followed recursively, so a symlink pointing
+ * to another symlink will still resolve to 'DT_LNK'.
+ *
* Note that 'path' is assumed to have a trailing slash. It is also modified
* in-place during the execution of the function, but is then reverted to its
* original value before returning.
*/
-unsigned char get_dtype(struct dirent *e, struct strbuf *path);
+unsigned char get_dtype(struct dirent *e, struct strbuf *path,
+ int follow_symlink);
/*Count the number of slashes for string s*/
int count_slashes(const char *s);