Here's my problem.
When you call git status --porcelain
git returns 0 no matter what the output of the command is.
So the %ERRROREVEL%
is of no help to me here.
I need to be able to store the output of git status --porcelain
in a variable, and then based on the existence of any character in it realize if there are changes or not.
So basically I need this pseudo-code:
set GitStatusOutput = git status --porcelain
set HasChanges = findstr . in %GitStatusOutput%
But I'm stuck at running this simple need in CMD. I can't change to bash or PowerShell.
I have tried:
for /f "tokens=*" %%a in ('git -C %%s status --porcelain') do (set GitStatusResult=%%a)
echo %GitStatusResult%
Not working.
I have tried:
set HasChangesCommand=git -C %%s status --porcelain | findstr . && echo 1 || echo 0
echo %HasChangesCommand%
Not working.
How can I do that?
Please note:
I have asked many questions, but with no success.
I have a very very simple need and I'm stuck in for like hours.
I appreciate your time, but I don't need a fancy explanation. I just need a simple answer.