From: Poughon Victor <Victor.Poughon@cnes.fr>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Feedback on git-restore
Date: Wed, 15 May 2019 09:38:59 +0000 [thread overview]
Message-ID: <3E55146A6A81B44A9CB69CAB65908CEA6B91353C@TW-MBX-P01.cnesnet.ad.cnes.fr> (raw)
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
next reply other threads:[~2019-05-15 9:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-15 9:38 Poughon Victor [this message]
2019-05-15 10:30 ` Feedback on git-restore 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3E55146A6A81B44A9CB69CAB65908CEA6B91353C@TW-MBX-P01.cnesnet.ad.cnes.fr \
--to=victor.poughon@cnes.fr \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).