Fix metadata hook script to support non-ascii characters

tips/automatically_adding_metadata/pre-commit-annex: Fix to not silently
skip filenames containing non-ascii characters.

git diff-index defaults to munging non-ascii characters. Using -z makes
it not do that, and then we just change the nulls to newlines.

This commit was sponsored by Jochen Bartl on Patreon.
This commit is contained in:
Joey Hess 2018-02-26 12:58:37 -04:00
parent 48819cb92b
commit 42f154bd7e
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 6 additions and 1 deletions

View file

@ -28,6 +28,8 @@ git-annex (6.20180113) UNRELEASED; urgency=medium
and the destination subdirectory does not exist yet.
* Added annex.merge-annex-branches config setting which
can be used to disable automatic merge of git-annex branches.
* tips/automatically_adding_metadata/pre-commit-annex: Fix to not
silently skip filenames containing non-ascii characters.
-- Joey Hess <id@joeyh.name> Wed, 24 Jan 2018 20:42:55 -0400

View file

@ -65,3 +65,6 @@ ok
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
git annex is great. :)
> [[fixed|done]]; caused by git diff-index defaulting to not emitting such
> characters, got it to by using -z. --[[Joey]]

View file

@ -112,7 +112,7 @@ if [ -n "$*" ]; then
process "$f"
done
else
git diff-index --name-only --cached $against | while read f; do
git diff-index -z --name-only --cached $against | sed 's/\x00/\n/g' | while read f; do
process "$f"
done
fi