git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.34k stars 2.53k forks source link

git submodule foreach --recursive no longer works properly #2230

Closed jesterKing closed 3 years ago

jesterKing commented 5 years ago

Setup

$ git --version --build-options
git version 2.22.0.windows.1
cpu: x86_64
built from commit: d003d728ffa6c0006da875ec6318d3f6b28a4ddb
sizeof-long: 4
sizeof-size_t: 8
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.18362.116]
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VIM
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
Enable Builtin Interactive Add: Disabled

N/A

Details

Bash, CMD

git submodule foreach --recursive git clean -dxff

Proper running of the git clean -dxff command for each submodule

Error message

$ git submodule foreach --recursive git clean -dxff
Entering 'src/lib/opennurbs'
error: unknown switch `d'
usage: git submodule--helper foreach [--quiet] [--recursive] [--] <command>

    -q, --quiet           Suppress output of entering each submodule command
    --recursive           Recurse into nested submodules

fatal: run_command returned non-zero status while recursing in the nested submodules of src/lib/opennurbs
.

Happens with all repositories tested.

The command works with the form git submodule foreach --recursive "git clean -dxff", but that seems to be an undocumented change from git version 2.21.0.windows.1, where the form git submodule foreach --recursive git clean -dxff still worked as expected.

rimrul commented 5 years ago

It seems this was caused in upstream git in commit a282f5a. A fix seems to be in the in the making.

dscho commented 5 years ago

It entered next already as https://github.com/git/git/commit/30db18b148c4951deb2c870b5243fb5b18ecb5ed, which means that it is on track to be included in the next major version of Git.

@jesterKing feel free to install Git for Windows' SDK, then build an initial Git with sdk build git, then sdk cd git and cherry-pick this fix, then test, and open a PR.

(If this is too dense an explanation how to continue, please do not hesitate to ask for help.)

rimrul commented 3 years ago

The fix made it into git v2.22.1 and newer, so I'll assume this is working now.