aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers/git.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-04 21:04:35 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-04 21:04:35 +0000
commite5cc1ebc5db1ef837da82f5ce7824bb29cbcc44b (patch)
tree42d659874572b812526596f6534ffe884e77080f /src/libfetchers/git.cc
parenta7b82fd006606dad591f8da88907e79b4c87b1f7 (diff)
parent0f44b60e6dc999697bf9f2a4b3652a0551016598 (diff)
Merge remote-tracking branch 'upstream/master' into no-stringly-typed-derivation-output
Diffstat (limited to 'src/libfetchers/git.cc')
-rw-r--r--src/libfetchers/git.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc
index 17cc60228..75ce5ee8b 100644
--- a/src/libfetchers/git.cc
+++ b/src/libfetchers/git.cc
@@ -282,7 +282,10 @@ struct GitInput : Input
// 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->ref, *input->ref) });
+ auto fetchRef = input->ref->compare(0, 5, "refs/") == 0
+ ? *input->ref
+ : "refs/heads/" + *input->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);
@@ -418,7 +421,7 @@ struct GitInputScheme : InputScheme
auto input = std::make_unique<GitInput>(parseURL(getStrAttr(attrs, "url")));
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);
input->ref = *ref;
}