commit - 9743083996cb3beca1525614b4cf4b8580fb9245
commit + ddcd8544ed03d513d539a972b05a2c0140b48b90
blob - e4c1921409c815ed610bff7618c0c7964b4c8d49
blob + 569469beed32d05c207dbf9cd3067ed433793128
--- lib/path.c
+++ lib/path.c
const struct got_error *err = NULL;
if (mkdir(abspath, GOT_DEFAULT_DIR_MODE) == -1) {
- struct stat sb;
-
- if (errno == EEXIST) {
- if (lstat(abspath, &sb) == -1) {
- err = got_error_from_errno();
- goto done;
- }
-
- if (!S_ISDIR(sb.st_mode)) {
- /* TODO directory is obstructed; do something */
- err = got_error(GOT_ERR_FILE_OBSTRUCTED);
- goto done;
- }
-
- return NULL;
- } else if (errno == ENOENT) {
+ if (errno == ENOENT) {
err = make_parent_dirs(abspath);
if (err)
goto done;
blob - 5aff68d747e08015367d0201cf56f3ebc9d840be
blob + 8ce73ba0ba53813a0ee2a1585db0e7432279b738
--- lib/worktree.c
+++ lib/worktree.c
return got_error_from_errno();
err = got_path_mkdir(abspath);
+ if (err && err->code == GOT_ERR_ERRNO && errno == EEXIST) {
+ struct stat sb;
+ err = NULL;
+ if (lstat(abspath, &sb) == -1) {
+ err = got_error_from_errno();
+ } else if (!S_ISDIR(sb.st_mode)) {
+ /* TODO directory is obstructed; do something */
+ err = got_error(GOT_ERR_FILE_OBSTRUCTED);
+ }
+ }
free(abspath);
return err;
}