Bug Report Details:
Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.
What did you do before the bug happened? (Steps to reproduce your issue)
The prerequisites of this bug concerning `git restore` the following:
* You are explicitly specifying a source for the restore
* The file or files in which you are attempting to restore exists in any state within the source commit, branch, or tag you are using to restore the file.
* Said files also exist in the working tree
* The wildcard `*` is being used to dynamically locate the file
* the wildcard is not being used only for the file extension
All of the following examples demonstrate the same behavior with GIT RESTORE:
git restore --source=<tree> -- "*.json"
git restore -s <tree> "*.json"
git restore -s <tree> "*.component.*"
What did you expect to happen? (Expected behavior)
* Find all files that match the pathspec
* Restore those files to the states in which they existed in the source tree
What happened instead? (Actual behavior)
* The wildcard allows me to find the files correctly
* all these files are always deleted
What's different between what you expected and what actually happened?
As an example of the differences I'll post my console commands accompanied by git status
# Using the Wildcard
<computer> MINGW64 /i/DevSRC/Thinkster.io/AdvancedGIT-Example (feature/gitRestore/000003)
$ git restore --source=feature/gitRestore/000002 -- "*.json"
<computer> MINGW64 /i/DevSRC/Thinkster.io/AdvancedGIT-Example (feature/gitRestore/000003)
$ git status
On branch feature/gitRestore/000003
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: e2e/tsconfig.json
deleted: src/assets/movies.json
# Using Explicit Paths (one of the files had no changes which demonstrates more contrast)
<computer> MINGW64 /i/DevSRC/Thinkster.io/AdvancedGIT-Example (feature/gitRestore/000003)
$ git restore --source=feature/gitRestore/000002 -- e2e/tsconfig.json src/assets/movies.json
<computer> MINGW64 /i/DevSRC/Thinkster.io/AdvancedGIT-Example (feature/gitRestore/000003)
$ git status
On branch feature/gitRestore/000003
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/assets/movies.json
Anything else you want to add:
Please review the rest of the bug report below.
You can delete any lines you don't wish to share.
[System Info]
git version:
git version 2.28.0.windows.1
cpu: x86_64
built from commit: 77982caf269b7ee713a76da2bcf260c34d3bf7a7
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
uname: Windows 10.0 20211
compiler info: gnuc: 10.2
libc info: no libc information available
$SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe
[Enabled Hooks]