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
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2023-10-10 00:58:54 +0300
committerJunio C Hamano <gitster@pobox.com>2023-10-10 01:53:13 +0300
commit6dc10043338bbb29ffd7f8fc431f37b0fed08ae6 (patch)
tree93c140d03d14f0d066b19a5c996892b14a9dafa8 /diagnose.c
parent5305474ec4650755f2c0437c004cabfb1c60cf6a (diff)
dir.[ch]: expose 'get_dtype'
Move 'get_dtype()' from 'diagnose.c' to 'dir.c' and add its declaration to 'dir.h' so that it is accessible to callers in other files. The function and its documentation are moved verbatim except for a small addition to the description clarifying what the 'path' arg represents. 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.c36
1 files changed, 0 insertions, 36 deletions
diff --git a/diagnose.c b/diagnose.c
index 8430064000..fc4d344bd6 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -71,42 +71,6 @@ static int dir_file_stats(struct object_directory *object_dir, void *data)
return 0;
}
-/*
- * Get the d_type of a dirent. If the d_type is unknown, derive it from
- * stat.st_mode.
- *
- * 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.
- */
-static unsigned char get_dtype(struct dirent *e, struct strbuf *path)
-{
- struct stat st;
- unsigned char dtype = DTYPE(e);
- size_t base_path_len;
-
- if (dtype != DT_UNKNOWN)
- return dtype;
-
- /* d_type unknown in dirent, try to fall back on lstat results */
- base_path_len = path->len;
- strbuf_addstr(path, e->d_name);
- if (lstat(path->buf, &st))
- goto cleanup;
-
- /* determine d_type from st_mode */
- if (S_ISREG(st.st_mode))
- dtype = DT_REG;
- else if (S_ISDIR(st.st_mode))
- dtype = DT_DIR;
- else if (S_ISLNK(st.st_mode))
- dtype = DT_LNK;
-
-cleanup:
- strbuf_setlen(path, base_path_len);
- return dtype;
-}
-
static int count_files(struct strbuf *path)
{
DIR *dir = opendir(path->buf);