Code review: binary paths containing ` b/` are truncated and misclassified as renames

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

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

@Guihakka2 がすでに取り組んでいます。

2026年11月24日 から。

  • #3969 @Guihakka2 による — オープン

評価

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

調査の方向性

parseDiffGitHeader から始めます。これは packages/core/diff-paths.ts にあり、引用符で囲まれていない diff --git a/... b/... の正規表現がここにあります。次に、parseDiffToFiles での使用箇所を packages/core/diff-files.ts で追います。issue の bun repro-diff-path.ts スニペットを実行して、誤った icon.png/oldPath の出力を確認し、既存の diff テストの隣にパーサーテストを追加します。等しいパスのバイナリヘッダーが path: "assets b/icon.png" を oldPath なしで、ステータス modified で返し、引用符付きパスと実際の rename/copy ケースが引き続き通れば完了です。

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

説明

What happened?

A binary modification under a directory containing the literal sequence b/ is parsed with the wrong file identity and incorrectly classified as a rename. The existing file assets b/icon.png becomes path: "icon.png", with oldPath: "assets b/icon.png b/assets".

I reproduced this by calling the unmodified production parseDiffToFiles with actual git diff output from an isolated repository. A control file at assets/icon.png parses correctly. This verifies the parser; I have not run the browser UI or a packaged Plannotator binary.

Minimal reproduction

From a Plannotator checkout, save this as repro-diff-path.ts and run bun repro-diff-path.ts:

import { parseDiffToFiles } from './packages/core/diff-files';

const patch = [
  'diff --git a/assets b/icon.png b/assets b/icon.png',
  'index a4b2576..e98258d 100644',
  'Binary files a/assets b/icon.png and b/assets b/icon.png differ',
  '',
].join('\n');

console.log(parseDiffToFiles(patch).map(({ path, oldPath, status }) =>
  ({ path, oldPath, status })));

This is real Git output: create and commit a PNG at assets b/icon.png, change its binary bytes, then run git diff --no-ext-diff --no-textconv. Git leaves these space-containing paths unquoted in this header.

Actual result

[{"path":"icon.png","oldPath":"assets b/icon.png b/assets","status":"renamed"}]

Expected result

[{"path":"assets b/icon.png","status":"modified"}]

oldPath should be absent because the file was not renamed.

Source and impact
  • parseDiffGitHeader uses /^diff --git a\/(.+) b\/(.+)$/ for unquoted headers. The first greedy group consumes through the b/ inside the new-side path.
  • parseDiffToFiles has no ---/+++ or rename metadata to fall back to for this binary modification, so it propagates incorrect paths and derives renamed.
  • The code-review app uses this parser for its file list, and listPatchFiles uses it for the server's changed-file set. findPatchFileEntry also uses the same header parser. Downstream file identity/path lookup therefore receives a path that does not name the changed file. These downstream implications are based on source inspection, not a browser reproduction.

A fix should cover unquoted equal-path binary headers containing b/, while preserving quoted paths and genuine rename/copy handling. Simply making the regex non-greedy also needs care: b/ can occur in the old-side path too.

Related reports checked

I searched issues and PRs for the parser name, binary paths, whitespace and diff headers. #628 concerns quoted/non-ASCII headers and is closed; this reproduction uses an unquoted header and still fails on the checked main snapshot.

Plannotator version

Source checkout at 76cbbecf8bfe67ad1c3f8713c0c0907663710fd5 (package.json: 0.29.2). The same parser file was rechecked on main before filing.

OS

Windows. Verification runtime: Node.js v24.22.3 with native TypeScript support and an extension-resolution hook for the repo's extensionless import; Git 2.56.0.windows.2. The Bun snippet above is the equivalent maintainer-facing reproduction; the measured output was obtained with Node calling the original source functions.

Agent

None / standalone source-level reproduction

Where did it happen?

Code review — shared diff parser

Browser

Not used.

主要言語
TypeScript
スター
8.7k
フォーク
649
平均マージ
14時間 26分
マージ済み PR(30日)
772

環境構築

はじめの一歩

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

backnotprop/plannotator のほかの issue

backnotprop/plannotator の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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