Skip to content
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

fix(amend): don't detach current branch when current commit has descendants #1072

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

arxanas
Copy link
Owner

@arxanas arxanas commented Sep 24, 2023

Closes #1059.

Previously, `Repo::get_paths_touched_by_commit` returned `None` if the commit was a merge commit, the idea being that a merge commit doesn't have a single correct "patch". However, no call-site cared about this interpretation, and all call-sites worked just as well or better with the new interpretation, where we return the union of all changed paths with respect to all parents. Usually, the impact is that the dehydrated commit is a slightly larger commit than normal.

`git amend` was failing when `HEAD` was a merge commit for this reason, since the "fast amend" path first dehydrated the current commit. Before this commit, git-branchless would panic; after this commit, it successfully amends the merge commit.

Note that the `--merge` option to `git amend` is unrelated: it deals with restacking and merging descendant commits after the amend has been carried out.
Base automatically changed from arxanas/amend to master September 25, 2023 00:39
@arxanas arxanas marked this pull request as ready for review September 25, 2023 00:40
@arxanas arxanas merged commit 0c184b0 into master Oct 3, 2023
13 checks passed
@arxanas arxanas deleted the arxanas/amend-2 branch October 3, 2023 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

git amend in the middle of stack results in detached HEAD
1 participant