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

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

From
Jeff King <peff@peff.net>
Date
Nov 11, 2008, 01:22 UTC
Message-ID
<20081111012210.GA26920@coredump.intra.peff.net>
In-Reply-To
<7vljvr2hjn.fsf@gitster.siamese.dyndns.org>
On Mon, Nov 10, 2008 at 05:11:08PM -0800, Junio C Hamano wrote:
Show 7 quoted lines
> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 of 29 in “git-diff: Add --staged as a synonym for --cached.”
  1. git-diff: Add --staged as a synonym for --cached.David Symonds, Oct 29, 2008
  2. Jeff KingOct 29, 2008
  3. David SymondsOct 29, 2008
  4. Johannes SchindelinOct 29, 2008
  5. Jeff KingOct 29, 2008
  6. Junio C HamanoNov 2, 2008
  7. Jeff KingNov 3, 2008
  8. Björn SteinbrinkNov 2, 2008
  9. Junio C HamanoNov 2, 2008
  10. Björn SteinbrinkNov 2, 2008
  11. Jeff KingNov 3, 2008
  12. David SymondsNov 10, 2008
  13. Jeff KingNov 11, 2008
  14. Junio C HamanoNov 11, 2008
  15. Jeff KingNov 11, 2008
  16. Junio C HamanoNov 12, 2008
  17. Avery PennarunNov 11, 2008
  18. Miles BaderNov 11, 2008
  19. Jeff KingNov 12, 2008
  20. Johannes SchindelinNov 12, 2008
  21. Jeff KingNov 12, 2008
  22. Avery PennarunNov 12, 2008
  23. Jeff KingNov 12, 2008
  24. Junio C HamanoNov 12, 2008
  25. Jeff KingNov 12, 2008
  26. Junio C HamanoNov 12, 2008
  27. Avery PennarunNov 12, 2008
  28. Junio C HamanoNov 12, 2008
  29. Avery PennarunNov 12, 2008

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.