overcommit --run skips Git-quoted filenames with include filters
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with GitRepo.all_files in lib/overcommit/git_repo.rb around lines 138-143, which splits both git ls-files and git ls-files --deleted output on newlines. Reproduce with the scratch-repo steps in the issue, using a filename such as café.rb under core.quotePath=true, then check whether the TrailingWhitespace hook reports a failure. Done means NUL-delimited parsing for both lists, with regression specs covering Unicode, quoted, control-character, nested, deleted, untracked, empty-index and broken-symlink paths.
索引モデルが issue の本文から書いたものです。
説明
Reproduced on current main 50f3e866bef75e3c3be7f92b47b1c45b6e7436ba (0.74.0), macOS 15.6.1, Ruby 4.0.7, Apple Git 2.50.1.
With Git's default core.quotePath=true, GitRepo.all_files returns the quoted/escaped output of git ls-files rather than actual paths. When a hook has an include pattern such as **/*.rb, those paths no longer match, and overcommit --run can report success without checking a tracked file.
Reproduction
Use a scratch repository, not an existing project:
mkdir overcommit-path-repro
cd overcommit-path-repro
git init
git config --local user.name 'Local Fixture'
git config --local user.email '[email protected]'
git config --local commit.gpgsign false
git config --local core.hooksPath /dev/null
git config --local core.quotePath true
git commit --allow-empty -m 'Initial fixture'
cat > .overcommit.yml <<'YAML'
PreCommit:
ALL:
enabled: false
TrailingWhitespace:
enabled: true
on_warn: fail
include:
- '**/*.rb'
YAML
overcommit --sign
printf 'puts "fixture" \n' > normal.rb
git add -- normal.rb
overcommit --run
# TrailingWhitespace FAILED; exit 65.
git mv -- normal.rb 'café.rb'
overcommit --run
# All pre-commit hooks passed; exit 0. The content is unchanged.
git config --local core.quotePath false
overcommit --run
# TrailingWhitespace FAILED again; exit 65.
The same false-success result occurs for filenames containing double quotes, tabs, or newlines. core.quotePath=false is a control for the Unicode case, not a general workaround for those other characters.
Scope
GitRepo.all_files in lib/overcommit/git_repo.rb:138-143 splits both git ls-files and git ls-files --deleted on newlines. Using NUL-delimited output for both lists would avoid interpreting Git's C-style filename quoting while retaining the deleted-file filtering added in #905.
This behavior predates #905; I am not reporting it as a regression from that PR. The older #220/#222 discussion concerned a repository root containing spaces and list_files. I reproduced this with the repository root itself containing a space, and ordinary space-containing basenames still work.
The regression cases should include live Unicode/quoted/control-character paths, a nested Unicode path, unstaged deletions, an empty index, untracked files, and a tracked broken symlink. The broken symlink must remain visible to the BrokenSymlinks hook.
Would a small all_files parsing fix with these tests be welcome? I would leave other Git helpers, command execution, and index-error handling out of this change.
- 主要言語
- Ruby
- スター
- 4k
- フォーク
- 288
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 18
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sds/overcommit のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
sds/overcommit#909 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
sds/overcommit#847 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
sds/overcommit#875 ·
メンテナーはふだん 1 日以内に返信
-
help wanted
難易度 4/5 3〜5日 初心者へのやさしさ 18/100
sds/overcommit#869 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 半日 初心者へのやさしさ 25/100
sds/overcommit#856 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
seek4science/seek#2784 ·
メンテナーはふだん 2 日以内に返信
-
Translation tutorial: snippet crashes on chunks export and misses simple { t } entries対応中かも @Mahdi-Hasan が今日担当しました。 オープンresource-documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
TarteelAI/quranic-universal-library#1020 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Records without the CRI logtag raise NoMethodError and are joined into the next record対応中かも @nazarli-shabnam が今日担当しました。 オープンbug help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
swombat/souls-house#842 ·
メンテナーはふだん 1 日以内に返信