Repository navigation
fix(effort, summary): count files with non-ASCII names - #1290
Conversation
| save_ifs=$IFS | ||
| IFS=$(echo -en "\n\b") | ||
| paths=($(git ls-files)) | ||
| paths=($(git -c core.quotepath=off ls-files)) |
There was a problem hiding this comment.
Maybe we can use mapfile -d '' -t paths < <(git -c core.quotepath=off ls-files -z), so it works with newlines?
There was a problem hiding this comment.
Done in 81a8d80: paths now come from mapfile -d '' -t paths < <(git ls-files -z). With -z git doesn't quote names, so core.quotepath isn't needed there. git-effort already needs bash 4.4 for ${nJobs@P}, so mapfile -d doesn't raise the floor. Added a test with a newline in a file name.
| # | ||
| lines() { | ||
| git ls-files -- "$@" | single_file | ||
| git -c core.quotepath=off ls-files -- "$@" | single_file |
There was a problem hiding this comment.
lines() now receives names from git ls-files -- "$@", but the output is read by single_file using while read -r data, which doesn't work with newline
There was a problem hiding this comment.
Fixed in 81a8d80: lines() uses git ls-files -z and single_file reads with while IFS= read -r -d '' data, which also works on bash 4.0. Added a test that counts a file with a newline in its name.
|
@jayhemnani9910 |
git effortleaves out files with non-ASCII names, andgit summary --linecounts no lines (and no author) for them. With the defaultcore.quotepath,git ls-filesprintsünï.txtas"\303\274n\303\257.txt", and that quoted name is passed on togit logandgit blame, which find no such file.Both commands now list files with
git -c core.quotepath=off ls-files, so the names come through as they are.Added
tests/git-effort.batsandtests/git-summary.bats; both fail without the change.bats ./testspasses.