diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2017-01-06 16:22:25 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-08 03:30:08 (GMT) |
commit | 204a047f23462e4931eb00c367818d9870237827 (patch) | |
tree | 73b6d90e28f537ffe36ca8f8b3627aba14da6329 /sha1_file.c | |
parent | 029443070a4e5b0290a2d09f3707bc486d84a961 (diff) | |
download | git-204a047f23462e4931eb00c367818d9870237827.zip git-204a047f23462e4931eb00c367818d9870237827.tar.gz git-204a047f23462e4931eb00c367818d9870237827.tar.bz2 |
safe_create_leading_directories(): set errno on SCLD_EXISTS
The exit path for SCLD_EXISTS wasn't setting errno, which some callers
use to generate error messages for the user. Fix the problem and
document that the function sets errno correctly to help avoid similar
regressions in the future.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c index 10395e7..ae8f0b4 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -137,8 +137,10 @@ enum scld_error safe_create_leading_directories(char *path) *slash = '\0'; if (!stat(path, &st)) { /* path exists */ - if (!S_ISDIR(st.st_mode)) + if (!S_ISDIR(st.st_mode)) { + errno = ENOTDIR; ret = SCLD_EXISTS; + } } else if (mkdir(path, 0777)) { if (errno == EEXIST && !stat(path, &st) && S_ISDIR(st.st_mode)) |