aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-02 14:31:18 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-02 14:31:18 +0000
commit1b6461f671b5ad8475c6f30f82d8fc9422746508 (patch)
treeab3d3831ffe979f3673fd1071c59f33fb680933e /src/libfetchers
parentefcd30da891eccdb3518e9c07afc6f907e9ac5e6 (diff)
parentbfa1acd85c4d15c5ea95337138f47672659e2a9e (diff)
Merge remote-tracking branch 'upstream/master' into validPathInfo-ca-proper-datatype
Diffstat (limited to 'src/libfetchers')
-rw-r--r--src/libfetchers/git.cc7
-rw-r--r--src/libfetchers/tarball.cc3
2 files changed, 7 insertions, 3 deletions
diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc
index 7d681218e..75d70c1b4 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;
}
diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc
index 8efb8d68c..e8e5231d2 100644
--- a/src/libfetchers/tarball.cc
+++ b/src/libfetchers/tarball.cc
@@ -74,7 +74,8 @@ DownloadFileResult downloadFile(
.method = FileIngestionMethod::Flat,
.hash = hash,
};
- store->addToStore(info, sink.s, NoRepair, NoCheckSigs);
+ auto source = StringSource { *sink.s };
+ store->addToStore(info, source, NoRepair, NoCheckSigs);
storePath = std::move(info.path);
}