.gitattributes does not handle -diff properly in UI
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=408763) </details> <!--IssueSummary end--> <!--- Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "regression" or "type::bug" label: - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=type::bug and verify the issue you're about to submit isn't a duplicate. ---> ### Summary `-diff` option is not working and not suppressing difference in UI when applied in `.gitattributes` file. Note: git CLI works fine with this settings, it's just our UI is not using .gitattributes ### Steps to reproduce 1. Create a repo with README 1. Create a new branch ("test") 2. Add the `.gitattributes` file with the following content on "test" branch ``` # cat .gitattributes ignoreme.txt -diff ``` 3. Add the "ignoreme.txt" file on "test" branch ``` # cat ignoreme.txt first line this must be ignored by diff ``` 4. Push the changes to the branch "test" 5. Observe with CLI git that the diff is suppressed: ``` git diff main diff --git a/.gitattributes b/.gitattributes index e69de29..d2200ca 100644 --- a/.gitattributes +++ b/.gitattributes @@ -0,0 +1 @@ +ignoreme.txt -diff diff --git a/ignoreme.txt b/ignoreme.txt index 6cc3bfa..d0a2c51 100644 Binary files a/ignoreme.txt and b/ignoreme.txt differ ``` 6. Go to GL UI and compare the diff there (or create an MR and check the diff). This will show full content of the `ignoreme.txt` file and will not suppress the diff ![image](/uploads/713c0dafb590c8dbbbbe2b213536af84/image.png) ### What is the current *bug* behavior? Diff of a file mentioned in `.gitattributes` with flag `-diff` is not suppressed in the UI ### What is the expected *correct* behavior? Diff is hidden in the UI "diff" view #### Results of GitLab environment info <!-- Input any relevant GitLab environment information if needed. --> <details> <summary>Expand for output related to GitLab environment info</summary> <pre> ``` sudo gitlab-rake gitlab:env:info System information System: Ubuntu 20.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.7.6p219 Gem Version: 3.1.6 Bundler Version:2.3.15 Rake Version: 13.0.6 Redis Version: 6.2.7 Sidekiq Version:6.4.2 Go Version: unknown GitLab information Version: 15.4.6-ee Revision: 4fc991ae59a Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 13.8 URL: https://gitlab-3.26.115.161.nip.io HTTP Clone URL: https://gitlab-3.26.115.161.nip.io/some-group/some-project.git SSH Clone URL: git@gitlab-3.26.115.161.nip.io:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.10.0 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell ``` </pre> </details> ### Possible fixes <!-- If you can, link to the line of code that might be responsible for the problem. -->
issue