Skip to content

Commit 5bb20ec

Browse files
committed
Merge branch 'jn/unpack-lstat-failure-report'
* jn/unpack-lstat-failure-report: unpack-trees: handle lstat failure for existing file unpack-trees: handle lstat failure for existing directory
2 parents f5bbbf9 + a93e530 commit 5bb20ec

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

unpack-trees.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,16 +1374,22 @@ static int verify_absent_1(struct cache_entry *ce,
13741374
char path[PATH_MAX + 1];
13751375
memcpy(path, ce->name, len);
13761376
path[len] = 0;
1377-
lstat(path, &st);
1377+
if (lstat(path, &st))
1378+
return error("cannot stat '%s': %s", path,
1379+
strerror(errno));
13781380

13791381
return check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st,
13801382
error_type, o);
1381-
} else if (!lstat(ce->name, &st))
1383+
} else if (lstat(ce->name, &st)) {
1384+
if (errno != ENOENT)
1385+
return error("cannot stat '%s': %s", ce->name,
1386+
strerror(errno));
1387+
return 0;
1388+
} else {
13821389
return check_ok_to_remove(ce->name, ce_namelen(ce),
1383-
ce_to_dtype(ce), ce, &st,
1384-
error_type, o);
1385-
1386-
return 0;
1390+
ce_to_dtype(ce), ce, &st,
1391+
error_type, o);
1392+
}
13871393
}
13881394

13891395
static int verify_absent(struct cache_entry *ce,

0 commit comments

Comments
 (0)