{"thread":{"id":"52464","subject":"git restore --staged --worktree does not restore the index (Git 2.24.1)","startedAt":"2019-12-16T10:51:17Z","lastAt":"2019-12-16T11:57:24Z","messageCount":2,"participants":["Henré Botha","Phillip Wood"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"388244","messageId":"CAHbriemxQLVFQw9pTb37JmoD2QVqLcfgY43qFg4Ab8prrBSkuw@mail.gmail.com","threadId":"52464","inReplyTo":null,"subject":"git restore --staged --worktree does not restore the index (Git 2.24.1)","fromName":"Henré Botha","fromEmail":"henrebotha@gmail.com","sentAt":"2019-12-16T10:51:03Z","receivedAt":"2019-12-16T10:51:17Z","isPatch":false,"sender":{"key":"henrebotha@gmail.com","avatar":null},"body":"git help restore says:\n\n    The command can also be used to restore the content in the index\nwith --staged, or restore both the working tree and the index with\n--staged --worktree.\n\nHowever, this doesn't seem to work as advertised:\n\n    $ mkdir foo; cd foo; git init\n    $ touch a b; git add a b && git commit -m \"Initial commit\"\n    $ echo \"Foo\" > a; echo \"Bar\" > b\n    $ git add a\n    $ git status --short\n    M  a\n     M b\n    $ git restore --staged --worktree .\n    $ git status --short\n    M  a\n\nI'm not sure whether I expect 'a' to be empty at the end of this\nsequence, but I definitely expect it not to contain staged changes.\n"},{"id":"388246","messageId":"4c1324bb-faca-23e2-22b0-5fe2e2aa92e3@gmail.com","threadId":"52464","inReplyTo":"CAHbriemxQLVFQw9pTb37JmoD2QVqLcfgY43qFg4Ab8prrBSkuw@mail.gmail.com","subject":"Re: git restore --staged --worktree does not restore the index (Git 2.24.1)","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2019-12-16T11:57:17Z","receivedAt":"2019-12-16T11:57:24Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Henré\n\nOn 16/12/2019 10:51, Henré Botha wrote:\n> git help restore says:\n> \n>     The command can also be used to restore the content in the index\n> with --staged, or restore both the working tree and the index with\n> --staged --worktree.\n> \n> However, this doesn't seem to work as advertised:\n> \n>     $ mkdir foo; cd foo; git init\n>     $ touch a b; git add a b && git commit -m \"Initial commit\"\n>     $ echo \"Foo\" > a; echo \"Bar\" > b\n>     $ git add a\n>     $ git status --short\n>     M  a\n>      M b\n>     $ git restore --staged --worktree .\n>     $ git status --short\n>     M  a\n> \n> I'm not sure whether I expect 'a' to be empty at the end of this\n> sequence, but I definitely expect it not to contain staged changes.\n\nThanks for taking the time to report this. The man page for git restore\nstates\n\nWhen both `--staged` and `--worktree` are specified, `--source` must\nalso be specified.\"\n\nSo I think the bug is in the code that checks the options. It looks like\nit is just restoring from the index which is why there's no change to 'a'.\n\nBest Wishes\n\nPhillip\n\n"}]}