From: Derrick Stolee <derrickstolee@github.com>
To: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH] scalar reconfigure -a: remove stale `scalar.repo` entries
Date: Mon, 7 Nov 2022 15:14:41 -0500 [thread overview]
Message-ID: <8e4a8817-4fd5-d7f3-2c7d-bf23e61b9823@github.com> (raw)
In-Reply-To: <pull.1407.git.1667845501422.gitgitgadget@gmail.com>
On 11/7/22 1:25 PM, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> Every once in a while, a Git for Windows installation fails because the
> attempt to reconfigure a Scalar enlistment failed because it was deleted
> manually without removing the corresponding entries in the global Git
> config.
Not actually important to this patch: does it actually fail, or does it
just report a warning message (which _looks_ like a failure)?
> In f5f0842d0b5 (scalar: let 'unregister' handle a deleted enlistment
> directory gracefully, 2021-12-03), we already taught `scalar delete` to
> handle the case of a manually deleted enlistment gracefully. This patch
> adds the same graceful handling to `scalar reconfigure --all`.
>
> This patch is best viewed with `--color-moved`.
Thanks, that did help, even if it's a small change.
> @@ -638,8 +656,22 @@ static int cmd_reconfigure(int argc, const char **argv)
> strbuf_reset(&gitdir);
>
> if (chdir(dir) < 0) {
> - warning_errno(_("could not switch to '%s'"), dir);
> - res = -1;
> + struct strbuf buf = STRBUF_INIT;
> +
> + if (errno != ENOENT) {
> + warning_errno(_("could not switch to '%s'"), dir);
> + res = -1;
> + continue;
> + }
> +
> + 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'"),
> + dir);
> + strbuf_release(&buf);
Looks good.
> +test_expect_success '`reconfigure -a` removes stale config entries' '
> + git init stale/src &&
> + scalar register stale &&
> + scalar list >scalar.repos &&
> + grep stale scalar.repos &&
> + rm -rf stale &&
> + scalar reconfigure -a &&
> + scalar list >scalar.repos &&
> + ! grep stale scalar.repos
> +'
In his reply, Taylor mentioned it would be good to check that we
still have the correct list of scalar.repos value. I think that
might be critical since one "solution" to this problem of a stale
repo could be to remove all scalar.repos values (and this test
would currently pass).
Please use a `test_cmp` against scalar.repos. Something like
this works:
test_expect_success '`reconfigure -a` removes stale config entries' '
git init stale/src &&
scalar register stale &&
scalar list >scalar.repos &&
grep stale scalar.repos &&
grep -v stale scalar.repos >expect &&
rm -rf stale &&
scalar reconfigure -a &&
scalar list >scalar.repos &&
test_cmp expect scalar.repos
'
Thanks,
-Stolee
prev parent reply other threads:[~2022-11-07 20:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 18:25 [PATCH] scalar reconfigure -a: remove stale `scalar.repo` entries Johannes Schindelin via GitGitGadget
2022-11-07 19:03 ` Taylor Blau
2022-11-07 20:14 ` Derrick Stolee [this message]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8e4a8817-4fd5-d7f3-2c7d-bf23e61b9823@github.com \
--to=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).