Fed*_*oni 6 git whitespace path
似乎在git difftool执行外部命令时,它不会正确引用参数.
如果.gitconfig包含以下行:
[difftool.echo]
cmd = echo "$LOCAL" "$REMOTE"
Run Code Online (Sandbox Code Playgroud)
当我尝试difftool使用包含空格的路径运行时,例如
> git difftool -t echo HEAD^ HEAD spaces\ here/test.txt
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
/tmp/RL2Nyi_test.txt spaces here/test.txt
Run Code Online (Sandbox Code Playgroud)
如您所见,文件名未被引用(尽管命令中有明确的引号),因此参数解析失败.删除引号.gitconfig(编辑:以及将它们转义为\")不会改变结果.
(通过替换echo任何diff程序,您将获得更有意义的用例).
如何获得正确转义的文件名?
您将要在以下命令中绕过命令转义引号.gitconfig:
cmd = difftoolname \"$LOCAL\" \"$REMOTE\"
Run Code Online (Sandbox Code Playgroud)