I need to set a git filter with an executable file and a long list of parameters under Windows.
The executable is jq.exe
the parameters I need to pass to it are --indent 1 "(.cells[] | select(has(\"outputs\")) | .outputs) = [] | (.cells[] | select(has(\"execution_count\")) | .execution_count) = null | .metadata = {\"language_info\": {\"name\": \"python\", \"pygments_lexer\": \"ipython3\"}} | .cells[].metadata = {}"
I have tried two ways to have git filter to invoke this long command. None of them has worked.
I wrote a small bat file
nbstrip.bat
that contains the full invocation. I have put this bat file in the path. And I have set the filtergit config --global --add filter.nbstrip.clean "cmd /c nbstrip"
When I invoke this filter indirectly with a
git add test.nb
, git gets apparently "confused" and kinda interprets the output of the filter as new commands and tries to execute them.what is the correct way to set a window bat file as command in a git filter?
I put all the parameters in a auxiliary file in
%appdata%
in order to simplify the command invocation. This waygit config --global --add filter.nbstrip.clean "jq --indent 1 --from-file %appdata%\nbstrip.jq.txt"
.When I invoke this filter indirectly with a
git add test.nb
, the jq executable does not receive the correct filename, and complains with a error messagejq.exe: Could not open C:UsersAdminAppDataRoamingnbstrip.jq.txt: No such file or directory
as if it had all the backslashes removed before the name be passed to the executable.What is the correct way to have parms with backslashes in a git filter command specification?
Note that:
- In both cases I have tried the command invocation directly in the command line and they work perfectly
- there is no issue with the git filter definition in .gitattributes nor in the git config, they are correctly setup: if instead of invoking my command I set a simple log it works perfectly.
Do you have any additional strategy that could solve this situation?