Skip to content

Commit 043cae6

Browse files
committed
SQUASH??? read_gitfile(): group ENOENT and ENOTDIR into a single MISSING error
The code from the previous step does not deal wellwith a case where we check if "sm/.git" is a good directory after replacing "sm" with a regular file. ENOTDIR is returned when we ask about "sm/.git", not ENOENT, and the code would want to handle both. I am not convinced if this is a good change, though. Outside the submodule caller, the story might be different and we may want to treat ENOTDIR differently from ENOENT. I dunno. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 82fc828 commit 043cae6

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

setup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ int verify_repository_format(const struct repository_format *format,
895895
void read_gitfile_error_die(int error_code, const char *path, const char *dir)
896896
{
897897
switch (error_code) {
898-
case READ_GITFILE_ERR_STAT_ENOENT:
898+
case READ_GITFILE_ERR_STAT_MISSING:
899899
case READ_GITFILE_ERR_IS_A_DIR:
900900
/* non-fatal; follow return path */
901901
break;
@@ -943,8 +943,8 @@ const char *read_gitfile_gently(const char *path, int *return_error_code)
943943
static struct strbuf realpath = STRBUF_INIT;
944944

945945
if (stat(path, &st)) {
946-
if (errno == ENOENT)
947-
error_code = READ_GITFILE_ERR_STAT_ENOENT;
946+
if (errno == ENOENT || errno == ENOTDIR)
947+
error_code = READ_GITFILE_ERR_STAT_MISSING;
948948
else
949949
error_code = READ_GITFILE_ERR_STAT_FAILED;
950950
goto cleanup_return;
@@ -1589,7 +1589,7 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
15891589
gitdirenv = read_gitfile_gently(dir->buf, &error_code);
15901590
if (!gitdirenv) {
15911591
switch (error_code) {
1592-
case READ_GITFILE_ERR_STAT_ENOENT:
1592+
case READ_GITFILE_ERR_STAT_MISSING:
15931593
/* no .git in this directory, move on */
15941594
break;
15951595
case READ_GITFILE_ERR_IS_A_DIR:

setup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int is_nonbare_repository_dir(struct strbuf *path);
3636
#define READ_GITFILE_ERR_NO_PATH 6
3737
#define READ_GITFILE_ERR_NOT_A_REPO 7
3838
#define READ_GITFILE_ERR_TOO_LARGE 8
39-
#define READ_GITFILE_ERR_STAT_ENOENT 9
39+
#define READ_GITFILE_ERR_STAT_MISSING 9
4040
#define READ_GITFILE_ERR_IS_A_DIR 10
4141
void read_gitfile_error_die(int error_code, const char *path, const char *dir);
4242
const char *read_gitfile_gently(const char *path, int *return_error_code);

submodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,7 @@ void absorb_git_dir_into_superproject(const char *path,
24132413
const struct submodule *sub;
24142414
struct strbuf sub_gitdir = STRBUF_INIT;
24152415

2416-
if (err_code == READ_GITFILE_ERR_STAT_ENOENT) {
2416+
if (err_code == READ_GITFILE_ERR_STAT_MISSING) {
24172417
/* unpopulated as expected */
24182418
strbuf_release(&gitdir);
24192419
return;

0 commit comments

Comments
 (0)