Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-11-02 10:53:14 +0300
committerJunio C Hamano <gitster@pobox.com>2023-11-02 10:53:15 +0300
commit50758312f2d29a32858ccd25b24ea64ae8a04cb1 (patch)
treed18aec2323a92bf729007f5914c8f7b84c2c64ba /setup.c
parent396a167bd4e68f496981345c3d89459abb910b7e (diff)
parentf9a547d3a7a70db491f191dbc4f16c17e3308f78 (diff)
Merge branch 'ds/scalar-updates' into maint-2.42
Scalar updates. * ds/scalar-updates: scalar reconfigure: help users remove buggy repos setup: add discover_git_directory_reason() scalar: add --[no-]src option
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/setup.c b/setup.c
index 18927a847b..2e607632db 100644
--- a/setup.c
+++ b/setup.c
@@ -1221,19 +1221,6 @@ static const char *allowed_bare_repo_to_string(
return NULL;
}
-enum discovery_result {
- GIT_DIR_NONE = 0,
- GIT_DIR_EXPLICIT,
- GIT_DIR_DISCOVERED,
- GIT_DIR_BARE,
- /* these are errors */
- GIT_DIR_HIT_CEILING = -1,
- GIT_DIR_HIT_MOUNT_POINT = -2,
- GIT_DIR_INVALID_GITFILE = -3,
- GIT_DIR_INVALID_OWNERSHIP = -4,
- GIT_DIR_DISALLOWED_BARE = -5,
-};
-
/*
* We cannot decide in this function whether we are in the work tree or
* not, since the config can only be read _after_ this function was called.
@@ -1385,21 +1372,23 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
}
}
-int discover_git_directory(struct strbuf *commondir,
- struct strbuf *gitdir)
+enum discovery_result discover_git_directory_reason(struct strbuf *commondir,
+ struct strbuf *gitdir)
{
struct strbuf dir = STRBUF_INIT, err = STRBUF_INIT;
size_t gitdir_offset = gitdir->len, cwd_len;
size_t commondir_offset = commondir->len;
struct repository_format candidate = REPOSITORY_FORMAT_INIT;
+ enum discovery_result result;
if (strbuf_getcwd(&dir))
- return -1;
+ return GIT_DIR_CWD_FAILURE;
cwd_len = dir.len;
- if (setup_git_directory_gently_1(&dir, gitdir, NULL, 0) <= 0) {
+ result = setup_git_directory_gently_1(&dir, gitdir, NULL, 0);
+ if (result <= 0) {
strbuf_release(&dir);
- return -1;
+ return result;
}
/*
@@ -1429,11 +1418,11 @@ int discover_git_directory(struct strbuf *commondir,
strbuf_setlen(commondir, commondir_offset);
strbuf_setlen(gitdir, gitdir_offset);
clear_repository_format(&candidate);
- return -1;
+ return GIT_DIR_INVALID_FORMAT;
}
clear_repository_format(&candidate);
- return 0;
+ return result;
}
const char *setup_git_directory_gently(int *nongit_ok)
@@ -1515,10 +1504,11 @@ const char *setup_git_directory_gently(int *nongit_ok)
}
*nongit_ok = 1;
break;
- case GIT_DIR_NONE:
+ case GIT_DIR_CWD_FAILURE:
+ case GIT_DIR_INVALID_FORMAT:
/*
* As a safeguard against setup_git_directory_gently_1 returning
- * this value, fallthrough to BUG. Otherwise it is possible to
+ * these values, fallthrough to BUG. Otherwise it is possible to
* set startup_info->have_repository to 1 when we did nothing to
* find a repository.
*/