Re: [PATCH] doc: ls-tree paths do not support wildcards
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 28, 2020, 22:21 UTC
- Message-ID
- <xmqqy2pb1z0x.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200528215107.GA1265681@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> So I think for now we ought to explain the situation a bit more clearly: > leave this language as-is, but add a new section describing what > patterns we do support.
Thanks; you said a lot better than I could ;-)
Show 19 quoted lines
> In the long run it would be nice to actually match regular pathspecs. > That would be a backwards-incompatibility, which I think is why nobody > has pursued it further (and ls-tree is meant to be plumbing that should > stay consistent, so we need to be extra careful). So we'd need a > transition plan. Perhaps: > > 1. Deprecate the current behavior in the documentation and release > notes, encouraging people who want literal matching to use > --literal-pathspecs or the ":(literal)" magic. AFAICT we've > supported these since at least 2013 for this command, so it should > be safe to use unconditionally. > > 2. Add a new option, "--use-pathspecs" or similar, that switches the > matching code to use match_pathspec(). That lets people use the new > feature immediately if they want to. > > 3. When --use-pathspecs is not in use, warn to stderr about any > wildcard characters in the input. That reinforces the deprecation > notice in (1) and is likely to get more people's attention.
Hmph, if we are serious about deprecation and migration, I would image that in stage #1, we should do this check already. When "--literal-pathspecs" is NOT in use, if a pathspec would change its meaning if not taken literally (e.g. has glob letters, begins with :-magic introducer, etc.), we warn and do so from the very beginning of the migration process.
> 4. After several releases, flip the default to --use-pathspecs, > leaving --no-use-pathspecs as an escape hatch for people who still > haven't switched their scripts.
Wouldn't --literal-pathspecs be the accepted escape hatch that will always be accepted, even after --use-pathspecs becomes a no-op?
> 5. After several more releases, eventually remove the old-style > matching (perhaps leaving --use-pathspecs as a noop).
> To be honest, that may be more careful than we absolutely need to be.
Yeah, there seem to be some room for optimization, but I think the key steps are about right if we wanted to do this migration.
Thanks.