Re: [PATCH v8 06/11] submodule--helper: add gitdir migration command
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jan 8, 2026, 06:46 UTC
- Message-ID
- <aV9S3rV6wKZp9CP2@pks.im>
- In-Reply-To
- <20260107230145.517562-7-adrian.ratiu@collabora.com>
On Thu, Jan 08, 2026 at 01:01:40AM +0200, Adrian Ratiu wrote:
Show 62 quoted lines
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index b3d6f9ff68..271d549bac 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -1266,6 +1266,66 @@ static int module_gitdir(int argc, const char **argv, const char *prefix UNUSED,
> return 0;
> }
>
> +static int module_migrate(int argc UNUSED, const char **argv UNUSED,
> + const char *prefix UNUSED, struct repository *repo)
> +{
> + struct strbuf module_dir = STRBUF_INIT;
> + DIR *dir;
> + struct dirent *de;
> + int repo_version = 0;
> +
> + repo_git_path_append(repo, &module_dir, "modules/");
> +
> + dir = opendir(module_dir.buf);
> + if (!dir)
> + die(_("could not open '%s'"), module_dir.buf);
> +
> + while ((de = readdir(dir))) {
> + struct strbuf gitdir_path = STRBUF_INIT;
> + char *key;
> + const char *value;
> +
> + if (is_dot_or_dotdot(de->d_name))
> + continue;
> +
> + strbuf_addf(&gitdir_path, "%s/%s", module_dir.buf, de->d_name);
> + if (!is_git_directory(gitdir_path.buf)) {
> + strbuf_release(&gitdir_path);
> + continue;
> + }
> + strbuf_release(&gitdir_path);
> +
> + key = xstrfmt("submodule.%s.gitdir", de->d_name);
> + if (!repo_config_get_string_tmp(repo, key, &value)) {
> + /* Already has a gitdir config, nothing to do. */
> + free(key);
> + continue;
> + }
> + free(key);
> +
> + create_default_gitdir_config(de->d_name);
> + }
> +
> + closedir(dir);
> + strbuf_release(&module_dir);
> +
> + repo_config_get_int(the_repository, "core.repositoryformatversion", &repo_version);
> + if (repo_version == 0 &&
> + repo_config_set_gently(repo, "core.repositoryformatversion", "1"))
> + die(_("could not set core.repositoryformatversion to 1. "
> + "Please set it for migration to work, for example: "
> + "git config core.repositoryformatversion 1"));
> +
> + if (repo_config_set_gently(repo, "extensions.submodulePathConfig", "true"))
> + die(_("could not enable submodulePathConfig extension. It is required "
> + "for migration to work. Please enable it in the root repo: "
> + "git config extensions.submodulePathConfig true"));These error messages could probably use some newlines so that they're wrapped to a more readable length.
Patrick