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
git: worktree_commit, Modify checking empty commit. Fixes #723 #1050
base: master
Are you sure you want to change the base?
Conversation
By the way, could you provide the answer here? -> #1045 (comment) |
cff0e2a
to
71d1f25
Compare
I have some considerations.
I think comparing treeHash of parent and current tree is more appropriate than this approach. What are your thoughts on it? |
Can you please add a test that tests that an error is returned if you try to add an empty commit to a non-empty repo. |
I think that is what @pjbgf said here: #1050 (comment) And I think the current code will not correctly error for an empty commit on a non-empty repo (hence why I just requested that test) |
Oh! I should have checked the issue carefully. I made a mistake. |
d2f2f86
to
7611da7
Compare
I changed it as requested. I expect this is the right approach. There were test failures as I changed the logic. But I think those were not being tested right. So I changed the tests. |
eefa64b
to
9603fc9
Compare
9603fc9
to
746141e
Compare
What should happen, and is there a test for, a merge commit which leaves the tree in the same state as it was (ie merging 2 branches with the same changes)? (Should that be considered an empty commit?) |
I tested the behavior with git cli. $ git log --all --decorate --oneline --graph
* 1778bba (main) anything
| * 1044aab (HEAD -> hi) ab
| * aaf0fc5 a
| * 2c9a900 second
| * 34b3b53 first
|/
* a60d58b Init
* $ git diff hi main
-- no output -- If you merge $ git merge main
Merge made by the 'ort' strategy. Even if the worktree remains the same, seems like we'll need to store metadata of the commit (parent commits, etc). Since |
@pjbgf Could you re-run the checks? I'm not sure if this failure is related to this PR.
|
@AriehSchneier thanks for helping reviewing this PR. Do you think we need an additional test with a FF merge with a branch that has an empty commit on it? Or are you happy for this to be considered once we implement other merge types? |
Sorry for the slow reply I was on leave and hadn't checked my messages. I'm happy with whatever you think is best (it's been a little while since I looked at the actual change), as long as when the merge types are added its clear that we need to (or don't need to) touch this code to keep it compliant. That said, if there is a possibility off adding more test cases now, I'm not sure why we wouldn't? |
Changed condition of checking empty commit from
count of entries == 0
tocreatedHash == parentHash
.There was an edge case where the given commit is initial commit and worktree has no entries. So I made another control branch to check it.
I'm not aware of other edge cases it might have. If there is one, please let me know.
Connected to #723