git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 3/3] scalar reconfigure: help users remove buggy repos

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 22, 2023, 17:24 UTC
Message-ID
<7ac7311863d2e05c3dc8e26cb821fe8a7c4b6804.1692725056.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1569.v2.git.1692725056.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 | 51 ++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 13 deletions(-)
diff --git a/scalar.c b/scalar.c
index 02a38e845e1..54df0fdbb9f 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 succeeded = 0;
 		const char *dir = scalar_repos.items[i].string;
 
 		strbuf_reset(&commondir);
@@ -674,27 +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;
+				goto loop_end;
 			}
 
 			strbuf_addstr(&buf, dir);
 			if (remove_deleted_enlistment(&buf))
-				res = error(_("could not remove stale "
-					      "scalar.repo '%s'"), dir);
-			else
-				warning(_("removing stale scalar.repo '%s'"),
+				error(_("could not remove stale "
+					"scalar.repo '%s'"), dir);
+			else {
+				warning(_("removed stale scalar.repo '%s'"),
 					dir);
+				succeeded = 1;
+			}
 			strbuf_release(&buf);
-		} else {
-			git_config_clear();
+			goto loop_end;
+		}
+
+		switch (discover_git_directory_reason(&commondir, &gitdir)) {
+		case GIT_DIR_INVALID_OWNERSHIP:
+			warning(_("repository at '%s' has different owner"), dir);
+			goto loop_end;
+
+		case GIT_DIR_DISCOVERED:
+			succeeded = 1;
+			break;
+
+		default:
+			warning(_("repository not found in '%s'"), dir);
+			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)
+			succeeded = 1;
 
-			if (set_recommended_config(1) < 0)
-				res = -1;
+loop_end:
+		if (!succeeded) {
+			res = -1;
+			warning(_("to unregister this repository from Scalar, run\n"
+				  "\tgit config --global --unset --fixed-value scalar.repo \"%s\""),
+				dir);
 		}
 	}
 
-- 
gitgitgadget
Previous: Oswald BuddenhagenNext: Junio C Hamano
Message 13 of 25 in “scalar: two downstream improvements”
  1. 0/3 scalar: two downstream improvementsDerrick Stolee via GitGitGadget, Aug 14, 2023
  2. 1/3 scalar: add --[no-]src optionDerrick Stolee via GitGitGadget, Aug 14, 2023
  3. Junio C HamanoAug 14, 2023
  4. Derrick StoleeAug 14, 2023
  5. 3/3 scalar reconfigure: help users remove buggy reposDerrick Stolee via GitGitGadget, Aug 14, 2023
  6. Junio C HamanoAug 14, 2023
  7. 2/3 setup: add discover_git_directory_reason()Derrick Stolee via GitGitGadget, Aug 14, 2023
  8. Junio C HamanoAug 14, 2023
  9. Junio C HamanoAug 14, 2023
  10. 0/3 scalar: two downstream improvementsDerrick Stolee via GitGitGadget, Aug 22, 2023
  11. 1/3 scalar: add --[no-]src optionDerrick Stolee via GitGitGadget, Aug 22, 2023
  12. Oswald BuddenhagenAug 23, 2023
  13. 3/3 scalar reconfigure: help users remove buggy reposDerrick Stolee via GitGitGadget, Aug 22, 2023
  14. Junio C HamanoAug 22, 2023
  15. Derrick StoleeAug 25, 2023
  16. Junio C HamanoAug 25, 2023
  17. 2/3 setup: add discover_git_directory_reason()Derrick Stolee via GitGitGadget, Aug 22, 2023
  18. Junio C HamanoAug 22, 2023
  19. Derrick StoleeAug 22, 2023
  20. Oswald BuddenhagenAug 23, 2023
  21. 0/3 scalar: two downstream improvementsDerrick Stolee via GitGitGadget, Aug 28, 2023
  22. 1/3 scalar: add --[no-]src optionDerrick Stolee via GitGitGadget, Aug 28, 2023
  23. 3/3 scalar reconfigure: help users remove buggy reposDerrick Stolee via GitGitGadget, Aug 28, 2023
  24. 2/3 setup: add discover_git_directory_reason()Derrick Stolee via GitGitGadget, Aug 28, 2023
  25. Junio C HamanoAug 28, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.