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

Re: [RFC/PATCH 0/2] New 'stage' command

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Apr 6, 2009, 20:49 UTC
Message-ID
<vpqiqlh1p8t.fsf@bauges.imag.fr>
In-Reply-To
<7vy6ud4otd.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
>  - there are three distinct kinds of states: a committed state, the state
>    in the index (aka "what you have staged so far to the index"), and the
>    state in your work tree.
>
>  - many commands understand that you want to operate on and/or inspect
>    states in one or more of these states.  They default to what is often
>    used (e.g. "git diff" compares the index and the work tree, "git grep"
>    looks in the work tree, "git apply" patches the work tree [*1*]), but
>    you can tell them to use different entities via options and arguments.
>
> How does it help understanding any of the above to introduce STAGE?

For the first, if there are three kinds of states, I would find it natural to have three kinds of ways to talk about these states.

Sure, it doesn't change the second, since it makes things more explicit, it doesn't make them more concise.

>    - when you want to work with the index, you say --cached;

But that doesn't apply to "git diff". Both "git diff" and "git diff --cached" work with the index. "git diff" works with the index and work tree, while "git diff --cached" work with the index and HEAD.

>    - when you want to work with both the index and the work tree at the
>      same time, you say --index.

... which is everything but intuitive. The option name doesn't tell the user what the command is doing. First thing is that with Git, the user has to learn 3 words for one concept (index, cache, staging area). And then, he has to learn that although people use "index" and "cache" as synomyms, --index and --cached have different meanings. And that one can also have a --cache, and that it's possible to have a --stage too, but with different meaning.

I can understand the historical reasons, but I think finding a way to get rid of this historical terminology mess should be encourraged.

>    - for all commands, working with work tree is the default, so there is
>      no --work-tree option (we could add one, if you really want).

Except "git checkout", which takes the index by default, and a commit if specified. It makes sense since checking-out from the working tree doesn't make sense, but it is a special case, and learning the general rules you give doesn't tell the user what "git checkout" does.

Except "git ls-files", too. And I may have missed some.

See, you complain about special cases with the proposal, but the current UI _has_ tons of special cases like this.

> and the STAGE would work something like this:
>
>    - when you want to work with a committed state (or more in general,
>      with a tree-ish), you give the name of the commit;

It's not just "I want to work with". It's also about the role of the things you want to work with.

"git diff WORKTREE STAGE" would mean "diff from the worktree to the staging area", while "git diff STAGE WORKTREE" would mean the other way around.

> Think.  What does "git log STAGE" mean?  Can you explain why it does not
> make any sense?

It could make sense. Actually, gitk does show the work-tree and the index in a way similar to commits. Fundamentally, I don't see a difference between "git log" and "gitk" except that gitk is graphical.

Sure, STAGE and WORKTREE cannot have a commit message, and hardly have an author, but I could very well imagine "git log --stat WORKTREE" showing roughly what "git diff --stat; git diff --stat --cached; git log --stat HEAD" does today. I don't know how usefull this would be, but I wouldn't say it doesn't make sense either.

-- 
Matthieu
Previous: Johannes SchindelinNext: Junio C Hamano
Message 32 of 38 in “New 'stage' command”
  1. 0/2 New 'stage' commandFelipe Contreras, Apr 5, 2009
  2. 1/2 git: remote stageFelipe Contreras, Apr 5, 2009
  3. 2/2 Add new 'git stage' scriptFelipe Contreras, Apr 5, 2009
  4. Junio C HamanoApr 5, 2009
  5. Felipe ContrerasApr 5, 2009
  6. Junio C HamanoApr 5, 2009
  7. Junio C HamanoApr 5, 2009
  8. Felipe ContrerasApr 5, 2009
  9. Jay SoffianApr 5, 2009
  10. Felipe ContrerasApr 5, 2009
  11. 0/2 Re: New 'stage' commandNicolas Sebrecht, Apr 5, 2009
  12. Markus HeidelbergApr 5, 2009
  13. Felipe ContrerasApr 5, 2009
  14. Björn SteinbrinkApr 5, 2009
  15. Markus HeidelbergApr 5, 2009
  16. Björn SteinbrinkApr 6, 2009
  17. Markus HeidelbergApr 5, 2009
  18. Sverre RabbelierApr 5, 2009
  19. Johannes SchindelinApr 5, 2009
  20. Felipe ContrerasApr 6, 2009
  21. David AguilarApr 6, 2009
  22. Junio C HamanoApr 6, 2009
  23. David AguilarApr 6, 2009
  24. Junio C HamanoApr 6, 2009
  25. David KågedalApr 6, 2009
  26. David KågedalApr 6, 2009
  27. Junio C HamanoApr 6, 2009
  28. Felipe ContrerasApr 6, 2009
  29. Björn SteinbrinkApr 6, 2009
  30. Felipe ContrerasApr 7, 2009
  31. Johannes SchindelinApr 7, 2009
  32. Matthieu MoyApr 6, 2009
  33. Junio C HamanoApr 7, 2009
  34. Stefan KarpinskiApr 7, 2009
  35. Octavio AlvarezApr 7, 2009
  36. Junio C HamanoApr 7, 2009
  37. Octavio AlvarezApr 7, 2009
  38. Octavio AlvarezApr 7, 2009

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.