git diff tmp file invalid on windows when using external program on Windows 7

后端 未结 3 946
情话喂你
情话喂你 2021-01-14 06:05

I\'m following the docs from the Git configuration page and trying to apply this to my Windows 7 environment. When I run say, \"git diff file0\" I get an error in P4Merge:

3条回答
  •  再見小時候
    2021-01-14 06:32

    The correct solution would be using Cygwin's cygpath tool to convert path formats:

    [difftool "p4merge"]
        cmd = p4merge \"$(cygpath -w \"$LOCAL\")\" \"$(cygpath -w \"$REMOTE\")\"
    

    The same goes for mergetool:

    [mergetool "p4merge"]
        keepBackup = false
        trustExitCode = true
        cmd = p4merge \"$(cygpath -w \"$BASE\")\" \"$(cygpath -w \"$LOCAL\")\" \"$(cygpath -w \"$REMOTE\")\" \"$(cygpath -w \"$MERGED\")\"
    

    Please note that this solution (as well as the question, actually) applies only to Cygwin environment. I've never had Git Bash exhibit the same problem and don't know if it has a utility similar tocygpath.

    UPDATE: Unfortunately, the cygpath utility does a poor job converting /dev/null to its Windows equivalent. It will return the invalid \\.\NUL path, and so diffing new files will fail. I'll issue another update with the workaround, as soon as I find it.

提交回复
热议问题