forked from LnL7/nix
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make fetchGit/fetchTree use Git file ingestion #6
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
88b5a98
Handle treeHash in Git fetcher
matthewbauer 7f77ba1
Support null bytes in hashes for dumpGitTree
matthewbauer 6611e36
Use “git” for all git object names
matthewbauer d07212c
Show error when git treeHash is not a tree
matthewbauer 3457b3e
Copy executable bit correctly in fs-sink
matthewbauer 3e8ddac
Don’t add 0 in front of dumpGitTree format
matthewbauer 192ea2b
Observe correct git sort order
matthewbauer 3e59168
Merge remote-tracking branch 'obsidiansystems/git-objects-develop' in…
matthewbauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,7 @@ static void parse(ParseSink & sink, Source & source, const Path & path, const Pa | |
Hash hash(HashType::SHA1); | ||
std::copy(hashs.begin(), hashs.end(), hash.hash); | ||
|
||
string entryName = getStoreEntry(storeDir, hash, name); | ||
string entryName = getStoreEntry(storeDir, hash, "git"); | ||
Path entry = absPath(realStoreDir + "/" + entryName); | ||
|
||
struct stat st; | ||
|
@@ -154,22 +154,32 @@ GitMode dumpGitBlob(const Path & path, const struct stat st, Sink & sink) | |
|
||
GitMode dumpGitTree(const GitTree & entries, Sink & sink) | ||
{ | ||
std::string s1 = ""; | ||
vector<uint8_t> v1; | ||
|
||
for (auto & i : entries) { | ||
unsigned int mode; | ||
switch (i.second.first) { | ||
case GitMode::Directory: mode = 40000; break; | ||
case GitMode::Executable: mode = 100755; break; | ||
case GitMode::Regular: mode = 100644; break; | ||
} | ||
s1 += (format("%06d %s\0%s"s) % mode % i.first % i.second.second.hash).str(); | ||
auto name = i.first; | ||
if (i.second.first == GitMode::Directory) | ||
name.pop_back(); | ||
auto s1 = (format("%d %s") % mode % name).str(); | ||
std::copy(s1.begin(), s1.end(), std::back_inserter(v1)); | ||
v1.push_back(0); | ||
std::copy(i.second.second.hash, i.second.second.hash + 20, std::back_inserter(v1)); | ||
} | ||
|
||
std::string s2 = (format("tree %d\0%s"s) % s1.size() % s1).str(); | ||
vector<uint8_t> v2; | ||
auto s2 = (format("tree %d"s) % v1.size()).str(); | ||
std::copy(s2.begin(), s2.end(), std::back_inserter(v2)); | ||
v2.push_back(0); | ||
std::copy(v1.begin(), v1.end(), std::back_inserter(v2)); | ||
|
||
sink(v2.data(), v2.size()); | ||
|
||
vector<uint8_t> v; | ||
std::copy(s2.begin(), s2.end(), std::back_inserter(v)); | ||
sink(v.data(), v.size()); | ||
return GitMode::Directory; | ||
} | ||
|
||
|
@@ -187,8 +197,17 @@ static GitMode dumpGitInternal(HashType ht, const Path & path, Sink & sink, Path | |
else if (S_ISDIR(st.st_mode)) { | ||
GitTree entries; | ||
for (auto & i : readDirectory(path)) | ||
if (filter(path + "/" + i.name)) | ||
entries[i.name] = dumpGitHashInternal(ht, path + "/" + i.name, filter); | ||
if (filter(path + "/" + i.name)) { | ||
auto result = dumpGitHashInternal(ht, path + "/" + i.name, filter); | ||
|
||
// correctly observe git order, see | ||
// https://github.com/mirage/irmin/issues/352 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! |
||
auto name = i.name; | ||
if (result.first == GitMode::Directory) | ||
name += "/"; | ||
|
||
entries[name] = result; | ||
} | ||
perm = dumpGitTree(entries, sink); | ||
} else throw Error(format("file '%1%' has an unsupported type") % path); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a
front_inserter
? Then we could use just one array.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there is!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it doesn't work, because it would be quadratic.