Re: Unexpected (bug-like) behavior in `git ls-remote` matching.
- From
Jeff King <peff@peff.net>
- Date
- Feb 8, 2023, 16:30 UTC
- Message-ID
- <Y+POCxHMzrZj2bwz@coredump.intra.peff.net>
- In-Reply-To
- <CALJHx12DetwZ=+aMEG6Ss4P3fMTeLN2styXuPw93C5N6yg98NA@mail.gmail.com>
On Wed, Feb 08, 2023 at 08:49:57AM -0500, William Blevins wrote:
> This still feels "weird" to me. Other pattern matching tools like grep > and sed don't have exceptions to their behavior like this. > > Can you reference the unit tests that verifies this specific behavior?
See commit 631f0f8c4b (ls-remote: do not send ref prefixes for patterns, 2018-10-31), which also adds a test. However, it was just handling existing behavior (which in fact confused another developer and caused a bug which the commit was fixing!).
I think the tail-matching behavior is not what we would probably choose today, but that is how it has behaved since 2005, and we are not going to break backwards compatibility in a plumbing tool like ls-remote.
There's some discussion in this thread about adding a new option to do prefix-matching, but I don't think any code was ever written:
https://lore.kernel.org/git/m2k12g7v5u.fsf@gmail.com/
Likewise, something more elaborate like full-path globbing or even regex matching would be possible, but would need to be activated by an option.
-Peff