From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] diff --no-index: allow pathspec after --
Date: Sat, 20 Sep 2014 23:19:19 -0700 [thread overview]
Message-ID: <xmqq38blmr6g.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <xmqqha04o8k7.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Thu, 18 Sep 2014 15:41:44 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Coming back to the command line syntax for the new feature, if I had
> to choose, I would say
>
> git diff --no-index [-<options>] [--] <path> <path> <pathspec>
>
> perhaps? As we never compare anything other than two things,...
Actually, I am not so sure about this anymore.
It is not entirely fair to say that
git diff --no-index [--options] A B C D
as comparing A and B while using C and D as pathspec and declare a
person who expects otherwise a moron. To a person whose brain is
not rotten by years of use of Git, "we never compare anything other
than two things with --no-index" is not a given, I am afraid.
It is equally plausible that the same command line may be asking to
compare A with B and C with D, i.e. producing
diff --no-git a/A b/B
...
diff --no-git a/C b/D
...
It also equally plausible (taking a cue from "mv A B C Dir/") that
it is comparing A, B and C with D/A, D/B and D/C, respectively,
producing
diff --no-git a/A b/D/A
...
diff --no-git a/B b/D/B
...
diff --no-git a/C b/D/C
...
The only unambiguous syntax I can think of that avoids such
alternative interpretations is something ugly like
git diff --no-index [-<options>] --src=<path> --dst=<path> [--] <pathspec>
where "src" and "dst" are in line with the existing src/dst-prefix
options.
Perhaps we could declare that this is the "canonical" way to spell
pathspec-filtered no-index comparison of two directories, but we
allow the syntax suggested in the message I am responding to as a
short-hand, but I am not sure if that would fly well.
This --src/--dst thing could lead to even uglier tangent. We could
use these options to specify what is compared with what else
--{src,dst}-path=<directory in the working tree>
--{src,dst}-index
--{src,dst}-worktree
--{src,dst}-tree=<tree object>
which allows us to express funky combinations like
git diff --src-index --dst-worktree [--] <pathspec>
git diff --src-tree=HEAD --dst-index [--] <pathspec>
git diff --src-tree=maint --dst-tree=master [--] <pathspec>
The above three would be ugly ways to spell the traditional "short
hands", e.g.
git diff [--] <pathspec>
git diff --cached [--] <pathspec>
git diff maint master [--] <pathspec>
respectively. And an obvious fallout of the above is this command
line:
git diff --src-path=A --dst-path=B [--] <pathspec>
Because this does not involve any index, tree or worktree, it cannot
be a Git operation, so we know that is --no-index mode; the command
line does not need to say --no-index anywhere if we go that route.
next prev parent reply other threads:[~2014-09-21 6:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 9:56 [PATCH] diff --no-index: allow pathspec after -- Nguyễn Thái Ngọc Duy
2014-09-18 22:41 ` Junio C Hamano
2014-09-21 4:08 ` Duy Nguyen
2014-09-21 6:19 ` Junio C Hamano [this message]
2014-09-21 9:25 ` Duy Nguyen
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=xmqq38blmr6g.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@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.
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.