git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Next: Junio C Hamano
Message 1 of 4 in “filenames with " b" in them create confusing git diff-tree output”
  1. Paul MackerrasJun 20, 2007
  2. Junio C HamanoJun 20, 2007
  3. Linus TorvaldsJun 20, 2007
  4. Junio C HamanoJun 20, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.