Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 delta won't show diffs of files marked as autogenerated with .gitattributes even though they're text files #1623

Open
2 tasks done
matteematt opened this issue Feb 12, 2024 · 6 comments

Comments

@matteematt
Copy link

  • Please include the raw text output from git, so that we can reproduce the problem.
    (You can use git --no-pager to produce the raw text output.) - I tried this but it wasn't working
  • A screenshot of Delta's output is often helpful also.

Thanks for filing a Delta bug report!

We use .gitattributes on our project to mark certain files as autogenearted, so in Github they are not expanded when the revieiwer is looking at the code. This could be to mark output js files transpiled from ts files, or autogenerated markdown files.

An example of the file to mark the markdown files.

*.md -diff
*.md linguist-generated

In diff tools such as vscode I get expected diff output still, but delta just gives me info about how this is a binary file and I can't see the diff.

Output from delta:

Screenshot 2024-02-12 at 10 44 10

Output with vscode diff vieiwer (this is what I expect)

Screenshot 2024-02-12 at 10 43 20

I understand that if I use the standard git diff without delta that it has the same issue, so the answer might be that this isn't possible. I just think there could be a way (potentially enabled with an option) if other tools can manage it.

@imbrish
Copy link
Contributor

imbrish commented Feb 12, 2024

By unsetting the diff in .gitattributes, you are telling git that it is not possible to diff the *.md files. Which, if i understand correctly, is what you want on GitHub. The standard behavior is showing such files as binary. It has nothing to do with delta.

If you want to skip these diffs on GitHub, but generate them locally, I guess you could have another attributes file, not included in version control, where you tell git it should diff these files. I am a bit unsure about inheritance though.

@matteematt
Copy link
Author

I did think that is the case, does that imply then that vscode is behaving how I want due to the fact that it's probably behaving incorrectly?

@imbrish
Copy link
Contributor

imbrish commented Feb 12, 2024

I don't use vscode myself, but I would imagine it talks with git to be helpful, and not necessarily promises to follow all the rules.

@0xjac
Copy link

0xjac commented May 7, 2024

@imbrish I have a similar issue and a scenario which I believe to be relevant here:

I have generated files which are committed to a repo. Those files are marked as binary mainly to tell git to not perform any kind of merging on those files. It also hides the diffs on Github/Gitlab which is useful as they should not be reviewed/edited when merging.

However locally, there a few times where I do need to look at the code generation process and investigate what changed in those files. I can easily do this with git diff by passing the --text option, essentially telling git to treat those files as as text (which they actually are).

I want to use delta to do a diff between two generation versions of my files in two separate dir. Ideally I'd like to do delta dirA dirB. Since this calls git it doesn't work. My current work around is to call:

git diff --no-index --color --text -- dirA dirB | delta

which works but is a bit cumbersome.

I believe the issue is here where delta calls git but does not allow passing any extra options to git. It would be great if we could do something along the lines of

delta [OPTIONS] [MINUS_FILE] [PLUS_FILE] -- [GIT_OPTIONS]

which would look like delta dirA dirB -- --text.

@th1000s
Copy link
Contributor

th1000s commented May 7, 2024

The gitattributes are applied to the output before it is sent to delta or any other pager, see git diff | less - this is what delta works on, and it already mentions binary files.
Setting a different file via git -c core.attributesFile=my_gitattributes diff seemingly can not override the -diff setting.

However, in your specific case, @0xjac, PR #1697 will add an option so you can call -@=--text

@0xjac
Copy link

0xjac commented May 7, 2024

@th1000s I missed that PR. Thanks a lot, it seems perfect. I'll wait for it to be released. 馃殌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants