Skip to content

Add support for git-crypt#81983

Closed
mikeseese wants to merge 1 commit into
microsoft:masterfrom
mikeseese:feat/gitcrypt-diff-support
Closed

Add support for git-crypt#81983
mikeseese wants to merge 1 commit into
microsoft:masterfrom
mikeseese:feat/gitcrypt-diff-support

Conversation

@mikeseese

Copy link
Copy Markdown
Contributor

This PR resolves #34330 by adding support for git-crypt, a tool which encrypts and decrypts files as a git filter.

Currently VS Code does not properly show diffs for files that are encrypted on the remote but decrypted locally.

Here is some of the current behavior:

A file will have no changes (see below that production.yaml doesn't show up in the git status panel) but will show in the editor that the whole file was modified:

image

We can see here when bringing up the inline diffs, that it's comparing the decrypted local file with the encrypted HEAD version:

image

Lastly, when the file is changed (shown below as showing up in the git status on the panel), and the git diff is opened, the diff isn't shown because the left side is the binary version:

image

This PR is fairly simple, and doesn't attempt to solve the total scope of adding generic support for any and all filters. However, I hope this can get accepted in the meantime before that solution is realized to support this specific issue.

This PR checks after a git show to see if the buffer contains a magic word that indicates it is a git-crypt encrypted blob. If it is, then it runs it into git-crypt smudge which will decrypt the contents appropriately. This resolves all of the cases mentioned above.

A potential implementation for solving the generic issue would be to read .gitattributes for the file being git show'd and see what the filter is and hand that as the program to execute the blob on. However, this would require significantly more testing which was out of scope for the work I'm doing.

@joaomoreno joaomoreno added the git GIT issues label Oct 7, 2019
@martin-css

Copy link
Copy Markdown

This looks like a git-crypt specific version of #81395 which I'd coincidentally submitted a few day prior.

This approach is certainly simpler whereas mine was focused more on support for a generic git filter. Regardless of whatever is thought to be best, would be nice to have git-crypt file diffs working properly!

@mikeseese

Copy link
Copy Markdown
Contributor Author

I would definitely prefer a generic solution rather than a specific one. Nice find (of this PR) @martin-css! I'll take a look at your PR

@mikeseese

Copy link
Copy Markdown
Contributor Author

Closing in favor of #81395

@mikeseese mikeseese closed this May 20, 2020
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

git GIT issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git: Support git-crypt

3 participants