mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
Fetch specific Git revisions
This is more efficient, and necessary when using shallow=1 with a rev.
This commit is contained in:
parent
f450c8773c
commit
e4066c0444
@ -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 New Issue
Block a user