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

Re: [PATCH] Implement git-staged, an alias for 'git diff --cached'.

From
David Kågedal <davidk@lysator.liu.se>
Date
Oct 29, 2008, 20:24 UTC
Message-ID
<87abcnb14c.fsf@krank.kagedal.org>
In-Reply-To
<878ws7w8xc.fsf@iki.fi>
Teemu Likonen <tlikonen@iki.fi> writes:
Show 17 quoted lines
> Wincent Colaiuta (2008-10-29 18:42 +0100) wrote:
>
>> El 29/10/2008, a las 18:03, Johannes Schindelin escribió:
>>> I completely disagree. If the existing set of commands causes
>>> confusion, we need to deprecate those parts and add new commands.
>>> Even if we have a ton of commands already.
>>
>> The confusion isn't at the command level; it's at the switch/option
>> level. The solution isn't to add a new command.
>
> I don't remember being confused in particular area but I think it's a
> _very_ good thing that the following three are behind the same "diff"
> command:
>
>     git diff
>     git diff --cached       (or --staged)
>     git diff HEAD

One irregularity hear is that there is no way to explicitly say what you want to compare against the index (the staging area). Diff compares two things to each other, and a more regular and general way to express what it does would be something like

    git diff STAGE WORKTREE   (like "git diff" today)
    git diff HEAD WORKTREE    (like "git diff HEAD" today)
    git diff WORKTREE HEAD    (like "git diff -R HEAD" today)
    git diff HEAD STAGE       (like "git diff --cached" today)
    git diff commit STAGE     (like "git diff --cached commit" today)

To me, it isn't obvious that --cached changes the thing you *compare* rather than the thing you compare *against*. I think it would be useful to have a way of explicitly stating what you compare, something like what I wrote above, and then having useful shortcuts for common cases (like that no arguments compares the work tree against the stage).

-- 
David Kågedal
Previous: Teemu LikonenNext: Johannes Schindelin
Message 17 of 25 in “Implement git-staged, an alias for 'git diff --cached'.”
  1. Implement git-staged, an alias for 'git diff --cached'.David Symonds, Oct 28, 2008
  2. Jeff KingOct 28, 2008
  3. Implement git-staged, an alias for 'git diff --cached'.David Symonds, Oct 28, 2008
  4. Jeff KingOct 29, 2008
  5. Implement git-staged, an alias for 'git diff --cached'.David Symonds, Oct 29, 2008
  6. Johannes SchindelinOct 29, 2008
  7. Jeff KingOct 29, 2008
  8. Wincent ColaiutaOct 29, 2008
  9. Johannes SchindelinOct 29, 2008
  10. Stephan BeyerOct 29, 2008
  11. Johannes SchindelinOct 29, 2008
  12. Wincent ColaiutaOct 29, 2008
  13. Johannes SchindelinOct 29, 2008
  14. Pascal ObryOct 29, 2008
  15. Wincent ColaiutaOct 29, 2008
  16. Teemu LikonenOct 29, 2008
  17. David KågedalOct 29, 2008
  18. Johannes SchindelinOct 29, 2008
  19. Wincent ColaiutaOct 29, 2008
  20. Stephan BeyerOct 29, 2008
  21. Jeff KingOct 29, 2008
  22. Brandon CaseyOct 29, 2008
  23. Jeff KingOct 29, 2008
  24. Pascal ObryOct 29, 2008
  25. Felipe ContrerasOct 29, 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.