-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Improve errors when we are trying to access a git repository with partial history (+ fix fetchGit on these repos) #13265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This can never work and leads to a crash bug.
3ed12b2
to
3110805
Compare
if (!getShallowAttr(input)) { | ||
input.attrs.insert_or_assign("revCount", | ||
rev == nullRev ? 0 : getRevCount(*input.settings, repoInfo, repoPath, rev)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this intended to be included in this PR? Because this seems like a behaviour change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't change behavior. If we do a builtins.fetchGit with shallow = true; than it tries to compute the revCount and crashes. This code never worked for shallow clones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the error before this change:
error:
… while calling the 'fetchGit' builtin
at «string»:1:2:
1| (builtins.fetchGit { url = "file:///tmp/nix-test/main/fetchGitShallow/shallow-worktree"; shallow = true; }).rev
| ^
… while fetching the input 'git+file:///tmp/nix-test/main/fetchGitShallow/shallow-worktree?exportIgnore=1&shallow=1'
error: getting parent of Git commit 'b84683a868d74413ba54bd3c7da8bd57a94a8c8a': object not found - no match for id (cfad7cc96b05c722c83ea7c41269a6910c0a2020)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other code paths for shallow clones also seem to not include revCount as expected.
[[ $(nix eval --impure --expr "(builtins.fetchTree { type = \"git\"; url = \"file://$TEST_ROOT/shallow\"; ref = \"dev\"; shallow = true; }).revCount or 123") == 123 ]] | ||
|
||
expectStderr 1 nix eval --expr 'builtins.fetchTree { type = "git"; url = "file:///foo"; }' | grepQuiet "'fetchTree' will not fetch unlocked input" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if these tests should be removed in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not removed but moved to fetchGitShallow.sh
Before we got something like this but only inside the VM test: vm-test-run-functional-tests-on-nixos_user> machine # fetchGit.sh: line 286: unexpected EOF while looking for matching `)' We now try to do not too much in a single line, so that the bash parser does not get confused. This also seems more readable and better quoted.
3110805
to
5419d82
Compare
Motivation
This is a subset of #13260 but doesn't change the default behavior for flake urls, so it can be backported.
Error fixed by this PR:
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.