aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-02-01 23:54:20 +0100
committerEelco Dolstra <edolstra@gmail.com>2020-02-01 23:54:20 +0100
commit887730aab39dd63a37d49d72a07c6441ea3b2f92 (patch)
tree9bda18dac5be9832ea797a73fe375829ba9f9785 /src/libstore
parentb9d64f931893120834fa54ebf084764d2e22ba33 (diff)
Remove superfluous TreeInfo::rev field
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/fetchers/git.cc33
-rw-r--r--src/libstore/fetchers/github.cc1
-rw-r--r--src/libstore/fetchers/mercurial.cc2
-rw-r--r--src/libstore/fetchers/tree-info.hh2
4 files changed, 19 insertions, 19 deletions
diff --git a/src/libstore/fetchers/git.cc b/src/libstore/fetchers/git.cc
index 4ad0f6f34..4f302cd0f 100644
--- a/src/libstore/fetchers/git.cc
+++ b/src/libstore/fetchers/git.cc
@@ -23,21 +23,25 @@ static Path getCacheInfoPathFor(const std::string & name, const Hash & rev)
return cacheDir + "/" + linkName + ".link";
}
-static void cacheGitInfo(Store & store, const std::string & name, const Tree & tree)
+static void cacheGitInfo(
+ Store & store,
+ const std::string & name,
+ const Tree & tree,
+ const Hash & rev)
{
nlohmann::json json;
json["storePath"] = store.printStorePath(tree.storePath);
json["name"] = name;
- json["rev"] = tree.info.rev->gitRev();
+ json["rev"] = rev.gitRev();
json["revCount"] = *tree.info.revCount;
json["lastModified"] = *tree.info.lastModified;
- auto cacheInfoPath = getCacheInfoPathFor(name, *tree.info.rev);
+ auto cacheInfoPath = getCacheInfoPathFor(name, rev);
createDirs(dirOf(cacheInfoPath));
writeFile(cacheInfoPath, json.dump());
}
-static std::optional<Tree> lookupGitInfo(
+static std::optional<std::pair<Hash, Tree>> lookupGitInfo(
ref<Store> store,
const std::string & name,
const Hash & rev)
@@ -50,16 +54,14 @@ static std::optional<Tree> lookupGitInfo(
auto storePath = store->parseStorePath((std::string) json["storePath"]);
if (store->isValidPath(storePath)) {
- Tree tree{
+ return {{rev, Tree{
.actualPath = store->toRealPath(store->printStorePath(storePath)),
.storePath = std::move(storePath),
.info = TreeInfo {
- .rev = rev,
.revCount = json["revCount"],
.lastModified = json["lastModified"],
}
- };
- return tree;
+ }}};
}
} catch (SysError & e) {
@@ -181,8 +183,10 @@ struct GitInput : Input
assert(!rev || rev->type == htSHA1);
if (rev) {
- if (auto tree = lookupGitInfo(store, name, *rev))
- return {std::move(*tree), input};
+ if (auto tree = lookupGitInfo(store, name, *rev)) {
+ input->rev = tree->first;
+ return {std::move(tree->second), input};
+ }
}
auto [isLocal, actualUrl_] = getActualUrl();
@@ -326,8 +330,10 @@ struct GitInput : Input
input->rev = Hash(chomp(readFile(localRefFile)), htSHA1);
}
- if (auto tree = lookupGitInfo(store, name, *input->rev))
- return {std::move(*tree), input};
+ if (auto tree = lookupGitInfo(store, name, *input->rev)) {
+ assert(*input->rev == tree->first);
+ return {std::move(tree->second), input};
+ }
// FIXME: check whether rev is an ancestor of ref.
@@ -354,13 +360,12 @@ struct GitInput : Input
.actualPath = store->toRealPath(store->printStorePath(storePath)),
.storePath = std::move(storePath),
.info = TreeInfo {
- .rev = input->rev,
.revCount = revCount,
.lastModified = lastModified
}
};
- cacheGitInfo(*store, name, tree);
+ cacheGitInfo(*store, name, tree, *input->rev);
return {std::move(tree), input};
}
diff --git a/src/libstore/fetchers/github.cc b/src/libstore/fetchers/github.cc
index a4d39d17d..0a000e83f 100644
--- a/src/libstore/fetchers/github.cc
+++ b/src/libstore/fetchers/github.cc
@@ -114,7 +114,6 @@ struct GitHubInput : Input
.actualPath = dresult.path,
.storePath = store->parseStorePath(dresult.storePath),
.info = TreeInfo {
- .rev = *rev,
.lastModified = *dresult.lastModified,
},
};
diff --git a/src/libstore/fetchers/mercurial.cc b/src/libstore/fetchers/mercurial.cc
index b415b7944..0eb81d014 100644
--- a/src/libstore/fetchers/mercurial.cc
+++ b/src/libstore/fetchers/mercurial.cc
@@ -220,7 +220,6 @@ struct MercurialInput : Input
.actualPath = store->printStorePath(storePath),
.storePath = std::move(storePath),
.info = TreeInfo {
- .rev = input->rev,
.revCount = revCount,
},
},
@@ -256,7 +255,6 @@ struct MercurialInput : Input
.actualPath = store->printStorePath(storePath),
.storePath = std::move(storePath),
.info = TreeInfo {
- .rev = input->rev,
.revCount = revCount
}
},
diff --git a/src/libstore/fetchers/tree-info.hh b/src/libstore/fetchers/tree-info.hh
index 61500facb..28ead8588 100644
--- a/src/libstore/fetchers/tree-info.hh
+++ b/src/libstore/fetchers/tree-info.hh
@@ -5,7 +5,6 @@ namespace nix {
struct TreeInfo
{
Hash narHash;
- std::optional<Hash> rev; // FIXME: remove
std::optional<uint64_t> revCount;
std::optional<time_t> lastModified;
@@ -13,7 +12,6 @@ struct TreeInfo
{
return
narHash == other.narHash
- && rev == other.rev
&& revCount == other.revCount
&& lastModified == other.lastModified;
}