git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, johannes.schindelin@gmx.de,
	Derrick Stolee <derrickstolee@github.com>,
	Derrick Stolee <derrickstolee@github.com>
Subject: [PATCH 3/3] scalar reconfigure: help users remove buggy repos
Date: Mon, 14 Aug 2023 15:12:17 +0000	[thread overview]
Message-ID: <907410f76c4a5d7ef325545f52696a9a0c00b6b3.1692025937.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1569.git.1692025937.gitgitgadget@gmail.com>

From: Derrick Stolee <derrickstolee@github.com>

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 <derrickstolee@github.com>
---
 scalar.c | 56 +++++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 39 insertions(+), 17 deletions(-)

diff --git a/scalar.c b/scalar.c
index 938bb73f3ce..7d87d7ea724 100644
--- a/scalar.c
+++ b/scalar.c
@@ -664,6 +664,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);
@@ -674,30 +675,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();
-
-			the_repository = &r;
-			r.commondir = commondir.buf;
-			r.gitdir = gitdir.buf;
-
-			if (set_recommended_config(1) < 0)
-				res = -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;
+
+		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);
 		}
 	}
 
-- 
gitgitgadget

  parent reply	other threads:[~2023-08-14 15:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14 15:12 [PATCH 0/3] scalar: two downstream improvements Derrick Stolee via GitGitGadget
2023-08-14 15:12 ` [PATCH 1/3] scalar: add --[no-]src option Derrick Stolee via GitGitGadget
2023-08-14 16:02   ` Junio C Hamano
2023-08-14 19:20     ` Derrick Stolee
2023-08-14 15:12 ` [PATCH 2/3] setup: add discover_git_directory_reason() Derrick Stolee via GitGitGadget
2023-08-14 16:29   ` Junio C Hamano
2023-08-14 16:55     ` Junio C Hamano
2023-08-14 15:12 ` Derrick Stolee via GitGitGadget [this message]
2023-08-14 16:44   ` [PATCH 3/3] scalar reconfigure: help users remove buggy repos Junio C Hamano
2023-08-22 17:24 ` [PATCH v2 0/3] scalar: two downstream improvements Derrick Stolee via GitGitGadget
2023-08-22 17:24   ` [PATCH v2 1/3] scalar: add --[no-]src option Derrick Stolee via GitGitGadget
2023-08-23  9:25     ` Oswald Buddenhagen
2023-08-22 17:24   ` [PATCH v2 2/3] setup: add discover_git_directory_reason() Derrick Stolee via GitGitGadget
2023-08-22 19:30     ` Junio C Hamano
2023-08-22 19:39       ` Derrick Stolee
2023-08-23  9:58     ` Oswald Buddenhagen
2023-08-22 17:24   ` [PATCH v2 3/3] scalar reconfigure: help users remove buggy repos Derrick Stolee via GitGitGadget
2023-08-22 19:45     ` Junio C Hamano
2023-08-25 17:21       ` Derrick Stolee
2023-08-25 18:05         ` Junio C Hamano
2023-08-28 13:52   ` [PATCH v3 0/3] scalar: two downstream improvements Derrick Stolee via GitGitGadget
2023-08-28 13:52     ` [PATCH v3 1/3] scalar: add --[no-]src option Derrick Stolee via GitGitGadget
2023-08-28 13:52     ` [PATCH v3 2/3] setup: add discover_git_directory_reason() Derrick Stolee via GitGitGadget
2023-08-28 13:52     ` [PATCH v3 3/3] scalar reconfigure: help users remove buggy repos Derrick Stolee via GitGitGadget
2023-08-28 16:22     ` [PATCH v3 0/3] scalar: two downstream improvements Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=907410f76c4a5d7ef325545f52696a9a0c00b6b3.1692025937.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).