
cmd.exe will read from the AutoRun registry key at launch and execute the commands listed in the key. Since `FOR /F IN (command) ...` causes a new terminal instance to start, the AutoRun commands will be run again, possibly changing the current working directory. In this case, the `git rev-parse HEAD` check run in `shared.bat` could fail, which we were assuming meant `git` was not on the user's PATH. This change ensures that `git rev-parse HEAD` will always run in %FLUTTER_ROOT% and explicitly adds a separate check for `git` using `WHERE git` to more accurately determine if `git` is on the PATH. Fixes https://github.com/flutter/flutter/issues/159018 --------- Co-authored-by: Andrew Kolos <andrewrkolos@gmail.com>