* 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. */
| 233 | * also emit a warning for this error. |
| 234 | */ |
| 235 | static 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 | |
| 256 | int has_dirs_only_path(const char *name, int len, int prefix_len) |
| 257 | { |
no test coverage detected