Skip to content

Commit 1c9b277

Browse files
committed
terminate filenames with NUL, not LF
1 parent 18e19ba commit 1c9b277

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

scripts/githooks/check-file-format.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
107110
function list-files-to-check--all() {
108-
git ls-files
111+
git ls-files -z
109112
}
110113

111114
function 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

115118
function 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

119122
function 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

Comments
 (0)