aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/fetchers/fetchers.hh3
-rw-r--r--src/libstore/fetchers/git.cc12
-rw-r--r--src/libstore/fetchers/mercurial.cc11
3 files changed, 26 insertions, 0 deletions
diff --git a/src/libstore/fetchers/fetchers.hh b/src/libstore/fetchers/fetchers.hh
index 0ef79bc45..64628d1bb 100644
--- a/src/libstore/fetchers/fetchers.hh
+++ b/src/libstore/fetchers/fetchers.hh
@@ -62,6 +62,9 @@ struct Input : std::enable_shared_from_this<Input>
virtual std::optional<Path> getSourcePath() const { return {}; }
+ // FIXME: should merge with getSourcePath().
+ virtual void markChangedFile(std::string_view file) const { assert(false); }
+
virtual void clone(const Path & destDir) const
{
throw Error("do not know how to clone input '%s'", to_string());
diff --git a/src/libstore/fetchers/git.cc b/src/libstore/fetchers/git.cc
index 0101744bd..1c74d92a4 100644
--- a/src/libstore/fetchers/git.cc
+++ b/src/libstore/fetchers/git.cc
@@ -165,6 +165,18 @@ struct GitInput : Input
return {};
}
+ void markChangedFile(std::string_view file) const override
+ {
+ auto sourcePath = getSourcePath();
+ assert(sourcePath);
+ runProgram("git", true,
+ { "-C", *sourcePath, "add",
+ "--force",
+ "--intent-to-add",
+ std::string(file)
+ });
+ }
+
std::pair<bool, std::string> getActualUrl() const
{
// Don't clone file:// URIs (but otherwise treat them the
diff --git a/src/libstore/fetchers/mercurial.cc b/src/libstore/fetchers/mercurial.cc
index 9b8c2132c..0825f6b23 100644
--- a/src/libstore/fetchers/mercurial.cc
+++ b/src/libstore/fetchers/mercurial.cc
@@ -84,6 +84,17 @@ struct MercurialInput : Input
return {};
}
+ void markChangedFile(std::string_view file) const override
+ {
+ auto sourcePath = getSourcePath();
+ assert(sourcePath);
+ // FIXME: shut up if file is already tracked.
+ runProgram("hg", true,
+ { "add",
+ *sourcePath + "/" + std::string(file)
+ });
+ }
+
std::pair<bool, std::string> getActualUrl() const
{
bool isLocal = url.scheme == "file";