git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: "Henré Botha" <henrebotha@gmail.com>, git@vger.kernel.org
Subject: Re: git restore --staged --worktree does not restore the index (Git 2.24.1)
Date: Mon, 16 Dec 2019 11:57:17 +0000	[thread overview]
Message-ID: <4c1324bb-faca-23e2-22b0-5fe2e2aa92e3@gmail.com> (raw)
In-Reply-To: <CAHbriemxQLVFQw9pTb37JmoD2QVqLcfgY43qFg4Ab8prrBSkuw@mail.gmail.com>

Hi Henré

On 16/12/2019 10:51, Henré Botha wrote:
> git help restore says:
> 
>     The command can also be used to restore the content in the index
> with --staged, or restore both the working tree and the index with
> --staged --worktree.
> 
> However, this doesn't seem to work as advertised:
> 
>     $ mkdir foo; cd foo; git init
>     $ touch a b; git add a b && git commit -m "Initial commit"
>     $ echo "Foo" > a; echo "Bar" > b
>     $ git add a
>     $ git status --short
>     M  a
>      M b
>     $ git restore --staged --worktree .
>     $ git status --short
>     M  a
> 
> I'm not sure whether I expect 'a' to be empty at the end of this
> sequence, but I definitely expect it not to contain staged changes.

Thanks for taking the time to report this. The man page for git restore
states

When both `--staged` and `--worktree` are specified, `--source` must
also be specified."

So I think the bug is in the code that checks the options. It looks like
it is just restoring from the index which is why there's no change to 'a'.

Best Wishes

Phillip


      reply	other threads:[~2019-12-16 11:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16 10:51 git restore --staged --worktree does not restore the index (Git 2.24.1) Henré Botha
2019-12-16 11:57 ` Phillip Wood [this message]

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

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

  git send-email \
    --in-reply-to=4c1324bb-faca-23e2-22b0-5fe2e2aa92e3@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=henrebotha@gmail.com \
    /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.
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 NNTP newsgroup(s).