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

git: git_create_branch is marked non-destructive but silently resets an existing packed branch

Aperta Adatta ai principianti
#5,059 1 commento 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
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
git, python
Ambito
tooling

Direzione di ricerca

Parti da src/git/src/mcp_server_git/server.py: l'handler git_create_branch (intorno a L183-L195) e il suo blocco di annotazione (L396-L404). Riproduci il problema con il repo temporaneo pack-refs dell'issue, quindi aggiungi un controllo del branch esistente prima di repo.create_head in modo che i ref packati vengano rifiutati (o autorizzati tramite un argomento force esplicito), e regola di conseguenza destructiveHint. L'issue è risolta quando un branch packato non viene più spostato silenziosamente e i test del server git passano.

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

Descrizione

Summary

git_create_branch is annotated destructiveHint: false, but if a branch with the requested name already exists as a packed ref (as after git gc, git pack-refs, or in a fresh clone), the call silently moves that branch to the new base. The previous tip becomes unreachable from every ref, and no reflog entry records the reset. git branch <name> on the CLI would refuse.

Where

Reproduce

  1. In a scratch repo: create main, then a branch feature with one extra commit, and run git pack-refs --all.
  2. Start the git server on that repo.
  3. Call git_create_branch with {"repo_path": "<repo>", "branch_name": "feature", "base_branch": "main"}.
  4. The call reports Created branch 'feature' from 'main'; feature now points at main, its previous commit is unreachable, and git reflog show feature has no entry for the move.

Why it matters

MCP clients relax confirmation for tools that declare destructiveHint: false, so this call can be auto-approved, and it can discard commits.

Possible fix

Check for an existing branch (loose or packed) and return an error, or require an explicit force argument, matching the git CLI. While a force path exists, destructiveHint: true would be accurate.

Found during an audit of MCP tool annotations (AI-assisted source review, then reproduced locally). Happy to send a PR.

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

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.