I have trouble "forwarding" an output to a variable.
I'm using Atlassian SourceTree with my GIT versioning. There I want to create a custom action, with which I can easily create a zip file of all modified files of one commit. The created file should have a formatted date of the commit time in the filename as update-<YYYYmmdd>T<hhMM>.zip.
My working batch-file so far (line numbers for later reference):
1: setlocal enabledelayedexpansion
2: set output=
3: for /f "delims=" %%a in ('git diff-tree --no-commit-id --name-only -r %1^^') do ( set output=!output! "%%a" )
4: set hours=
5: git show -s --format=%%ci %1 > tmptmptmp & set /p hours= < tmptmptmp & del tmptmptmp
6: set hours=%hours:~0,4%%hours:~5,2%%hours:~8,2%T%hours:~11,2%%hours:~14,2%
7: git archive -o update-%hours%.zip HEAD %output%
8: endlocal
I'm having trouble to rewrite line 5 (hours-line) to avoid creating a temporary file. If I do the same as in line 3 (output-line) like:
for /f "delims=" %%a in ('git show -s --format=%%ci %1^^') do ( set hours=!hours! "%%a" )
I get the following error:
fatal: ambiguous argument '%ci': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this:
git <command> [<revision>...] -- [<file>...]
I assume this has something to do with the needed %ci parameter (for formatting the output).
Can somebody help me with this?
%cist not a valid parameter for--format.git show -s --format=%ci <commit-id>returns an iso formatted (I know, not strict) date string of the commits timestamp. Your suggenstion only returns "%c" if used in git bash.