-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix issue 4997 - Rebase/Fixup/Reword/Squash/Patch/Drop onto wrong commit (sibling branch) when git.log.showWholeGraph=true #5008
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR modifies the interactive rebase functionality to properly calculate and pass the parent commit index for various rebase operations. The key improvement is the addition of a new GetParentCommit helper method that finds the actual parent commit by traversing the commit graph, rather than relying on simple index arithmetic. The confirmation messages are also updated to clarify that operations squash/fixup into "the parent commit below" instead of just "the commit below".
- Added
GetParentCommithelper method to find actual parent commits in the commit list - Updated all rebase operations to calculate and pass the correct parent index
- Clarified user-facing messages to specify "parent commit below"
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/gui/controllers/helpers/commits_helper.go | Implements new GetParentCommit helper method to find parent commits by traversing commit history |
| pkg/gui/controllers/local_commits_controller.go | Updates all rebase operations to calculate parent index using the new helper and passes it to git commands |
| pkg/gui/controllers/custom_patch_options_menu_action.go | Updates patch operations to calculate and pass parent index |
| pkg/gui/controllers/commits_files_controller.go | Updates file discard operation to calculate and pass parent index |
| pkg/commands/git_commands/rebase.go | Updates rebase command methods to accept and use parent index parameter |
| pkg/commands/git_commands/patch.go | Updates patch command methods to accept and use parent index parameter |
| pkg/commands/git_commands/rebase_test.go | Adds parent index parameter to test cases |
| pkg/i18n/english.go | Updates confirmation messages to clarify "parent commit below" |
| pkg/i18n/translations/ko.json | Updates Korean translations to match English message changes |
| pkg/integration/tests/interactive_rebase/*.go | Updates test expectations to match new confirmation messages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f7c6c53 to
048cede
Compare
7a1fb7c to
348b294
Compare
bfb5bc8 to
b39ac5a
Compare
…holeGraph=true - Able to accurately select the parent commit now, preventing incorrect operations on merge commits and complex histories. - Updated method signatures to accept a parent commit index for precise targeting. - Improved english confirmation prompts and translations to clarify actions affect the parent commit below. - Fixed: squash "s", drop "d", reword "r/R", discard "d", edit/interactive-rebase "e", fixup "f", amend "a/A, patch "Ctrl-P" - Not yet fixed: interative-rebase "i" fix: GetParentCommit edge cases
cffd08d to
d7ad976
Compare
|
Is there a way to get momentum on this? It's a super annoying bug. |
PR Description
Fixes: #4997
This PR fixes bug mentioned in #4997 except the bug on interactive-rebase "i".
I have yet to figure out a way to get common ancestor to quickly obtains all the commits from the feature branch starting from the common ancestor.
Otherwise, the current approach shown below will still cause issue when git.log.showWholeGraph=true.
Please check if the PR fulfills these requirements
go generate ./...)