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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-crypt support? #1509

Closed
MinmoTech opened this issue Apr 2, 2020 · 9 comments · Fixed by #1837
Closed

git-crypt support? #1509

MinmoTech opened this issue Apr 2, 2020 · 9 comments · Fixed by #1837

Comments

@MinmoTech
Copy link

If I try to use :Gdiffsplit in a project that is encrypted with git-crypt, it always tries to diff with an encrypted file.

If i do a git diff or a git difftool on the commandline it works properly.
Is it possible to configure fugitive to work properly with git crypt?

@Parasrah
Copy link

Parasrah commented Apr 2, 2020

this seems to be a duplicate of #1508, albeit with more info

@tpope
Copy link
Owner

tpope commented Apr 2, 2020

We currently use git cat-file to populate the diff buffer. If you can provide a ore appropriate command to swap in it's possible we could support it.

@tpope tpope closed this as completed Apr 2, 2020
@YorikSar
Copy link
Contributor

@tpope Since git 2.11 (released in 2016) you can pass --filter instead of blob to git cat-file and it will process it with filters if applicable, including git-crypt. I think it should be enough replacing blob with --filter on lines 2112 and 2955 in autoload/fugitive.vim, but I don't really know if it will break smith else.

If you have to support older Git, maybe add an option for that? Like "supported Git version" or smth.

@tpope
Copy link
Owner

tpope commented Sep 10, 2021

The only breakage I can think of is that for the second case, the rev is not guaranteed to contain a :path. To address the path issue and the version issue in one go, try rev =~# ':' && fugitive#GitVersion(2, 11) ? '--filters' : 'blob'.

Please try the change out locally for a week or so and report back on your experience.

@YorikSar
Copy link
Contributor

Thanks for the direction. I've created commit YorikSar/vim-fugitive@58c6f2f and will test it for some time (I don't use git-crypt a lot, so it'll take about a month to be sure), then will create a pull request. Feel free to comment on that commit in the mean time.

YorikSar added a commit to YorikSar/dotfiles that referenced this issue Sep 13, 2021
@tpope
Copy link
Owner

tpope commented Sep 13, 2021

Limitations:

  • staging/unstaging separate hunks (ala "git add -p") doesn't work, because "git apply" doesn't know about filters, same as "git add -p".

Is this a limitation related to your patch, or just of using git-crypt with Fugitive in general?

@YorikSar
Copy link
Contributor

It's a limitation of the git-crypt in general. git add -p (even without vim-fugitive) always complains that the encrypted file is binary and exits.

@tpope
Copy link
Owner

tpope commented Sep 13, 2021

Alright let's ditch that from the commit message before sending a PR then just to minimize confusion.

And on that note, send a PR whenever, a release isn't imminent so your light testing is probably good enough.

@YorikSar
Copy link
Contributor

Ok, you're the boss! Created #1837.

tpope pushed a commit that referenced this issue Sep 13, 2021
Starting with Git 2.11 cat-file provides --filters option that can be
specified instead of "blob" type. This option tells Git to use all
filters specified in .gitattributes.

This enables diffs for files with filters, for example, git-crypt.

Closes #1509
YorikSar added a commit to YorikSar/dotfiles that referenced this issue Oct 3, 2021
This reverts commit 97b50f8.

The fix has been applied to vim-fugitive proper.
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

Successfully merging a pull request may close this issue.

4 participants