Problem with git + DiffMerge on OS X

前端 未结 1 1106
耶瑟儿~
耶瑟儿~ 2021-02-15 16:14

I have configured Sourcegear DiffMerge to be my default git merge tool using the following instructions:

git config --global diff.tool diffmerge
git config --glo         


        
相关标签:
1条回答
  • 2021-02-15 17:01

    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 讨论(0)
提交回复
热议问题