This is more an idle curiosity question but I've just discovered that Git adds TABs to the names of files containing spaces in git-diff output. E.g.
$ git init test
$ cd test
$ echo 'test' > 'file with spaces'
$ git add .
$ git commit -m 'Add'
$ git show | grep '<literal-TAB-here>' | od -c
0000000 + + + b / f i l e w i t h
0000020 s p a c e s \t \n
0000030
Why does it do this and is there some way to prevent this from happening? Using -z option and/or setting core.quotepath = false doesn't change this behaviour.
git diffandgit statusandgit showare "porcelain", human-convenience commands with output that's been postprocessed for human consumption. I expect the tab is there as a separator for notes that turn out to be empty here.If you want the just-the-facts-ma'am diff, use the core command, the "plumbing":
where
-psays you want the patch, not just differing ids, and@is there because core commands have very few defaults, you say exactly what you want and they do that. For instance,git diffnotices if you're diffing a root commit and supplies an ersatz empty base tree to diff against, for your example situation, a root commit, with nothing to compare against, you actually have to supply an empty tree to compare against:(personally I think
git diff-treeshould have supplied an empty parent to diff against for root commits automatically, the waygit diffdoes, but it's waayyyyy too late to change that now, because production scripts are allowed to rely on the exact behavior of core commands).