.gitattributes not making a difference, trying to skip files when using git difftool

前端 未结 2 1845
轮回少年
轮回少年 2021-02-08 12:12

I\'ve read the Git Pro website and I\'ve read multiple answers on StackOverflow, but sadly I am simply unable to make .gitattributes work for me.

Whenever I\'m using

相关标签:
2条回答
  • 2021-02-08 12:36

    patthoyts's answer worked for me.

    The trick for me was figuring out version of git-difftool--helper git was using (MacPorts had installed multiple versions)

    I used (with the difftool open):

    lsof | grep "git-difftool--helper"
    
    0 讨论(0)
  • 2021-02-08 12:49

    It looks like this is a deficiency in difftool. If you use the .gitattributes file as you have described then the output of 'git diff' is modified as intended so setting *.proj binary or *.proj -diff changes the git diff output for any .proj files to 'binary files differ'. However, difftool apears never to look at the attributes. I believe this is because difftool basically calls the same code as mergetool and merging of binary files is supported (if only by copying one over the other). The attached patch is a small change to the difftool-helper script that should cause it to skip files for which the binary attribute is set. It is probably something for the git mailing list.

    --- git-difftool--helper    2011-06-03 21:48:08.000000000 +0100
    +++ /opt/git/libexec/git-core/git-difftool--helper  2011-10-06 13:17:55.000000000 +0100
    @@ -56,6 +56,10 @@
        fi
     }
    
    +if test $(git check-attr diff "$1" | sed 's/.*diff: //') = 'unset'; then
    +   echo skip binary file "\"$1\""
    +else
    +
     if ! use_ext_cmd; then
        if test -n "$GIT_DIFF_TOOL"; then
            merge_tool="$GIT_DIFF_TOOL"
    @@ -70,3 +74,4 @@
        launch_merge_tool "$1" "$2" "$5"
        shift 7
     done
    +fi
    
    0 讨论(0)
提交回复
热议问题