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

[BUG] Spurious leading '/' in filename in "git diff --raw --relative=<subdirectory>"

From
Jakub Narebski <jnareb@gmail.com>
Date
Jul 5, 2010, 08:15 UTC
Message-ID
<201007051015.26995.jnareb@gmail.com>

I wanted to get non-recursive raw diff (difftree), but for a given subdirectory and not starting from root.

I have found '--relative[=<path>]', introduced in 
  c0cb4a0 (diff --relative: help working in a bare repository, 2008-02-13)
  cd676a5 (diff --relative: output paths as relative to the current subdirectory, 2008-02-12)

But when examining it's output in 'raw' mode, I have notice spurious leading '/' in filename:

  $ git diff-tree --abbrev -r --raw HEAD --relative=sub
  a3a8425fe5496c61921010cb1e7b455a1f52bb86
  :100644 100644 d90bda0... cefcae0... M	/quux
The output without '-r' (recurse into sub-trees) is even more strange
  $ git diff-tree --abbrev --raw HEAD --relative=sub
  a3a8425fe5496c61921010cb1e7b455a1f52bb86
  :040000 040000 e62aa6e... b5d4a43... M	
(that's a trailing TAB, and no filename).
What I expected was the following output:
  $ git diff-tree --abbrev --raw HEAD --relative=sub
  a3a8425fe5496c61921010cb1e7b455a1f52bb86
  :040000 040000 e62aa6e... b5d4a43... M	quux

I see that the '--relative' and '--relative=<path>' options were introduced for patch ('-p') format, and not for difftree / raw format, but I think they should work for it, too.

P.S. I have noticed this bug when working on proof-of-concept tree-blame (i.e. when given file was modified) in Perl.

-- 
Jakub Narebski
Poland
Next: Jakub Narebski
Message 1 of 10 in “[BUG] Spurious leading '/' in filename in "git diff --raw --relative=<subdirectory>"”
  1. Jakub NarebskiJul 5, 2010
  2. Jakub NarebskiJul 5, 2010
  3. [BUG/RFC] Raw diff output format (git-diff-tree) and --relative[=<path>] optionJakub Narebski, Jul 8, 2010
  4. Jeff KingJul 8, 2010
  5. Jakub NarebskiJul 8, 2010
  6. Jakub NarebskiJul 8, 2010
  7. Jeff KingJul 8, 2010
  8. Jakub NarebskiJul 8, 2010
  9. Jeff KingAug 9, 2010
  10. Jeff KingAug 9, 2010

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.