Skip to content

Commit

Permalink
scalar reconfigure: help users remove buggy repos
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
derrickstolee authored and dscho committed Jun 17, 2022
1 parent ffb9b7d commit 9a1bbca
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1350,26 +1350,48 @@ 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);
strbuf_reset(&gitdir);

if (chdir(dir) < 0) {
warning_errno(_("could not switch to '%s'"), dir);
res = -1;
} else if (discover_git_directory(&commondir, &gitdir) < 0) {
warning_errno(_("git repository gone in '%s'"), dir);
res = -1;
} else {
git_config_clear();
failed = -1;
goto loop_end;
}

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;

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;

the_repository = &r;
r.commondir = commondir.buf;
r.gitdir = gitdir.buf;
if (set_recommended_config(1) < 0)
failed = -1;

if (set_recommended_config(1) < 0)
res = -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);
}
}

Expand Down

0 comments on commit 9a1bbca

Please sign in to comment.