sublime_merge icon indicating copy to clipboard operation
sublime_merge copied to clipboard

.gitattributes diff filters are not respected when viewing diffs

Open gschaffner opened this issue 6 years ago • 12 comments

Version info

  • OS: Manjaro GNU/Linux 18.0.4
  • Build: 1116

Description

Files with diff filters set in .gitattributes do not have their filters respected when viewing diffs in Sublime Merge. Instead, the diff says only <binary file changed>.

This behavior is observed with git-crypt in particular, but this may also apply to other filters applied in .gitattributes

Steps to reproduce

Steps to reproduce the behavior:

  1. Install git-crypt and initialize it on a repository. Instructions for initialization are here.
$ mkdir test-repo && cd test-repo
$ git init
$ git crypt init
$ git crypt add-gpg-user [email protected]
  1. Configure git-crypt to act on a file.
$ echo "secretfile filter=git-crypt diff=git-crypt" > .gitattributes
$ git add . && git commit -m "Add secretfile encryption to .gitattributes"
  1. Modify that file and stage the changes.
$ echo "this is secret" > secretfile && git add .
  1. View the diff in Sublime Merge.
$ smerge .

Expected behavior

Instead of <binary file changed>, the proper filtered diff should appear.

The proper diff can be seen with

$ git diff --staged
diff --git a/secretfile b/secretfile
new file mode 100644
index 0000000..a2446a1
--- /dev/null
+++ b/secretfile
@@ -0,0 +1 @@
+this is secret

Screenshots

gschaffner avatar Aug 24 '19 23:08 gschaffner

related: #448 & #428

srbs avatar Aug 27 '19 02:08 srbs

I am having the same issue with https://github.com/AGWA/git-crypt

saikpr avatar Aug 05 '20 08:08 saikpr

This would also be really nice for Git LFS tracked text files (filter=lfs diff=lfs merge=lfs), which diff like normal files given git config diff.lfs.textconv cat (git-lfs/git-lfs#440).

bb010g avatar Oct 20 '20 03:10 bb010g

This would also be very helpful in "the other direction", i.e. *.foo binary or *.foo -diff where files with suffix .foo are marked as binary, for files that are technically ascii, e.g. eps or mathematica notebook files

ref: gitattributes: -diff section "Identifying Binary Files" in this

daviehh avatar Jul 19 '21 21:07 daviehh

Hi confirm the issue in sublime-merge 4

olopost avatar Nov 05 '21 17:11 olopost

Ran into the same issue when using *.xlsx diff=xdoc2txt in .gitattributes as documented here: git-scm: Diffing Binary Files

It works fine on the command line, and in other GUI clients (tested Fork and Git GUI). The issue is also still present whether using the bundled or system git binary in Sublime Merge.

anthroid avatar Mar 25 '22 18:03 anthroid

Ran into the same issue with nbstripout, confirmed working in cli and other gui clients.

content of .gitattributes:

*.ipynb filter=nbstripout
*.ipynb diff=ipynb

pSpitzner avatar Dec 29 '22 18:12 pSpitzner

Same issue with *.docx diff=pandoc in .gitattributes.

I only see people reporting on the existence of this issue (since 2019). Can someone with authority say anything about the progress on this issue?

Dante3085 avatar Feb 25 '23 17:02 Dante3085

Still appears to be an issue in build 2083 when using elasticdog/transcrypt

path/to/file  filter=crypt diff=crypt merge=crypt

Sublime Merge is the only git client I've used so far that fails to diff the files correctly. It shows the encrypted version of the file instead of the decrypted version. VSCode, git CLI, etc. all diff the file using the decrypted version.

Although given this issue has been open since 2019, very little hope of this being addressed any time soon?

othyn avatar Apr 06 '23 10:04 othyn

This make SM unusable for our use case, where we have compiled assets (>50) and .gitattributes set to

dist/** -diff

Because SM is the only Git client that doesn't do this correctly, you have to scroll past tens of lines of "working directory" changes (which aren't) to find actual changes e.g. in src/ to work with.

tomchiverton avatar Jul 10 '23 15:07 tomchiverton

This is still an issue in build 2096 with git-crypt.

bitmagewb avatar May 13 '24 18:05 bitmagewb

When will .gitattributes be supported? It's needed for developers who use Bun: https://bun.sh/docs/install/lockfile#how-do-i-inspect-bun-s-lockfile

samholmes avatar Jul 17 '24 18:07 samholmes

Maybe the issue has slipped through the cracks? Seems like something that should be easy to fix, and quite fundamental since there seem to be a number of circumstances where it matters?

Could someone from the Sublime HQ comment, please? Maybe @dpjohnst? If more debug info is needed, Im happy to help out.

Thanks!

pSpitzner avatar Mar 18 '25 16:03 pSpitzner

If I understand right, something like this would be useful for filtering out generated files from the diff view in Go programs that use Templ.

I'm just learning about .gitattributes so maybe I've misunderstood something, but my goal is to de-emphasize or prevent certain files from showing up in the diff view.

I'd prefer them checked in but given Sublime Merge's current behavior (showing them intermixed with other files) I will probably add them to my .gitignore for now. Please let me know if there's a setting for this that I missed -- I searched around but haven't found one.

yurivish avatar Jul 25 '25 00:07 yurivish