Feedback on git-restore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux