Skip to content

Conversation

@ryan-ph
Copy link
Contributor

@ryan-ph ryan-ph commented Nov 28, 2024

Negative refspecs were added in Git v2.29.0 which allows refspecs to be
prefixed with ^1. Currently, the library is unable to normalize
negative refspecs which causes errors in different tools that rely on
libgit2. Specifically, when the library attempts to parse and
normalize a negative refspec, it returns a GIT_EINVALIDSPEC code.

Add the ability to correctly normalize negative refspecs. While this PR
will not update the behavior of fetch, or other actions that rely on
negative refspecs, this allows us to be able to successfully parse and
normalize them. A future change will handle updating the individual
actions.

#6741

Footnotes

  1. https://github.com/git/git/commit/c0192df6306d4d9ad77f6015a053925b13155834

Negative refspecs were added in Git v2.29.0 which allows refspecs to be
prefixed with `^`[^1]. Currently, the library is unable to normalize
negative refspecs which causes errors in different tools that rely on
`libgit2`. Specifically, when the library attempts to parse and
normalize a negative refspec, it returns a `GIT_EINVALIDSPEC` code.

Add the ability to correctly normalize negative refspecs. While this PR
will not update the behavior of `fetch`, or other actions that rely on
negative refspecs, this allows us to be able to successfully parse and
normalize them. A future change will handle updating the individual
actions.

[^1]: git/git@c0192df
@ryan-ph ryan-ph force-pushed the ryanpham/negative-refspec/parse branch from d2fd5ae to 2adb7bc Compare November 28, 2024 04:11
@ethomson
Copy link
Member

Seems reasonable - could you take a look at the failing existing test? I assume that it assumes that we don't support negative ref specs?

Refs can now be prefixed with a ^ (indicating a negative ref). Remove a
now-obsolete validity test.
@ethomson
Copy link
Member

Seems reasonable - could you take a look at the failing existing test? I assume that it assumes that we don't support negative ref specs?

Nevermind - I fixed the test. Thanks for the addition to the library!

@ethomson ethomson merged commit 1738f89 into libgit2:main Dec 11, 2024
18 checks passed
@ryan-ph
Copy link
Contributor Author

ryan-ph commented Dec 11, 2024

Oops, I didn't realize I left a broken test. Thanks! Will work on updating the remote related code when I get a chance.

@ethomson
Copy link
Member

Oops, I didn't realize I left a broken test. Thanks! Will work on updating the remote related code when I get a chance.

No worries! It was old unrelated code.

I'd look forward to the remote code! Exciting stuff, thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants