fix(git): keep the merge parent when git_commit concludes a merge - #4942
Open
jayhemnani9910 wants to merge 2 commits into
Open
jayhemnani9910 wants to merge 2 commits into
jayhemnani9910 wants to merge 2 commits into
Conversation
After a conflicted merge was resolved and staged, git_commit created a commit with only HEAD as its parent and left MERGE_HEAD behind, so the merged branch's history was silently dropped and status still reported an unfinished merge. When MERGE_HEAD exists, commit with it as an extra parent and clear the merge state, as `git commit` does.
|
git merge needs user.name and user.email. CI has none, so the merge stopped before writing MERGE_HEAD and the test never saw a merge.
This branch has not been deployed
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.
Description
After a conflicted merge is resolved and staged,
git_commitcreated a commit with onlyHEADas its parent and leftMERGE_HEADbehind. The merged branch's history was silently dropped from the result, andgit_statusstill reported "All conflicts fixed but you are still merging".git_commitnow usesMERGE_HEADas an extra parent when it exists and clears the merge state, asgit commitdoes.Server Details
git_commit)Motivation and Context
repo.index.commit(message)ignores an in-progress merge. An agent that resolves a conflict and commits through the server ends up with a linear commit instead of a merge commit.How Has This Been Tested?
test_git_commit_concludes_a_mergecreates a real conflict, resolves it and callsgit_commit; it fails on main (one parent) and passes here.MERGE_HEADis gone.uv run pytest,ruff checkandpyrightpass.Breaking Changes
None.
Types of changes
Checklist