-
Notifications
You must be signed in to change notification settings - Fork 589
discard changes: hunks #7677
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
discard changes: hunks #7677
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@Byron is attempting to deploy a commit to the GitButler Team on Vercel. A member of the Team first needs to authorize it. |
If an index modification is dropped beecause there also is an overriding modification to the worktree, assure that we use the higher-value modification which can happen if the to-be-dropped modification is a rename. Also add some protection for other cases that we might not know about.
That way it's easier to review or manipulate hunks as they wouild occur in testing.
When comparing hunks we must be sure these refer these have been created from the same content. Currently, `unified_diff()` produces the content by applying binary-to-text filters, which is good for presentation of binary files, but bad if hunks actually get selected there. For now, rely on hunks having to match perfectly to be applicable, but assure that the content used for file generation is the same (so the hunks that match actually refer to the right thing).
Previously, if there were tree/index changes and index/worktree changes, the index/worktree changes would inform the states to diff. This is correct for Git, but wrong for GitButler which is only interested in the 'total' change. Now we always use the previous change of a tree/index modification as the previous change of the corresponding index/worktree modification.
@Caleb-T-Owens The issue mentioned in Discord is now fixed, and led to the realisation that an entire bag of problems with worktree changes was nearly entirely ignored previously. Now I see that what GitButler really is doing is to "pretend the index doesn't exist". For the typical user and GitButler-exclusive operation that is the case even, and the index is always matching the tree it was created from. Every handled case (even those that aren't implemented yet) has a specific test-case to trigger it, which makes deciding what should be done very easy. Follow-up PRs have to deal with the Thinking about it, now that this is implemented, the UI could be used for testing how certain edge-cases will work quite easily, the test-cases show how these states can be triggered. And yes, I guess you can take this as invitation to break it :D. @krlvi I am merging this without review as this is only refactors in preparation for chunk-handling, along with plenty of fixes. |
Thanks @Byron. I'm starting to use the v3 client where possible, so I can hopefully exercise most of these |
Add V3 facilities for discarding changes in the worktree or index, this time it's about hunks specifically.
Follow-up of #7597.
Tasks
deduplicate match- no need, will just be harder to read thenFor next PR
main
.Notes for the reviewer
For the next PR
Shortcomings
Out of Scope
Research
unapply_lines
,unapply_ownership
andreset_files