开发者

Problem with git + DiffMerge on OS X

开发者 https://www.devze.com 2023-01-31 01:24 出处:网络
I have configured Sourcegear DiffMerge to be my default git merge tool using the following in开发者_如何学运维structions:

I have configured Sourcegear DiffMerge to be my default git merge tool using the following in开发者_如何学运维structions:

git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd "diffmerge \"\$LOCAL\" \"\$REMOTE\""

git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd "diffmerge --merge --result=\"\$MERGED\"
\"\$LOCAL\" \"\$BASE\" \"\$REMOTE\""
git config --global mergetool.diffmerge.trustexitcode false

Source: http://www.andrejkoelewijn.com/wp/2010/01/08/configure-diffmerge-with-git/

However when I run git mergetool I get the following error:

Problem with git + DiffMerge on OS X

What could be the cause of this issue?


It is possible that there will be no $BASE file, if for instance the two files being merged have no common ancestor, or if you happen to get the conflict when applying or rebasing a patch rather than merging branches. In this case, while the $BASE variable will still be set, there will be no file there.

In your mergetool command, you need to check whether $BASE exists, and do a merge without a common ancestor if it does not. It doesn't look like DiffMerge supports that mode (it supports merging two files with no common ancestor, but it always writes the output to one of the files, not a result file). Instead, you'll need instead to pass in $LOCAL as the $BASE file if $BASE does not exist:

git config --global mergetool.diffmerge.cmd 'diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"'
0

精彩评论

暂无评论...
验证码 换一张
取 消