为什么 github/gitlab 错误地应用了 gitattributes?

问题描述

这是我发现的类似问题:Make github use .gitattributes "binary" attribute 如果它不打算在 Github 中工作,那么我的问题仅适用于 Gitlab。


问题是:想象一下创建一个带有单个文本 Dockerfile 并跟随 .gitattributes 的分支:

[core]
    whitespace=trailing-space,space-before-tab
[apply]
    whitespace=fix
* binary
Dockerfile text=auto diff merge

你推送这段代码,你可以在界面中查看提交,它工作得很好。 然后您决定 Dockerfile 也应该是二进制的(无论出于何种原因)并删除最后一行。您提交它,然后更改 Dockerfile 以检查它是否有效。您调用 git show,它显示确实应用了更改:

pzixe@ZPC MINGW64 ~/Documents/Repos/gitlab-test (all-binary)
$ git show HEAD
commit 141451116e292ae30a515920e6efb906f84b4142 (HEAD -> all-binary,origin/all-binary,github/all-binary)
Author: Psilon <[email protected]>
Date:   Wed Apr 14 19:25:04 2021 +0300

    test changes

diff --git a/Dockerfile b/Dockerfile
index 11f0f66..fef4bc1 100644
Binary files a/Dockerfile and b/Dockerfile differ

但是现在,如果您检查 github 界面,您会发现它实际上显示的是文本差异而不是所询问的二进制差异:

enter image description here

然后您尝试查看 GitLab 的工作方式是否有所不同,然后发现不是:

enter image description here

所以问题是:有什么办法可以使它起作用吗?我希望看到初始提交 6c0745e 的文本差异和最新提交 1414511

的二进制折叠差异

这是一个带有复制案例的仓库:https://github.com/Pzixel/test-gitlab

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)