зеркало из https://github.com/microsoft/git.git
scalar reconfigure: help users remove buggy repos
When running 'scalar reconfigure -a', such as at install time, Scalar has warning messages about the repository missing (or not containing a .git directory). Failures can also happen while trying to modify the repository-local config for that repository. These warnings may seem confusing to users who don't understand what they mean or how to stop them. Add a warning that instructs the user how to remove the warning in future installations. Signed-off-by: Derrick Stolee <derrickstolee@github.com>
This commit is contained in:
Родитель
95e667d55f
Коммит
03ed96515f
52
scalar.c
52
scalar.c
|
@ -1032,6 +1032,7 @@ static int cmd_reconfigure(int argc, const char **argv)
|
|||
git_config(get_scalar_repos, &scalar_repos);
|
||||
|
||||
for (i = 0; i < scalar_repos.nr; i++) {
|
||||
int failed = 0;
|
||||
const char *dir = scalar_repos.items[i].string;
|
||||
|
||||
strbuf_reset(&commondir);
|
||||
|
@ -1042,30 +1043,51 @@ static int cmd_reconfigure(int argc, const char **argv)
|
|||
|
||||
if (errno != ENOENT) {
|
||||
warning_errno(_("could not switch to '%s'"), dir);
|
||||
res = -1;
|
||||
continue;
|
||||
failed = -1;
|
||||
goto loop_end;
|
||||
}
|
||||
|
||||
strbuf_addstr(&buf, dir);
|
||||
if (remove_deleted_enlistment(&buf))
|
||||
res = error(_("could not remove stale "
|
||||
"scalar.repo '%s'"), dir);
|
||||
failed = error(_("could not remove stale "
|
||||
"scalar.repo '%s'"), dir);
|
||||
else
|
||||
warning(_("removing stale scalar.repo '%s'"),
|
||||
warning(_("removed stale scalar.repo '%s'"),
|
||||
dir);
|
||||
strbuf_release(&buf);
|
||||
} else if (discover_git_directory(&commondir, &gitdir) < 0) {
|
||||
warning_errno(_("git repository gone in '%s'"), dir);
|
||||
res = -1;
|
||||
} else {
|
||||
git_config_clear();
|
||||
goto loop_end;
|
||||
}
|
||||
|
||||
the_repository = &r;
|
||||
r.commondir = commondir.buf;
|
||||
r.gitdir = gitdir.buf;
|
||||
switch (discover_git_directory_reason(&commondir, &gitdir)) {
|
||||
case GIT_DIR_INVALID_OWNERSHIP:
|
||||
warning(_("repository at '%s' has different owner"), dir);
|
||||
failed = -1;
|
||||
goto loop_end;
|
||||
|
||||
if (set_recommended_config(1) < 0)
|
||||
res = -1;
|
||||
case GIT_DIR_DISCOVERED:
|
||||
break;
|
||||
|
||||
default:
|
||||
warning(_("repository not found in '%s'"), dir);
|
||||
failed = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
git_config_clear();
|
||||
|
||||
the_repository = &r;
|
||||
r.commondir = commondir.buf;
|
||||
r.gitdir = gitdir.buf;
|
||||
|
||||
if (set_recommended_config(1) < 0)
|
||||
failed = -1;
|
||||
|
||||
loop_end:
|
||||
if (failed) {
|
||||
res = failed;
|
||||
warning(_("to unregister this repository from Scalar, run\n"
|
||||
"\tgit config --global --unset --fixed-value scalar.repo \"%s\""),
|
||||
dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче