Skip to content

Commit

Permalink
Fixup bad rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbauer committed Jun 2, 2020
1 parent b120259 commit 4e3a7d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ StorePath LocalStore::addToStore(const string & name, const Path & _srcPath,
small files. */
StringSink sink;
switch (method) {
case FileIngestionMethod::Recursive:
case FileIngestionMethod::Recursive: {
dumpPath(srcPath, sink, filter);
break;
}
Expand Down
9 changes: 3 additions & 6 deletions src/libutil/git.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ typedef std::map<string, std::pair<GitMode, Hash>> GitTree;
GitMode dumpGitTree(const GitTree & entries, Sink & sink);

// Recursively dumps path, hashing as we go
Hash dumpGitHash(
std::function<std::unique_ptr<AbstractHashSink>()>,
const Path & path,
PathFilter & filter = defaultPathFilter);
Hash dumpGitHash(HashType ht, const Path & path, PathFilter & filter = defaultPathFilter);

void dumpGit(HashType ht, const Path & path, Sink & sink, PathFilter & filter = defaultPathFilter);

// N.B. There is no way to recursively dump to a sink, as that doesn't make
// sense with the git hash/data model where the information is Merklized.
}
19 changes: 6 additions & 13 deletions src/nix/hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,24 @@ struct CmdHash : Command
{
for (auto path : paths) {

auto makeHashSink = [&]() -> std::unique_ptr<AbstractHashSink> {
std::unique_ptr<AbstractHashSink> t;
if (modulus)
t = std::make_unique<HashModuloSink>(ht, *modulus);
else
t = std::make_unique<HashSink>(ht);
return t;
};
std::unique_ptr<AbstractHashSink> hashSink;
if (modulus)
hashSink = std::make_unique<HashModuloSink>(ht, *modulus);
else
hashSink = std::make_unique<HashSink>(ht);

Hash h;
switch (mode) {
case FileIngestionMethod::Flat: {
auto hashSink = makeHashSink();
readFile(path, *hashSink);
h = hashSink->finish().first;
break;
}
case FileIngestionMethod::Recursive: {
auto hashSink = makeHashSink();
dumpPath(path, *hashSink);
h = hashSink->finish().first;
break;
}
case FileIngestionMethod::Git:
h = dumpGitHash(makeHashSink, path);
dumpGit(ht, path, *hashSink);
break;
}

Expand Down

0 comments on commit 4e3a7d9

Please sign in to comment.