aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers/git.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-06-03 16:15:22 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-06-03 16:15:22 +0200
commitc20591ddc3454263ac49435624f4ec2983ee335d (patch)
treee026dc0c272e02b3e5293f819b46f8f93df3d206 /src/libfetchers/git.cc
parent7dbba0a94e3d5ad0388131d5653808084c42db89 (diff)
parent01572c2198de49071827f0be9f5db202bac21703 (diff)
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/libfetchers/git.cc')
-rw-r--r--src/libfetchers/git.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc
index af4efc9b1..0b6155e71 100644
--- a/src/libfetchers/git.cc
+++ b/src/libfetchers/git.cc
@@ -64,7 +64,7 @@ struct GitInputScheme : InputScheme
maybeGetBoolAttr(attrs, "submodules");
if (auto ref = maybeGetStrAttr(attrs, "ref")) {
- if (!std::regex_match(*ref, refRegex))
+ if (std::regex_search(*ref, badGitRefRegex))
throw BadURL("invalid Git branch/tag name '%s'", *ref);
}
@@ -261,7 +261,7 @@ struct GitInputScheme : InputScheme
return files.count(file);
};
- auto storePath = store->addToStore("source", actualUrl, true, htSHA256, filter);
+ auto storePath = store->addToStore("source", actualUrl, FileIngestionMethod::Recursive, htSHA256, filter);
// FIXME: maybe we should use the timestamp of the last
// modified dirty file?
@@ -348,7 +348,11 @@ struct GitInputScheme : InputScheme
// FIXME: git stderr messes up our progress indicator, so
// we're using --quiet for now. Should process its stderr.
try {
- runProgram("git", true, { "-C", repoDir, "fetch", "--quiet", "--force", "--", actualUrl, fmt("%s:%s", *input.getRef(), *input.getRef()) });
+ auto ref = input.getRef();
+ auto fetchRef = ref->compare(0, 5, "refs/") == 0
+ ? *ref
+ : "refs/heads/" + *ref;
+ runProgram("git", true, { "-C", repoDir, "fetch", "--quiet", "--force", "--", actualUrl, fmt("%s:%s", fetchRef, fetchRef) });
} catch (Error & e) {
if (!pathExists(localRefFile)) throw;
warn("could not update local clone of Git repository '%s'; continuing with the most recent version", actualUrl);
@@ -413,7 +417,7 @@ struct GitInputScheme : InputScheme
unpackTarfile(*source, tmpDir);
}
- auto storePath = store->addToStore(name, tmpDir, true, htSHA256, filter);
+ auto storePath = store->addToStore(name, tmpDir, FileIngestionMethod::Recursive, htSHA256, filter);
auto lastModified = std::stoull(runProgram("git", true, { "-C", repoDir, "log", "-1", "--format=%ct", input.getRev()->gitRev() }));