From: Matt McClure <matthewlmcclure@gmail.com>
To: John Keeping <john@keeping.me.uk>
Cc: Junio C Hamano <gitster@pobox.com>,
David Aguilar <davvid@gmail.com>,
"git@vger.kernel.org" <git@vger.kernel.org>,
Tim Henigan <tim.henigan@gmail.com>
Subject: Re: difftool -d symlinks, under what conditions
Date: Tue, 12 Mar 2013 18:11:14 -0400 [thread overview]
Message-ID: <CAJELnLGenaFR1zeq=+2Ed6CCbog7q9aFm=B4PN2poJVhGxLBww@mail.gmail.com> (raw)
In-Reply-To: <CAJELnLGBr1wOX4-3rCNjPpPLezc_6FgyeuPqty268JR0==qtvQ@mail.gmail.com>
On Tue, Mar 12, 2013 at 5:43 PM, Matt McClure <matthewlmcclure@gmail.com> wrote:
> On Tue, Mar 12, 2013 at 5:06 PM, John Keeping <john@keeping.me.uk> wrote:
>>
>> is it sufficient to say
>> "there is no more than one non-option to the left of '--' and '--cached'
>> is not among the options"?
>
> An alternative approach would be to reuse git-diff's option parsing
> and make it tell git-difftool when git-diff sees the working tree
> case. At this point, I haven't seen an obvious place in the source
> where git-diff makes that choice, but if someone could point me in the
> right direction, I think I'd actually prefer that approach. What do
> you think?
There's an interesting comment in cmd_diff:
/*
* We could get N tree-ish in the rev.pending_objects list.
* Also there could be M blobs there, and P pathspecs.
*
* N=0, M=0:
* cache vs files (diff-files)
* N=0, M=2:
* compare two random blobs. P must be zero.
* N=0, M=1, P=1:
* compare a blob with a working tree file.
*
* N=1, M=0:
* tree vs cache (diff-index --cached)
*
* N=2, M=0:
* tree vs tree (diff-tree)
*
* N=0, M=0, P=2:
* compare two filesystem entities (aka --no-index).
*
* Other cases are errors.
*/
whereas inspecting rev.pending in the "compare against working tree"
case, I see:
(gdb) p rev.pending
$3 = {
nr = 1,
alloc = 64,
objects = 0x100807a00
}
(gdb) p *rev.pending.objects
$4 = {
item = 0x100831a48,
name = 0x7fff5fbff8f8 "HEAD^",
mode = 12288
}
Given the cases listed in the comment, I assume cmd_diff must
interpret this case as:
* N=1, M=0:
* tree vs cache (diff-index --cached)
The description of that case is confusing or wrong given that
git-diff-index(1) says:
--cached
do not consider the on-disk file at all
***
cmd_diff executes this case:
else if (ents == 1)
result = builtin_diff_index(&rev, argc, argv);
So it looks like I could short-circuit in builtin_diff_index or
something it calls -- e.g., run_diff_index -- to get git-diff to tell
git-difftool that it's the working tree case. I see that
run_diff_index does:
diff_set_mnemonic_prefix(&revs->diffopt, "c/", cached ? "i/" : "w/");
So that looks like a good place where the code is already deciding
that it's the working tree case -- "w/", though surprisingly to me:
(gdb) p revs->diffopt
$12 = {
...
a_prefix = 0x1001c25aa "a/",
b_prefix = 0x1001c25ad "b/",
...
So diff_set_mnemonic_prefix doesn't actually use the "w/" value passed
to it because:
if (!options->b_prefix)
options->b_prefix = b;
Maybe if I could prevent b_prefix from getting set earlier, I could
get some variant of git-diff to emit the "w/" for git-difftool.
--
Matt McClure
http://www.matthewlmcclure.com
http://www.mapmyfitness.com/profile/matthewlmcclure
next prev parent reply other threads:[~2013-03-12 22:11 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-26 20:23 difftool -d symlinks, under what conditions Matt McClure
2012-11-27 6:20 ` David Aguilar
2012-11-27 21:10 ` Matt McClure
[not found] ` <CAJELnLEL8y0G3MBGkW+YDKtVxX4n4axJG7p0oPsXsV4_FRyGDg@mail.gmail.com>
2013-03-12 18:12 ` Matt McClure
2013-03-12 19:09 ` John Keeping
2013-03-12 19:23 ` David Aguilar
2013-03-12 19:43 ` John Keeping
2013-03-12 20:39 ` Junio C Hamano
2013-03-12 21:06 ` John Keeping
2013-03-12 21:26 ` Junio C Hamano
2013-03-12 21:43 ` Matt McClure
2013-03-12 22:11 ` Matt McClure [this message]
2013-03-12 22:16 ` Junio C Hamano
2013-03-12 22:48 ` Matt McClure
2013-03-13 0:17 ` John Keeping
2013-03-13 0:56 ` Matt McClure
2013-03-13 8:24 ` David Aguilar
2013-03-13 15:30 ` Junio C Hamano
2013-03-13 16:45 ` Junio C Hamano
2013-03-13 17:08 ` John Keeping
2013-03-13 17:40 ` Junio C Hamano
2013-03-13 18:01 ` John Keeping
2013-03-13 19:28 ` Junio C Hamano
2013-03-13 20:33 ` [PATCH 0/2] difftool --dir-diff: symlink all files matching the working tree John Keeping
2013-03-13 20:33 ` [PATCH 1/2] git-difftool(1): fix formatting of --symlink description John Keeping
2013-03-13 20:33 ` [PATCH 2/2] difftool --dir-diff: symlink all files matching the working tree John Keeping
2013-03-14 3:41 ` David Aguilar
2013-03-14 9:36 ` John Keeping
2013-03-14 15:18 ` Junio C Hamano
2013-03-14 20:19 ` [PATCH v2 0/3] " John Keeping
2013-03-14 20:19 ` [PATCH v2 1/3] git-difftool(1): fix formatting of --symlink description John Keeping
2013-03-14 20:19 ` [PATCH v2 2/3] difftool: avoid double slashes in symlink targets John Keeping
2013-03-14 21:19 ` Junio C Hamano
2013-03-14 20:19 ` [PATCH v2 3/3] difftool --dir-diff: symlink all files matching the working tree John Keeping
2013-03-14 21:28 ` Junio C Hamano
2013-03-14 22:24 ` John Keeping
2013-03-14 22:31 ` Junio C Hamano
2013-03-14 9:43 ` difftool -d symlinks, under what conditions John Keeping
2013-03-14 17:25 ` John Keeping
2013-03-14 17:33 ` Junio C Hamano
2013-03-14 20:00 ` [PATCH 0/2] checkout-index: fix .gitattributes handling with --prefix John Keeping
2013-03-14 20:00 ` [PATCH 1/2] t2003: modernize style John Keeping
2013-03-14 20:00 ` [PATCH 2/2] entry: fix filter lookup John Keeping
2013-03-14 21:50 ` Junio C Hamano
2013-03-12 20:38 ` difftool -d symlinks, under what conditions Junio C Hamano
2013-03-12 19:24 ` [PATCH] difftool: Make directory diff symlink work tree John Keeping
2013-03-12 23:12 ` Matt McClure
2013-03-12 23:40 ` John Keeping
2013-03-13 0:26 ` Matt McClure
2013-03-13 9:11 ` John Keeping
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJELnLGenaFR1zeq=+2Ed6CCbog7q9aFm=B4PN2poJVhGxLBww@mail.gmail.com' \
--to=matthewlmcclure@gmail.com \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=john@keeping.me.uk \
--cc=tim.henigan@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).