Warn if .gitattributes is encrypted
#19
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #16
Note
This PR is built on top of #18 (to benefit from its code cleanup)
What
This PR makes
git-conceal statusprint a warning if.gitattributesfile would be encrypted, with the suggestion to add.gitattributes !filter !diffline for it in.gitattributesitself to prevent that from happening.Why
The
.gitattributesfile should never have thefilter=git-concealattribute applied, because that would mean that the.gitattributesfile itself would get encrypted (which would make it impossible for git to parse on checkout of a fresh clone, and thus would not allow git to know which files to decrypt…)Context
This case should rarely be encountered in practice, as we don't expect users to explicitly add
.gitattributes filter=git-concealin their.gitattributesfile explicitly on purpose. But it could happen if the.gitattributesfile were to accidentally match a generic pattern (e.g. if the user has added.* filter=git-concealto encrypt all files starting with a dot… which would accidentally include.gitattributesitself), so it's still nice to warn about it if we detect such edge case happening.Testing
make build-release. Thenexport PATH=$PWD/target/release:$PATHto have the built releasegit-concealbinary in your PATH.cdinto your working copy of PCAndroid and checkout the HEAD branch of this pocket-casts-android PRgit conceal status, and observe the warning is not printed. Same withgit conceal status --json..gitattributesand add a line at the end like.git* filter=git-concealgit conceal status, and observe the warning is now shown. Same withgit conceal status --json..gitattributes