Skip to content

Commit f9a547d

Browse files
derrickstoleegitster
authored andcommitted
scalar reconfigure: help users remove buggy repos
When running 'scalar reconfigure -a', 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 26ae8da commit f9a547d

File tree

1 file changed

+43
-16
lines changed

1 file changed

+43
-16
lines changed

scalar.c

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ static int cmd_reconfigure(int argc, const char **argv)
662662
git_config(get_scalar_repos, &scalar_repos);
663663

664664
for (i = 0; i < scalar_repos.nr; i++) {
665+
int succeeded = 0;
665666
const char *dir = scalar_repos.items[i].string;
666667

667668
strbuf_reset(&commondir);
@@ -672,30 +673,56 @@ static int cmd_reconfigure(int argc, const char **argv)
672673

673674
if (errno != ENOENT) {
674675
warning_errno(_("could not switch to '%s'"), dir);
675-
res = -1;
676-
continue;
676+
goto loop_end;
677677
}
678678

679679
strbuf_addstr(&buf, dir);
680680
if (remove_deleted_enlistment(&buf))
681-
res = error(_("could not remove stale "
682-
"scalar.repo '%s'"), dir);
683-
else
684-
warning(_("removing stale scalar.repo '%s'"),
681+
error(_("could not remove stale "
682+
"scalar.repo '%s'"), dir);
683+
else {
684+
warning(_("removed stale scalar.repo '%s'"),
685685
dir);
686+
succeeded = 1;
687+
}
686688
strbuf_release(&buf);
687-
} else if (discover_git_directory(&commondir, &gitdir) < 0) {
688-
warning_errno(_("git repository gone in '%s'"), dir);
689-
res = -1;
690-
} else {
691-
git_config_clear();
689+
goto loop_end;
690+
}
691+
692+
switch (discover_git_directory_reason(&commondir, &gitdir)) {
693+
case GIT_DIR_INVALID_OWNERSHIP:
694+
warning(_("repository at '%s' has different owner"), dir);
695+
goto loop_end;
696+
697+
case GIT_DIR_INVALID_GITFILE:
698+
case GIT_DIR_INVALID_FORMAT:
699+
warning(_("repository at '%s' has a format issue"), dir);
700+
goto loop_end;
701+
702+
case GIT_DIR_DISCOVERED:
703+
succeeded = 1;
704+
break;
705+
706+
default:
707+
warning(_("repository not found in '%s'"), dir);
708+
break;
709+
}
692710

693-
the_repository = &r;
694-
r.commondir = commondir.buf;
695-
r.gitdir = gitdir.buf;
711+
git_config_clear();
696712

697-
if (set_recommended_config(1) < 0)
698-
res = -1;
713+
the_repository = &r;
714+
r.commondir = commondir.buf;
715+
r.gitdir = gitdir.buf;
716+
717+
if (set_recommended_config(1) >= 0)
718+
succeeded = 1;
719+
720+
loop_end:
721+
if (!succeeded) {
722+
res = -1;
723+
warning(_("to unregister this repository from Scalar, run\n"
724+
"\tgit config --global --unset --fixed-value scalar.repo \"%s\""),
725+
dir);
699726
}
700727
}
701728

0 commit comments

Comments
 (0)