filenames with " b" in them create confusing git diff-tree output
- From
Paul Mackerras <paulus@samba.org>
- Date
- Jun 20, 2007, 11:15 UTC
- Message-ID
- <18041.3163.329391.298926@cargo.ozlabs.ibm.com>
While trying to improve gitk's handling of filenames with spaces, I realised that the header line in git diff-tree's output can be inherently ambiguous, since it doesn't put quotes around filenames with spaces (although it does for filenames with other special characters in them).
For example:
paulus@quango:~/gitk/testrepo$ mkdir "test b" paulus@quango:~/gitk/testrepo$ cat >"test b/foo" stuff paulus@quango:~/gitk/testrepo$ git add "test b/foo" paulus@quango:~/gitk/testrepo$ git commit -a Created commit 71a3074: Add a "test b" directory 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 test b/foo paulus@quango:~/gitk/testrepo$ git diff-tree -r -p -C HEAD 71a3074e723c3e5eb599e6b3c47e3267a3cac3bc
diff --git a/test b/foo b/test b/foo new file mode 100644 index 0000000..f2e4113 --- /dev/null +++ b/test b/foo @@ -0,0 +1 @@ +stuff Note how there appear to be 4 filenames on the "diff --git" line. At present gitk will interpret that as a diff between "test" and "foo b/test b/foo", since it looks for " a/" and " b/" to delimit the filenames. Of course if the file got renamed it could get even more confusing. :) Would there be any ill effects from quoting filenames with spaces, do you think? It seems the simplest fix to me (and I will make gitk handle quoted filenames, which it doesn't at present :). Paul.