From 124cc892a16b251d1f4aa1094becb4fb441e0929 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 28 May 2020 18:38:17 -0400 Subject: [PATCH 1/2] Fix bugs with git hashing --- foo/hello.txt | 1 + src/libutil/git.cc | 6 +++--- src/nix/hash.cc | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 foo/hello.txt diff --git a/foo/hello.txt b/foo/hello.txt new file mode 100644 index 00000000000..ef8f9fc5d88 --- /dev/null +++ b/foo/hello.txt @@ -0,0 +1 @@ +asdfsf diff --git a/src/libutil/git.cc b/src/libutil/git.cc index 32ba36677e4..7e8f25b3e14 100644 --- a/src/libutil/git.cc +++ b/src/libutil/git.cc @@ -57,7 +57,7 @@ GitMode dumpGitBlob(const Path & path, const struct stat st, Sink & sink) { auto s = (format("blob %d\0%s"s) % std::to_string(st.st_size) % readFile(path)).str(); - vector v; + vector v; std::copy(s.begin(), s.end(), std::back_inserter(v)); sink(v.data(), v.size()); return st.st_mode & S_IXUSR @@ -75,12 +75,12 @@ GitMode dumpGitTree(const GitTree & entries, Sink & sink) case GitMode::Executable: mode = 100755; break; case GitMode::Regular: mode = 100644; break; } - s1 += (format("%6d %s\0%s"s) % mode % i.first % i.second.second).str(); + s1 += (format("%6d %s\0%s"s) % mode % i.first % i.second.second.hash).str(); } std::string s2 = (format("tree %d\0%s"s) % s1.size() % s1).str(); - vector v; + vector v; std::copy(s2.begin(), s2.end(), std::back_inserter(v)); sink(v.data(), v.size()); return GitMode::Directory; diff --git a/src/nix/hash.cc b/src/nix/hash.cc index 4f3b3cd426f..3a8c82da17b 100644 --- a/src/nix/hash.cc +++ b/src/nix/hash.cc @@ -36,14 +36,17 @@ struct CmdHash : Command std::string description() override { - const char* d; + const char *d; switch (mode) { case FileIngestionMethod::Flat: d = "print cryptographic hash of a regular file"; + break; case FileIngestionMethod::Recursive: d = "print cryptographic hash of the NAR serialisation of a path"; + break; case FileIngestionMethod::Git: d = "print cryptographic hash of the Git serialisation of a path"; + break; }; return d; } From a1f57606958ab760ff06dd6571815f59e32918a5 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 28 May 2020 18:54:51 -0400 Subject: [PATCH 2/2] Remove cached data --- foo/hello.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 foo/hello.txt diff --git a/foo/hello.txt b/foo/hello.txt deleted file mode 100644 index ef8f9fc5d88..00000000000 --- a/foo/hello.txt +++ /dev/null @@ -1 +0,0 @@ -asdfsf