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

Re: [BUG/RFC] Raw diff output format (git-diff-tree) and --relative[=<path>] option

From
Jakub Narebski <jnareb@gmail.com>
Date
Jul 8, 2010, 12:11 UTC
Message-ID
<201007081411.14843.jnareb@gmail.com>
In-Reply-To
<20100708114125.GA2427@sigill.intra.peff.net>
On Thu, 8 Jul 2010, Jeff King wrote:
Show 19 quoted lines
> On Thu, Jul 08, 2010 at 01:00:17PM +0200, Jakub Narebski wrote:
> 
> > Last there is filename munging, done using strip_prefix function.
> > This is done using prefix_length only, and that is the cause of
> > the bug:
> >   $ git diff-tree --abbrev -r --raw HEAD --relative=sub
> >   a3a8425fe5496c61921010cb1e7b455a1f52bb86
> >   :100644 100644 d90bda0... cefcae0... M	/quux
> > 
> > if one uses '--relative=sub' instead of '--relative=sub/'.
> 
> Is that a bug or a feature? You need to say "sub/" to get what you want,
> which is annoying. But it means you can also you "--relative=su" to get
> "b/quux". In that example, it's probably useless, but consider a set of
> filenames "foo-1" through "foo-5". You don't always want to break on a
> directory boundary.
> 
> I believe "git-archive --prefix" has the same behavior for the same
> reason.

It is called --relative=<path>, *not* --relative=<prefix>. I also think that it was meant to be the opposite of --directory=<root> of git-am and git-apply.

"git archive --prefix" is IMVHO a bit of horse of different color.

Nevertheless in current situation it would be good to have the following applied. -- >8 --

diff --git i/Documentation/diff-options.txt w/Documentation/diff-options.txt
index 2371262..bc837cd 100644
--- i/Documentation/diff-options.txt
+++ w/Documentation/diff-options.txt
@@ -278,7 +278,7 @@ ifndef::git-format-patch[]
 	Swap two inputs; that is, show differences from index or
 	on-disk file to tree contents.
 
---relative[=<path>]::
+--relative[=<path>/]::
 	When run from a subdirectory of the project, it can be
 	told to exclude changes outside the directory and show
 	pathnames relative to it with this option.  When you are
-- 8< --
-- 
Jakub Narebski
Poland
Previous: Jeff KingNext: Jakub Narebski
Message 5 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.