【问题标题】:Git diff ignores textconv when provided paths提供路径时,Git diff 忽略 textconv
【发布时间】:2018-09-06 18:24:03
【问题描述】:

我已经设置了我的 git diff,当它在二进制文件上调用时,它将使用一个自定义程序作为 .gitconfig 文件中指定的 textconv。看起来像这样

[diff "file"]
    textconv = python "'/path/to/program.py'"
    xfuncname = .*name=.*
[core]
    attributesfile = ~/.gitattributes

在我的 .gitattributes 文件中

*.file diff=file

如果应用于我的 git repo 和终端,这会很好。但是,我的公司使用 TortoiseGit 作为 git 的前端,它带来了自己的差异工具,我无法使用 textconv 选项。为了查看差异,我提供了一个类似的命令

cmd /K git diff %base %mine

然后输出将是

diff --git "a/path/in/repo.file" "b/temporary/path/out/of/repo.file"
index e4ab82c..3c0f4d7 100644
Binary files "a/path/in/repo.file" and "b/temporary/path/out/of/repo.file" differ

通常 git 会将 textconv 应用于二进制文件,如果提供了“%base”而不是“HEAD”,它将毫无问题地工作。我怀疑 git 的运行就像使用 --no-index 调用一样,并忽略了 .gitattributes 文件,因此现在不必应用 textconv。

有没有办法解决这个问题?

【问题讨论】:

    标签: git tortoisegit git-diff


    【解决方案1】:

    使用 --textconv 选项强制进行 textconv 转换:

    cmd /K git diff --textconv %base %mine
    

    【讨论】:

    • 我不知道 diff 有这个选项。谢谢,解决了我的问题!
    猜你喜欢
    • 2010-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多