Negative fetch refspec causes `NegativeGlobPattern` parsing error
Current behavior 😯
https://github.com/o2sh/onefetch switched from libgit2 to gitoxide a while back
Now when I use onefetch in a repo where .git/config has
[remote "origin"]
url = [email protected]:.../...
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = ^refs/heads/*-deploy
fetch = ^refs/tags/*-deploy
It prints
Error: Failed to determine repository URL
Caused by:
0: fetch ref-spec under `remote.origin` was invalid
1: The refspec at "remote.<name>.fetch=^refs/heads/*-deploy" could not be parsed
2: Negative glob patterns are not allowed
This seems to be from https://github.com/GitoxideLabs/gitoxide/commit/4c4f82170d08b910a7f64482431c99956b1a04c3#diff-6d0a30d3d2eca6be3076f24e2cc5580c2862905660b5a68a47e6f545c112a579
I'm not familiar this library. The error message seems to say that negative fetch glob refspecs are simply not supported by this library, while the commit itself was trying to bar invalid negative glob refspecs only?
Expected behavior 🤔
Those two negative refspecs work in Git correctly. I'd expected they are treated as valid ones here too.
Git behavior
I usually run git fetch --all --prune --tags --jobs=10, which does not fetch those branches / tags with the negative refspecs.
Steps to reproduce 🕹
- Add those refspecs in a repo
- Install and run
onefetch
Thanks a lot for bringing this to my attention!
It should definitely not fail to just parse these refspecs and fail to open a repository.
Seeing that the commit explicitly added this makes me think that either I didn't know how to test this correctly, or I tested these specs with a command where they didn't work, or back then they really didn't work.
It will probably take me a moment to get into this more, as it will definitely need fetch-related tests to assure the filtering is truly working once it is allowed.
However, maybe the first step could be to allow parsing them, as a first fix, and then assure it does the right thing when fetching with gix.