1

目前我有这个gitconfig:

[diff]
    tool = diffmerge
[difftool "diffmerge"]
    cmd = diffmerge \"$LOCAL\" \"$REMOTE\"
[merge]
    tool = diffmerge
[mergetool "diffmerge"]
    cmd = "diffmerge --merge --result=\"$MERGED\" \"$LOCAL\" \"$(if test -f \"$BASE\"; then echo \"$BASE\"; else echo \"$LOCAL\"; fi)\" \"$REMOTE\""
    trustExitCode = true
[alias]
  df = difftool

每次我通过 git difftool somefile..somefile 启动 difftool 时,都会得到提示:

Hit return to launch 'diffmerge':

我怎样才能设置这个提示,如果我输入“Y”它会打开文件,如果“N”它会跳过它?

4

1 回答 1

0

这有点像黑客,但你可以这样做:

[alias]
    df = difftool -y
[difftool "diffmerge"]
    cmd = sh -c 'read -p \"Type Y to launch diffmerge:\" r && \
        test $r = Y \
        && diffmerge \"$LOCAL\" \"$REMOTE\"'

这假设您read接受-p。如果没有,请执行标准操作:

cmd = sh -c 'printf \"Type Y to launch diffmerge: \" && read r && test $r = Y \
            && diffmerge \"$LOCAL\" \"$REMOTE\"'
于 2012-11-06T16:49:26.597 回答