git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git restore --staged --worktree does not restore the index (Git 2.24.1)
@ 2019-12-16 10:51 Henré Botha
  2019-12-16 11:57 ` Phillip Wood
  0 siblings, 1 reply; 2+ messages in thread
From: Henré Botha @ 2019-12-16 10:51 UTC (permalink / raw)
  To: git

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.

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

* Re: git restore --staged --worktree does not restore the index (Git 2.24.1)
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Phillip Wood @ 2019-12-16 11:57 UTC (permalink / raw)
  To: Henré Botha, git

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


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

end of thread, other threads:[~2019-12-16 11:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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