Conversation
JJLovesLife
reviewed
Nov 3, 2023
|
|
||
| app = os.path.abspath(args.exe) | ||
|
|
||
| app = os.path.abspath('D:\learn\programming\s-git\s-git.exe') |
Owner
There was a problem hiding this comment.
这种不要commit进来,要是懒得传arg,可以改成optional的,然后用relative path。
| return 0; | ||
| } | ||
|
|
||
| int checkout(std::string branch){ |
Owner
There was a problem hiding this comment.
Reuse this function in line 187-214.
| return commitSha1; | ||
| } | ||
|
|
||
| struct commit Parent(struct commit child){ |
| if (buffer.has_value()) write_file(path, buffer.value()); | ||
| } | ||
|
|
||
| std::optional<std::string> resolveBranch(std::string &branch) { |
Owner
There was a problem hiding this comment.
This duplicate with https://github.com/MMaxwell66/s-git/blob/b6c24c5beaa32a5d6baf5747e6afe2b4848aca73/checkout/checkout.cpp#L119 Can we move into a common location?
| readTree(ROOT_DIR.value(), ancestor.tree, ancestorEntries); | ||
| // 将 ancestorEntries 转换为set | ||
| std::unordered_set<object,object_hash, object_equal> ancestorSet; | ||
| for (auto &entry : ancestorEntries) { |
Owner
There was a problem hiding this comment.
https://en.cppreference.com/w/cpp/container/unordered_set/unordered_set 能用6/7这种Iterator的构造函数吗?
| commit ancestor = LCA(currBranchCommit,mergeFromCommit); | ||
| std::cout << ancestor.message << std::endl; | ||
| // 三路归并文件树 | ||
| // 1. 读取ancestor的文件树 |
| } | ||
|
|
||
| object mergeFile(object based,object source,object curr){ | ||
| if (based.object_type == "blob") { |
Owner
There was a problem hiding this comment.
Well, 有一种写法的目的是为了减少代码的缩进,我比较推荐一点。
if (base.object_type != "blob") return /**/;
// following code has one less indentation.| } | ||
|
|
||
| //直接将当前分支指向mergeFromCommit | ||
| extern |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Basically completed the three-way merge of blob files, assuming there is a common ancestor node.