Skip to content

fix: match --git ignore patterns against relative paths - #1437

Merged
schollz merged 1 commit into
schollz:mainfrom
b84330808:fix-git-ignore-directory-patterns
Nov 12, 2026
Merged

schollz merged 1 commit into
schollz:mainfrom
b84330808:fix-git-ignore-directory-patterns

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

croc send --git <folder> matched each entry's base name against the folder's .gitignore, so directory patterns with a trailing slash (node_modules/, build/, __pycache__/) never matched and those folders were sent anyway. /dist matched at every depth and docs/generated/ never matched. The zip test even had to use build instead of build/ because of this.

This matches the path relative to the .gitignore, with a trailing slash for directories, and does the same for paths given on the command line (croc send --git *).

Folder with main.go, src/app.go, node_modules/pkg/index.js and .gitignore = node_modules/: before Sending 4 files and 4 folders, after Sending 3 files and 2 folders. Added TestGetFilesInfoGitIgnoreDirectoryPatterns (fails on main: node_modules/pkg/index.js and docs/generated/api.md are sent, lib/dist/keep.js is dropped), and the zip test now uses build/.

gitWalk matched each entry's base name, so directory patterns with a
trailing slash such as "node_modules/" never matched and those folders
were sent with --git. Patterns anchored to the .gitignore ("/dist")
matched at every depth, and patterns with a slash in the middle
("docs/generated/") never matched.

Match the path relative to the .gitignore, with a trailing slash for
directories, and do the same for the paths given on the command line.
@schollz
schollz merged commit cb04e2f into schollz:main Nov 12, 2026
6 checks passed
@schollz

schollz commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Thank you!

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.

2 participants