@@ -71,7 +71,7 @@ function main-invocation() {
7171 # 2MB on Linux but only 256KB on macOS. Assume a maximum filename
7272 # length of 200 characters and limiting us to batches of 1000 files
7373 # gives us a bit of a safety margin.
74- dry_run_opt=" ${dry_run_opt:- } " xargs --max-args=1000 --no-run-if-empty scripts/githooks/check-file-format.sh " $method "
74+ dry_run_opt=" ${dry_run_opt:- } " xargs -0 - -max-args=1000 --no-run-if-empty scripts/githooks/check-file-format.sh " $method "
7575}
7676
7777# Run editorconfig natively.
@@ -104,20 +104,23 @@ function main-tool-wrapper--via-docker() {
104104
105105# ==============================================================================
106106
107+ # These all produce filenames terminated by a NUL character, so that we
108+ # can handle filenames that contain spaces.
109+
107110function list-files-to-check--all() {
108- git ls-files
111+ git ls-files -z
109112}
110113
111114function list-files-to-check--staged-changes() {
112- git diff --diff-filter=ACMRT --name-only --cached
115+ git diff -z - -diff-filter=ACMRT --name-only --cached
113116}
114117
115118function list-files-to-check--working-tree-changes() {
116- git diff --diff-filter=ACMRT --name-only
119+ git diff -z - -diff-filter=ACMRT --name-only
117120}
118121
119122function list-files-to-check--branch() {
120- git diff --diff-filter=ACMRT --name-only ${BRANCH_NAME:- origin/ main}
123+ git diff -z - -diff-filter=ACMRT --name-only ${BRANCH_NAME:- origin/ main}
121124}
122125
123126# ==============================================================================
0 commit comments