MCPcopy Create free account
hub / github.com/git/git / threaded_check_leading_path

Function threaded_check_leading_path

symlinks.c:235–254  ·  view source on GitHub ↗

* Return zero if some leading path component of 'name' does not exist. * * Return -1 if leading path exists and is a directory. * * Return the length of a leading component if it either exists but it's not a * directory, or if we were unable to lstat() it. If warn_on_lstat_err is true, * also emit a warning for this error. */

Source from the content-addressed store, hash-verified

233 * also emit a warning for this error.
234 */
235static int threaded_check_leading_path(struct cache_def *cache, const char *name,
236 int len, int warn_on_lstat_err)
237{
238 unsigned int flags;
239 int match_len = lstat_cache_matchlen(cache, name, len, &flags,
240 FL_SYMLINK|FL_NOENT|FL_DIR, USE_ONLY_LSTAT);
241 int saved_errno = errno;
242
243 if (flags & FL_NOENT)
244 return 0;
245 else if (flags & FL_DIR)
246 return -1;
247 if (warn_on_lstat_err && (flags & FL_LSTATERR)) {
248 char *path = xmemdupz(name, match_len);
249 errno = saved_errno;
250 warning_errno(_("failed to lstat '%s'"), path);
251 free(path);
252 }
253 return match_len;
254}
255
256int has_dirs_only_path(const char *name, int len, int prefix_len)
257{

Callers 1

check_leading_pathFunction · 0.85

Calls 3

lstat_cache_matchlenFunction · 0.85
xmemdupzFunction · 0.85
warning_errnoFunction · 0.85

Tested by

no test coverage detected