Re: [PATCH] git-diff: Add --staged as a synonym for --cached.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 10, 2008 at 05:11:08PM -0800, Junio C Hamano wrote:

> I doubt "Is there any further discussion on THIS ONE ALONE?" is a valid
> question to ask.  What are the other command options we are introducing
> synonyms for?  There is no need for two variants of staged for "diff" (you
> don't have --staged-too option but instead you give a committish argument,
> e.g. HEAD), so --staged-only can be abbreviated to --staged without
> risking any ambiguity.  But at least a fully-spelled-out --staged-only
> should also be accepted, shouldn't it?

I'm not sure that "staged-only" really makes sense here. In modification
commands like "apply", it is about "do this one thing to the working
tree, to both the index and the working tree, or to just the index".

But here, you are selecting two points for comparison. So while it is
tempting to say "the default for diff just happens to work on the index
and the working tree, so we don't need --staged-too", I don't think that
is right. Doing "--staged-only" is _not_ about saying "do the thing we
would have done to the working tree and the index to just the index." It
is about "use HEAD as one of the points instead of the working tree
(and reverse the order of points :) )".

To me, what is really being asked with "git diff --staged" (or "git
diff --cached" for that matter), is "what is staged?" That is, diff is
not about an operation on a data location (like HEAD, index, or working
tree), but rather an operatoin on a data _relationship_. So you ask for
"what is not staged" (the relationship between index and working tree),
"what is staged" (the relationship between HEAD and index), "what is
different between the working tree and HEAD", or "what is different
between these two trees".

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux