Repository navigation
fetchGit: don't prefix "refs/heads/" on ref = "HEAD" - #4676
Merged
Merged
Conversation
thufschmitt
suggested changes
Mar 29, 2021
thufschmitt
left a comment
Member
There was a problem hiding this comment.
Looks good overall.
I think it's worth a test though (tests/fetchGit.sh seems like the right place for that)
| : ref->compare(0, 5, "refs/") == 0 | ||
| ? *ref | ||
| : "refs/heads/" + *ref; | ||
| : ref->compare("HEAD") == 0 |
Member
There was a problem hiding this comment.
Suggested change
| : ref->compare("HEAD") == 0 | |
| : ref == "HEAD" |
This fixes builtins.fetchGit { url = ...; ref = "HEAD"; }, that works in
stable nix (v2.3.10), but is broken in nix master:
$ ./result/bin/nix repl
Welcome to Nix version 2.4pre19700101_dd77f71. Type :? for help.
nix-repl> builtins.fetchGit { url = "https://github.com/NixOS/nix"; ref = "HEAD"; }
fetching Git repository 'https://github.com/NixOS/nix'fatal: couldn't find remote ref refs/heads/HEAD
error: program 'git' failed with exit code 128
The documentation for builtins.fetchGit says ref = "HEAD" is the
default, so it should also be supported to explicitly pass it.
I came across this issue because poetry2nix can use ref = "HEAD" in some
situations.
Fixes NixOS#4674.
bjornfor
force-pushed
the
fix-fetchgit-ref-head
branch
from
March 30, 2021 09:21
2464a92 to
edd606a
Compare
Contributor
Author
|
@regnat: Thanks for the review! I added your code suggestion and 2 tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes builtins.fetchGit { url = ...; ref = "HEAD"; }, that works in
stable nix (v2.3.10), but is broken in nix master:
The documentation for builtins.fetchGit says ref = "HEAD" is the
default, so it should also be supported to explicitly pass it.
I came across this issue because poetry2nix can use ref = "HEAD" in some
situations.
Fixes #4674.
I'm not 100 % sure how this change interacts with this nix git cache code (and the code that follows), I'd appreciate some review from somewone who knows the Nix code base :-)