mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Poughon Victor <>
To: "" <>
Subject: Feedback on git-restore
Date: Wed, 15 May 2019 09:38:59 +0000	[thread overview]
Message-ID: <> (raw)


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 



             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:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* 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

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).