From: Jakub Narebski <jnareb@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [BUG/RFC] Raw diff output format (git-diff-tree) and --relative[=<path>] option
Date: Thu, 8 Jul 2010 16:56:20 +0200 [thread overview]
Message-ID: <201007081656.23474.jnareb@gmail.com> (raw)
In-Reply-To: <20100708142341.GA9991@coredump.intra.peff.net>
On Thu, 8 Jul 2010, Jeff King wrote:
> On Thu, Jul 08, 2010 at 02:19:42PM +0200, Jakub Narebski wrote:
>
> > Nevertheless for the patch output format both "git diff --relative=sub"
> > and "git diff --relative=sub/" give the same output, without 'b//quux'.
> > The same IMHO should be done for raw output format, so we don't have
> > '/quux' but 'quux'.
>
> Hmm. That is because the diff output properly eliminates the double "/".
> But AFAICT, all of the following do what I would expect:
>
> git diff --relative=sub
> git diff --relative=sub/ ;# same as above
> git diff --relative=foo- ;# yields "a/10" for file "foo-10"
>
> Doing
>
> git diff --relative=sub --stat
>
> shows the same issue as your --raw version, as does --name-only. I think
> the right solution is to clean up a leading "/" for those cases. That
> leaves the possibility for non-directory prefixes, but should do what
> the user wants in the directory case (since a leading "/" is
> nonsensical).
Perhaps this would be enough:
-- >8 --
diff --git i/diff.c w/diff.c
index 3aa695d..3a4696e 100644
--- i/diff.c
+++ w/diff.c
@@ -2705,10 +2705,16 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
static void strip_prefix(int prefix_length, const char **namep, const char **otherp)
{
/* Strip the prefix but do not molest /dev/null and absolute paths */
- if (*namep && **namep != '/')
+ if (*namep && **namep != '/') {
*namep += prefix_length;
- if (*otherp && **otherp != '/')
+ if (**namep == '/')
+ ++*namep;
+ }
+ if (*otherp && **otherp != '/') {
*otherp += prefix_length;
+ if (**otherp == '/')
+ ++*otherp;
+ }
}
static void run_diff(struct diff_filepair *p, struct diff_options *o)
-- 8< --
>
> Or was that what you had in mind the whole time? My impression was that
> you wanted --relative=foo to always be equivalent to --relative=foo/.
> The subtle difference is that I want the "/" removed only if it is the
> next character (or another way of thinking about it is to append "/" to
> the prefix only if it is an actual directory).
What I wanted is for "git diff-tree A B --relative=sub" to behave as
"git diff-tree A:sub B:sub". Currently without -r / -t (without turning
on recursive mode) it produces no output; well at least no output if
'sub' is really subdirectory.
What's more I wanted for "git diff --raw" in any combination to behave
the same... although I guess here point is moot, as "git diff" is
automatically recursive regardless of output format, and you can't turn
it off.
Stil I'd like for "git diff-tree <commit>" to behave appropriately
with --relative or --relative=<path>.
--
Jakub Narebski
Poland
next prev parent reply other threads:[~2010-07-08 14:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-05 8:15 [BUG] Spurious leading '/' in filename in "git diff --raw --relative=<subdirectory>" Jakub Narebski
2010-07-05 15:44 ` Jakub Narebski
2010-07-08 11:00 ` [BUG/RFC] Raw diff output format (git-diff-tree) and --relative[=<path>] option Jakub Narebski
2010-07-08 11:41 ` Jeff King
2010-07-08 12:11 ` Jakub Narebski
2010-07-08 12:19 ` Jakub Narebski
2010-07-08 14:23 ` Jeff King
2010-07-08 14:56 ` Jakub Narebski [this message]
2010-08-09 14:50 ` Jeff King
2010-08-09 14:59 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201007081656.23474.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.