From 2292e1cebe558ff3eede506668df86a83f65f09f Mon Sep 17 00:00:00 2001 From: Richard Fearn Date: Sat, 19 Nov 2016 17:07:29 +0000 Subject: [PATCH] git-sed: use "git grep -z" and "xargs -0" to cope with spaces in filenames Otherwise filenames with spaces result in errors: $ cat "file with spaces in name" old $ git sed old new sed: can't read file: No such file or directory sed: can't read with: No such file or directory sed: can't read spaces: No such file or directory sed: can't read in: No such file or directory sed: can't read name: No such file or directory --- bin/git-sed | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/git-sed b/bin/git-sed index 7c6625332..9ba4f81e3 100755 --- a/bin/git-sed +++ b/bin/git-sed @@ -64,6 +64,6 @@ actual command: shift done -command="git grep -l '$search' | xargs sed -i 's/$search/$replacement/$flags'" -git grep -l "$search" | xargs sed -i "s/$search/$replacement/$flags" +command="git grep -lz '$search' | xargs -0 sed -i 's/$search/$replacement/$flags'" +git grep -lz "$search" | xargs -0 sed -i "s/$search/$replacement/$flags" do_commit