mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Merge pull request #9410 from edolstra/shallow
Some shallow git fetching improvements
This commit is contained in:
commit
c185e45ed7
3 changed files with 8 additions and 5 deletions
|
@ -381,7 +381,9 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
||||||
};
|
};
|
||||||
|
|
||||||
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
|
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
|
||||||
opts.depth = shallow ? 1 : GIT_FETCH_DEPTH_FULL;
|
// FIXME: for some reason, shallow fetching over ssh barfs
|
||||||
|
// with "could not read from remote repository".
|
||||||
|
opts.depth = shallow && parseURL(url).scheme != "ssh" ? 1 : GIT_FETCH_DEPTH_FULL;
|
||||||
opts.callbacks.payload = &act;
|
opts.callbacks.payload = &act;
|
||||||
opts.callbacks.sideband_progress = sidebandProgressCallback;
|
opts.callbacks.sideband_progress = sidebandProgressCallback;
|
||||||
opts.callbacks.transfer_progress = transferProgressCallback;
|
opts.callbacks.transfer_progress = transferProgressCallback;
|
||||||
|
|
|
@ -518,8 +518,11 @@ struct GitInputScheme : InputScheme
|
||||||
|
|
||||||
if (doFetch) {
|
if (doFetch) {
|
||||||
try {
|
try {
|
||||||
auto fetchRef = getAllRefsAttr(input)
|
auto fetchRef =
|
||||||
|
getAllRefsAttr(input)
|
||||||
? "refs/*"
|
? "refs/*"
|
||||||
|
: input.getRev()
|
||||||
|
? input.getRev()->gitRev()
|
||||||
: ref.compare(0, 5, "refs/") == 0
|
: ref.compare(0, 5, "refs/") == 0
|
||||||
? ref
|
? ref
|
||||||
: ref == "HEAD"
|
: ref == "HEAD"
|
||||||
|
|
|
@ -51,9 +51,7 @@ git -C $repo add differentbranch
|
||||||
git -C $repo commit -m 'Test2'
|
git -C $repo commit -m 'Test2'
|
||||||
git -C $repo checkout master
|
git -C $repo checkout master
|
||||||
devrev=$(git -C $repo rev-parse devtest)
|
devrev=$(git -C $repo rev-parse devtest)
|
||||||
out=$(nix eval --impure --raw --expr "builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; }" 2>&1) || status=$?
|
nix eval --impure --raw --expr "builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; }"
|
||||||
[[ $status == 1 ]]
|
|
||||||
[[ $out =~ 'Cannot find Git revision' ]]
|
|
||||||
|
|
||||||
[[ $(nix eval --raw --expr "builtins.readFile (builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; allRefs = true; } + \"/differentbranch\")") = 'different file' ]]
|
[[ $(nix eval --raw --expr "builtins.readFile (builtins.fetchGit { url = file://$repo; rev = \"$devrev\"; allRefs = true; } + \"/differentbranch\")") = 'different file' ]]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue