libgit2 icon indicating copy to clipboard operation
libgit2 copied to clipboard

Backport negative refspec patches

Open Frederick888 opened this issue 3 months ago • 0 comments

a7b1d11ab refs: Handle normalizing negative refspecs

Upstream commit 2adb7bc3f5f6eed38938ec6b7ab4a79827ade37e.

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.

383be7b53 refspec: Add func to distinguish negative refspecs

Upstream commit 3d9f4061ca56a3f2c4055904d924974031f59923.

Negative refspecs were added in Git v2.29.0 and are denoted by prefixing a refspec with a caret. This adds a way to distinguish if a refspec is negative and match negative refspecs.

20f77fb55 remote: Handle fetching negative refspecs

Upstream commit f7f30ec136907a2aad5e58ba95081ac94fe6aba6.

Add support for fetching with negative refspecs. Fetching from the remote with a negative refspec will now validate any references fetched do not match any negative refspecs and at least one non-negative refspec. As we must ensure that fetched references do not match any of the negative refspecs provided, we cannot short-circuit when checking for matching refspecs.

Closes https://github.com/romkatv/gitstatus/issues/438

Frederick888 avatar Sep 13 '25 02:09 Frederick888