Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

git_commit during a merge records one parent and leaves MERGE_HEAD in place

クローズ 初心者向け
#5,012 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

バグは src/git/src/mcp_server_git/server.py に存在し、git_commit がマージ状態を処理せずに repo.index.commit() を呼び出していることが原因です。まず当該関数とGitPythonの IndexFile.commit() のシグネチャを確認してください。MERGE_HEAD が存在する場合は、そのコミットを読み取って parent_commits として渡し、その後 MERGE_HEAD、MERGE_MSG、MERGE_MODE をクリアしてください。gitテストスイートに、--no-commit オプションでマージを実行し git_commit を呼び出して、2つの親が存在しマージ状態が残存しないことをアサートするテストを追加してください。

索引モデルが issue の本文から書いたものです。

説明

bug server-git v2
Describe the bug

git_commit cannot conclude a merge. While a merge is in progress (MERGE_HEAD present, e.g. after git merge --no-commit or a resolved conflict), it writes a commit with one parent, HEAD, and leaves MERGE_HEAD (and MERGE_MSG) in place, so the repository stays in merge state and the merged branch's history is not recorded.

src/git/src/mcp_server_git/server.py, git_commit calls repo.index.commit(message). GitPython's IndexFile.commit() takes parent_commits=None, which means [repo.head.commit] only; it neither reads nor clears MERGE_HEAD.

Found in the Copilot review of #5007 (the fix for #4762), which keeps the empty-merge-commit case committable but, like the code before it, records it with one parent. This predates #5007: any merge resolved through git_commit has always been recorded this way.

To Reproduce
import git
# repo on main with a branch `side` that adds side.txt
repo.git.merge("side", "--no-commit", "--no-ff")
commit = repo.index.commit("merge side")   # what git_commit does
len(commit.parents)                        # 1, git commit would give 2
(Path(repo.git_dir) / "MERGE_HEAD").exists()  # True, merge still in progress
Expected behavior

While MERGE_HEAD is present, git_commit records HEAD plus every MERGE_HEAD commit as parents and clears the merge state, as git commit does (either by shelling out to git commit, or by passing parent_commits and removing MERGE_HEAD/MERGE_MSG/MERGE_MODE). A test asserts both parents and that MERGE_HEAD is gone.

Additional context

Related: #659 (a git_merge tool), which would make this path reachable from the server alone.

主要言語
TypeScript
スター
91k
フォーク
11.8k
平均マージ
6時間 47分
マージ済み PR(30日)
74

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/servers のほかの issue

modelcontextprotocol/servers の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。