I cannot seem to get variables in my batch script to subtract properly. I have the following:
set /P head=<..\BUILD_NUMBER.dat
echo %head% > ..\HEAD.dat
set desired=%5
echo %desired% > ..\test.dat
set /a "version=%desired%-%head%"
echo %version% > ..\version.dat
git checkout @{%version%}
echo %desired% > ..\BUILD_NUMBER.dat
echo %desired% > ..\build\BUILD_NUMBER.dat
The contents of ..\HEAD.dat is correct, however, nothing else is.
- ..\test.dat is never created (which I don't care too much about, since it was just a test).
- ..\BUILD_NUMBER.dat and ..\build\BUILD_NUMBER.dat have the values they had before the echoes
- ..\version.dat contains what %desired% contains.
- The checked out version of the git repo is the current HEAD, not the desired revision
Basically, what I'm trying to do is checkout a specific revision number from git, using rev-list --count to get the HEAD value, and subtract that from the desired version to get the negative offset for the git checkout command.