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

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

オープン 初心者向け
#5,059 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

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

調査の方向性

src/git/src/mcp_server_git/server.py を起点にする:git_create_branch ハンドラー(L183-L195 あたり)とそのアノテーションブロック(L396-L404)。issue の pack-refs 用スクラッチリポジトリで問題を再現し、その後 repo.create_head の前に既存ブランチのチェックを追加して、packed refs が拒否されるようにする(または明示的な force 引数の背後でガードする)。そして destructiveHint をそれに合わせて調整する。packed ブランチが黙って移動されなくなり、git サーバーのテストが通ることで完了。

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

説明

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.

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

環境構築

はじめの一歩

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

modelcontextprotocol/servers のほかの issue

modelcontextprotocol/servers の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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