git_commit during a merge records one parent and leaves MERGE_HEAD in place
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
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ả
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
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/servers
-
mcp-server-fetch: `fetch` prompt returns JSON-RPC error code 0 with the raw exception text for an invalid URLCó thể đã có người làm @DawnofGenX đã nhận 6 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/servers#4914 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CLAUDE.md: tool-naming rule (kebab-case) disagrees with filesystem and memory serversCó thể đã có người làm @liang0417 đã nhận 7 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
modelcontextprotocol/servers#4892 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Filesystem README recommends deprecated MCP Roots protocol for restricting directory accessCó thể đã có người làm @its-amann đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
modelcontextprotocol/servers#4844 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docs: `fetch` installs npm packages during a tool call, which is worth stating for deploymentsCó thể đã có người làm @teddiesloco đã nhận 16 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/servers#4830 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docs: tool descriptions for browser-embedding servers do not mention the browser's own background trafficCó thể đã có người làm @AbhiPra24 đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modelcontextprotocol/servers#4829 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/servers
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
umbraco/Umbraco-CMS-MCP-Dev#512 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
wimpysworld/sidra#290 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
defuFn invokes function values for inherited default propertiesCó thể đã có người làm @xiehuanyi đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
feature request good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
TabularisDB/tabularis#853 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 85/100
capricorn86/happy-dom#2474 ·
Maintainer thường phản hồi trong vòng 2 ngày