git-wad

Manage files via git but not their content
git clone git://git.meso-star.fr/git-wad.git
Log | Files | Refs | README | LICENSE

commit 3544ac8520f181eaea8b0bbf932b4757121d201b
parent e76dcc7a18f9265c93afb069869f4022ea0758ab
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  5 Mar 2025 17:10:09 +0100

Fix problems with file names containing "special" chars

File names containing spaces or UTF-8 characters were not correctly
handled. The status subcommand was displaying several errors and the
checkout subcommand was also failing. As a result, this commit
introduces several changes to make the way file names are handled
internally more robust.

Diffstat:
Mgit-wad | 30++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/git-wad b/git-wad @@ -146,16 +146,16 @@ wad_paths() hashes="${git_wad_tmpdir}/hashes" wad_hashes | sort -b > "${hashes}" - # Lists the current tree - # | Replace tabs by spaces (see git-ls-tree(1) for output format) + # Lists the current tree. Ensure verbatim filename (-z option) + # | Ensure one entry per line (see the output section of git-ls-tree(1)) # | Print only the hash and path of listed files # | Sort the result in ascending order # | Print path for WAD files only - git ls-tree -r HEAD "${working_tree}" \ - | tr__ ' ' ' ' \ - | cut -d' ' -f3,4 \ + git ls-tree -zr HEAD "${working_tree}" \ + | tr__ '\0' '\n' \ + | cut -d' ' -f3- \ | sort -b \ - | join -o 2.2 "${hashes}" - + | join -t' ' -o 2.2 "${hashes}" - } # List WAD objects from the current working tree @@ -560,7 +560,14 @@ checkout() restore_init - git ls-files "${working_tree}" \ + # Lists the files. Ensure verbatim filename (-z option) + # | Ensure one entry per line (see the output section of git-ls-tree(1)) + # | Protect all characters in preparation for using xargs + # | Retain only unresolved WAD file + # | Restore content + git ls-files -z "${working_tree}" \ + | tr__ '\0' '\n' \ + | sed 's/./\\&/g' \ | xargs grep -le "^${GIT_WAD_HEADER} [0-9a-z]\{64\} [0-9]\{1,\}$" \ | while read -r i; do restore "${i}" @@ -641,7 +648,8 @@ status() # [-1a] # List resolved WADs, if any if [ -s "${resolved}" ]; then printf "Resolved WADs:\n" - sort "${resolved}" | xargs -I{} printf "\t\e[0;32m%s\e[0m\n" {} + sort "${resolved}" | sed 's/./\\&/g' \ + | xargs -I{} printf "\t\e[0;32m%s\e[0m\n" {} printf "\n" fi @@ -649,7 +657,8 @@ status() # [-1a] if [ -s "${unrestored}" ]; then printf "Unrestored WADs:\n" printf " (use \"git wad checkout\" to restore WADs)\n" - sort "${unrestored}" | xargs -I {} printf "\t\e[0;33m%s\e[0m\n" {} + sort "${unrestored}" | sed 's/./\\&/g' \ + | xargs -I {} printf "\t\e[0;33m%s\e[0m\n" {} printf "\n" fi @@ -657,7 +666,8 @@ status() # [-1a] if [ -s "${orphaned}" ]; then printf "Orphaned WADs:\n" printf " (use \"git wad pull\" to download and restore WADs)\n" - sort "${orphaned}" | xargs -I {} printf "\t\e[0;31m%s\e[0m\n" {} + sort "${orphaned}" | sed 's/./\\&/g' \ + | xargs -I {} printf "\t\e[0;31m%s\e[0m\n" {} printf "\n" fi