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
Avery Pennarun <apenwarr@gmail.com>
Date
Nov 11, 2008, 04:04 UTC
Message-ID
<32541b130811102004n54a47331v48ba8d299039897f@mail.gmail.com>
In-Reply-To
<20081103071420.GD10772@coredump.intra.peff.net>
On Mon, Nov 3, 2008 at 2:14 AM, Jeff King <peff@peff.net> wrote:
Show 21 quoted lines
> So "git diff --staged", while it makes sense to us (since we are asking
> "what is staged"), is not consistent with the discussed rules. In
> particular:
>
>  1. It operates on just the "stage" and not the working tree, so it
>     should be "--staged-only". But the only there is nonsensical.
>
>  2. The default is _already_ operating on the staging area, so you are
>     really switching up the working tree for the HEAD in what you are
>     diffing. So in that sense, it doesn't convey the change in
>     operation very well.
>
> And I am not proposing a change here (except to perhaps "git diff
> --staged" instead of "--cached"). Just pointing out that it does not
> follow the "--staged operates on both, --staged-only operates on just
> the index" rule.
>
> Hrm. For that matter, grep is a bit different, too. Since I would expect
> "git grep --staged" to find only staged things, not things in both the
> working tree and the index. So perhaps there is a difference between
> commands that modify and commands that inspect.

Speaking just for myself, I would find this all a lot less confusing if "staged" were a refspec of some sort, not an option at all.

   git diff HEAD..STAGED
   git diff STAGED..WORKTREE
   git grep pattern STAGED HEAD sillybranch WORKTREE ^ignorebranch --
path/to/files

git-rev-parse already gives us a nice syntax for including/excluding particular trees as much as we like; the only problem is you can't talk about the work tree or index as if they were revisions.

Have fun,
Avery
Previous: Junio C HamanoNext: Miles Bader
Message 17 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.