mirror of
https://github.com/NixOS/nix
synced 2025-07-07 06:01:48 +02:00
Merge pull request #13265 from Mic92/fix-shallow-clone-subset
Improve errors when we are trying to access a git repository with partial history (+ fix fetchGit on these repos)
This commit is contained in:
commit
170f6021cf
5 changed files with 92 additions and 22 deletions
|
@ -322,8 +322,17 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
|||
|
||||
for (size_t n = 0; n < git_commit_parentcount(commit->get()); ++n) {
|
||||
git_commit * parent;
|
||||
if (git_commit_parent(&parent, commit->get(), n))
|
||||
throw Error("getting parent of Git commit '%s': %s", *git_commit_id(commit->get()), git_error_last()->message);
|
||||
if (git_commit_parent(&parent, commit->get(), n)) {
|
||||
throw Error(
|
||||
"Failed to retrieve the parent of Git commit '%s': %s. "
|
||||
"This may be due to an incomplete repository history. "
|
||||
"To resolve this, either enable the shallow parameter in your flake URL (?shallow=1) "
|
||||
"or add set the shallow parameter to true in builtins.fetchGit, "
|
||||
"or fetch the complete history for this branch.",
|
||||
*git_commit_id(commit->get()),
|
||||
git_error_last()->message
|
||||
);
|
||||
}
|
||||
todo.push(Commit(parent));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -798,8 +798,10 @@ struct GitInputScheme : InputScheme
|
|||
auto rev = repoInfo.workdirInfo.headRev.value_or(nullRev);
|
||||
|
||||
input.attrs.insert_or_assign("rev", rev.gitRev());
|
||||
input.attrs.insert_or_assign("revCount",
|
||||
rev == nullRev ? 0 : getRevCount(*input.settings, repoInfo, repoPath, rev));
|
||||
if (!getShallowAttr(input)) {
|
||||
input.attrs.insert_or_assign("revCount",
|
||||
rev == nullRev ? 0 : getRevCount(*input.settings, repoInfo, repoPath, rev));
|
||||
}
|
||||
|
||||
verifyCommit(input, repo);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue