Skip to content

Conversation

@AliSoftware
Copy link
Contributor

@AliSoftware AliSoftware commented Dec 15, 2025

Closes #16

Note

This PR is built on top of #18 (to benefit from its code cleanup)

What

This PR makes git-conceal status print a warning if .gitattributes file would be encrypted, with the suggestion to add .gitattributes !filter !diff line for it in .gitattributes itself to prevent that from happening.

Why

The .gitattributes file should never have the filter=git-conceal attribute applied, because that would mean that the .gitattributes file 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-conceal in their .gitattributes file explicitly on purpose. But it could happen if the .gitattributes file were to accidentally match a generic pattern (e.g. if the user has added .* filter=git-conceal to encrypt all files starting with a dot… which would accidentally include .gitattributes itself), so it's still nice to warn about it if we detect such edge case happening.

Testing

  • Checkout this PR's HEAD branch, and run make build-release. Then export PATH=$PWD/target/release:$PATH to have the built release git-conceal binary in your PATH.
  • cd into your working copy of PCAndroid and checkout the HEAD branch of this pocket-casts-android PR
  • Run git conceal status, and observe the warning is not printed. Same with git conceal status --json.
  • Edit .gitattributes and add a line at the end like .git* filter=git-conceal
  • Run git conceal status, and observe the warning is now shown. Same with git conceal status --json.
  • Revert your changes to .gitattributes
cat .gitattributes git conceal status

@AliSoftware AliSoftware self-assigned this Dec 15, 2025
@AliSoftware AliSoftware linked an issue Dec 15, 2025 that may be closed by this pull request
Base automatically changed from type-conversion-rustification to trunk December 15, 2025 19:37
Copy link
Contributor

@iangmaia iangmaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good 👍 and worked as expected when I tested it

⚠️  Warning: The `git-conceal` filter is applied to your `.gitattributes` file.

:shipit:

@iangmaia iangmaia merged commit d929550 into trunk Dec 17, 2025
4 checks passed
@iangmaia iangmaia deleted the warn-gitattributes-encrypted branch December 17, 2025 16:23
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 this pull request may close these issues.

Detect .gitattributes being applied the filter

3 participants