git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Feedback on git-restore
@ 2019-05-15  9:38 Poughon Victor
  2019-05-15 10:30 ` Duy Nguyen
  0 siblings, 1 reply; 8+ messages in thread
From: Poughon Victor @ 2019-05-15  9:38 UTC (permalink / raw)
  To: git@vger.kernel.org

Hi

I came across a description of a new git command currently in development called 'git restore'. Since it's still not out, and the original poster [1] seemed to ask for feedback, I though I'd send some here. Hope that's ok!

Reading the documentation [2] I find it very confusing. In particular when comparing the following two commands:

$ git restore --staged file
$ git restore --worktree file

With the current proposal, the first will restore the index from HEAD, while the second will restore the worktree from the index. In other words, the source for the restore is different in both commands, even though neither specify a source! This means that git-restore really does two different things depending on some other not obvious context. Unfortunately that's typical of the (often criticized) obscure interface of git. To be fair that behavior is documented in [2]. But still, having a variable default value for --source depending on other arguments is very confusing.

So in summary, I'd make two recommendations for this command's UX:
1. Make --source default value always HEAD if unspecified
2. Rename --staged to --index

Some examples of those:

$ git restore --index file # reset the index from HEAD
$ git restore --worktree file # reset the worktree from HEAD
$ git restore --worktree --source=index file # reset the worktree from the index
$ git restore --index --worktree file # reset both the index and worktree from HEAD
$ git restore file # reset the worktree from HEAD 

[1] https://news.ycombinator.com/item?id=19907960
[2] https://github.com/git/git/blob/pu/Documentation/git-restore.txt

Best,
Victor




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-05-18 14:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-15  9:38 Feedback on git-restore Poughon Victor
2019-05-15 10:30 ` Duy Nguyen
2019-05-15 10:59   ` Ævar Arnfjörð Bjarmason
2019-05-15 11:16     ` Duy Nguyen
2019-05-16  2:18   ` Junio C Hamano
2019-05-16 12:12     ` Philip Oakley
2019-05-16 12:44       ` Duy Nguyen
2019-05-18 14:19         ` Philip Oakley

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).