Closed
Description
It seems that negative refspec in the form of ^refs
is not yet implemented in libgit2. See:
- Documentation: https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt-ltrefspecgt
- implementation in git: https://github.com/git/git/blob/master/remote.c#L896-L918
- libgit2 refspec parser: https://github.com/libgit2/libgit2/blob/main/src/libgit2/refspec.c
Reproduction steps
Perform a fetch with a negative refspec in some application. I am using https://github.com/arxanas/git-branchless/tree/v0.8.0.
Observe the error:
$ git-branchless submit @
branchless: running command: git fetch origin refs/heads/checkpoint-build-improve
Pseudo-terminal will not be allocated because stdin is not a terminal.
From github.com:bryango/nixpkgs
* branch checkpoint-build-improve -> FETCH_HEAD
The application panicked (crashed).
Message: A fatal error occurred:
0: could not find upstream branch for branch with name 'checkpoint-build-improve': '^refs/heads/rapidfuzz-opt-numpy' is not a valid refspec.; class=Invalid (3)
1: '^refs/heads/rapidfuzz-opt-numpy' is not a valid refspec.; class=Invalid (3)
Location: git-branchless-submit/src/branch_forge.rs:155
Location: git-branchless/src/commands/mod.rs:235
The full error is specific to git-branchless, but the not a valid refspec
part seems to come from libgit2.
Expected behavior
Understand negative refspec in the form of ^refs
.
Actual behavior
Do not understand negative refspec in the form of ^refs
.
Version of libgit2 (release number or SHA1)
I believe this is the rust binding of libgit2 v1.6.4.
Operating system(s) tested
$ uname -a
Linux 6.6.8-2-MANJARO #1 SMP PREEMPT_DYNAMIC Thu Dec 21 16:21:45 UTC 2023 x86_64 GNU/Linux