Skip to content

Commit

Permalink
Merge branch 'scalar-reconfigure-repo-handle' into scalar-reconfigure…
Browse files Browse the repository at this point in the history
…-vfs-2.45.0

TODO: Replace the right-hand side of this merge with the upstream
version of this change. Note that this was an easy merge with the
left-hand side's fixup! commit squashing two if blocks together.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
  • Loading branch information
derrickstolee committed May 1, 2024
2 parents c1f389a + 6f0f5fa commit 68b0d4c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,6 @@ static int cmd_reconfigure(int argc, const char **argv)
};
struct string_list scalar_repos = STRING_LIST_INIT_DUP;
int i, res = 0;
struct repository r = { NULL };
struct strbuf commondir = STRBUF_INIT, gitdir = STRBUF_INIT;

argc = parse_options(argc, argv, NULL, options,
Expand All @@ -1048,6 +1047,7 @@ static int cmd_reconfigure(int argc, const char **argv)

for (i = 0; i < scalar_repos.nr; i++) {
int succeeded = 0;
struct repository *old_repo, r = { NULL };
const char *dir = scalar_repos.items[i].string;

strbuf_reset(&commondir);
Expand Down Expand Up @@ -1095,14 +1095,18 @@ static int cmd_reconfigure(int argc, const char **argv)

git_config_clear();

if (repo_init(&r, gitdir.buf, commondir.buf))
goto loop_end;

old_repo = the_repository;
the_repository = &r;
r.commondir = commondir.buf;
r.gitdir = gitdir.buf;

if (set_recommended_config(1) >= 0 &&
toggle_maintenance(1) >= 0)
succeeded = 1;

the_repository = old_repo;

loop_end:
if (!succeeded) {
res = -1;
Expand Down
17 changes: 17 additions & 0 deletions t/t9210-scalar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ test_expect_success 'scalar reconfigure' '
test_subcommand git maintenance start <reconfigure
'

test_expect_success 'scalar reconfigure --all' '
repos="two three four" &&
for num in $repos
do
git init $num/src &&
scalar register $num/src &&
git -C $num/src config core.preloadIndex false || return 1
done &&
scalar reconfigure --all &&
for num in $repos
do
test true = "$(git -C $num/src config core.preloadIndex)" || return 1
done
'

test_expect_success '`reconfigure -a` removes stale config entries' '
git init stale/src &&
scalar register stale &&
Expand Down

0 comments on commit 68b0d4c

Please sign in to comment.