Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng Phù hợp với người mới
#5,012 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Lỗi nằm ở src/git/src/mcp_server_git/server.py, nơi git_commit gọi repo.index.commit() mà không xử lý trạng thái merge. Bắt đầu bằng cách kiểm tra hàm đó và chữ ký của IndexFile.commit() trong GitPython. Khi MERGE_HEAD tồn tại, đọc các commit của nó và truyền chúng dưới dạng parent_commits, sau đó xóa MERGE_HEAD, MERGE_MSG và MERGE_MODE. Thêm một bài kiểm tra trong bộ kiểm tra git thực hiện merge với tùy chọn --no-commit, gọi git_commit và kiểm tra xem có hai cha và không còn trạng thái merge nào không.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
91k
Fork
11.8k
Merge trung bình
6 giờ 47 phút
Pull request đã merge (30 ngày)
74

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/servers

Tất cả issue của modelcontextprotocol/servers

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.