Skip to content
New issue

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

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Escape special characters in filenames when git-ignoring files #4475

Merged
merged 2 commits into from
Apr 13, 2025

Conversation

stefanhaller
Copy link
Collaborator

  • PR Description

Some characters in file names need to be escaped so that they work correctly in .gitignore files. These include # and ! (only at the beginning of a filename), as well as [, ], and * anywhere in the name.

Fixes #4075
Fixes #4445

  • Please check if the PR fulfills these requirements
  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

@stefanhaller stefanhaller added the bug Something isn't working label Apr 10, 2025
Copy link

codacy-production bot commented Apr 10, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for d70a4051 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d70a405) Report Missing Report Missing Report Missing
Head commit (b0ab652) 54450 47225 86.73%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4475) 58 58 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

Copy link
Owner

@jesseduffield jesseduffield left a comment

Choose a reason for hiding this comment

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

LGTM

…racters

For #, !, [, and ], the problem is that it doesn't ignore the file because the
special characters need to be quoted. For *, the problem is that it ignores too
much (it also hides the abc_def file because the * is treated as a glob).
@jesseduffield jesseduffield force-pushed the escape-special-characters-when-ignoring-files branch from 3468de5 to b0ab652 Compare April 13, 2025 08:25
@jesseduffield jesseduffield merged commit d68c116 into master Apr 13, 2025
14 checks passed
@jesseduffield jesseduffield deleted the escape-special-characters-when-ignoring-files branch April 13, 2025 08:31
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
2 participants