This is a similar issue I found: Make github use .gitattributes "binary" attribute If it's not intended to work in Github then my question applies to Gitlab only.
So the question: Imagine creating a branch with a single text Dockerfile
and following .gitattributes
:
[core]
whitespace=trailing-space,space-before-tab
[apply]
whitespace=fix
* binary
Dockerfile text=auto diff merge
You push this code, you can view commit in interface and it works just fine.
Then you decide that Dockerfile
should be binary as well (for whatever reason) and remove the last line. You commit it and then make change to the Dockerfile
to check if it works. You call git show
and it shows that changes indeed applied:
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
But now if you check the github interface you will see that it actually shows a text diff instead of binary diff which was asked:
Then you're trying to see if GitLab is working differently and find out it's not:
So the question is: is there any way to make this working? I'd expect to see a text diff of initial commit 6c0745e
and binary collapsed diff on latest commit 1414511
Here is a repo with reproduced case: https://github.com/Pzixel/test-gitlab
Your
.gitattributes
file has invalid syntax and is probably being completely ignored on that basis. The first four lines (reproduced below) are configuration syntax and can't be included in a.gitattributes
file. Configuration cannot be shipped as part of the repository and would need to either be stored in.git/config
or in your personal.gitconfig
.Beyond that, as outlined in this answer, GitHub doesn't use the
binary
attribute in.gitattributes
to determine which files should be diffed. It will diff those files which appear to be plain text (and, by default, not autogenerated) and will not diff files which appear to be binary. You can mark a file aslinguist-generated
to indicate that it's a generated file, though.I don't know if GitLab does or doesn't support this feature, but given that your
.gitattributes
file contains invalid syntax, that's probably not helping.