Re: [PATCH v2 4/6] sparse-checkout: error or warn when given individual files
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Feb 17, 2022, 09:05 UTC
- Message-ID
- <220217.86zgmpj1rm.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <c3bb2a3b2f18891b08e9af0145d01703818f8a18.1644913943.git.gitgitgadget@gmail.com>
On Tue, Feb 15 2022, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <newren@gmail.com>
> + if (core_sparse_checkout_cone)
> + die(_("\"%s\" is not a directory; to treat it as a directory anyway, rerun with --skip-checks"), argv[i]);Almost all of our messaging quotes paths etc. with single quotes, which also makes this nicer in the C code:
die(_("'%s' is not a ...> + else
> + warning(_("pass a leading slash before paths such as \"%s\" if you want a single file (see NON-CONE PROBLEMS in the git-sparse-checkout manual)."), argv[i]);ditto.
> static struct option builtin_sparse_checkout_add_options[] = {
> + OPT_BOOL_F(0, "skip-checks", &add_opts.skip_checks,
> + N_("skip some sanity checks on the given paths that might give false positives"),
> + PARSE_OPT_NONEG),This is bikeshedding, but I dislike arguments whose long name requires us to have a PARSE_OPT_NONEG. Or well, not requires, but --no-skip-checks sounds odd, so it's disallowed here.
Why not simply have a --check-path, --path-checks or --sanity-check, all of which combine more naturally with a --no than not.
I.e. set the variable to a default of 1, and let the user negate it.
I think that also makes the synopsis easier to grok at first sight, since a:
git x [--no-XYZ]
Makes it immediately clear what the default is. Well, I suppose "--skip-*" does too, but we use --no-* more.
Another reason to do that is that if you do:
git cmd --no-<TAB>
You can see all the knobs that are off by default, our completion supports that specifically.