Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa Adatta ai principianti
#5,012 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Il bug si trova in src/git/src/mcp_server_git/server.py, dove git_commit chiama repo.index.commit() senza gestire lo stato di merge. Inizia esaminando quella funzione e la firma di IndexFile.commit() di GitPython. Quando esiste MERGE_HEAD, leggi i suoi commit e passali come parent_commits, quindi cancella MERGE_HEAD, MERGE_MSG e MERGE_MODE. Aggiungi un test nella suite di test di git che esegue un merge con --no-commit, chiama git_commit e verifica che ci siano due genitori e nessuno stato di merge rimasto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
91k
Fork
11.8k
Merge medio
6h 47m
PR unite (30g)
74

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/servers

Tutte le issue di modelcontextprotocol/servers

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.