[Bug] autoCommit treats the edited file name as a git glob and commits other files too
Description
commitFile in source/services/auto-commit.ts passes the file path to git as a pathspec in git add -- (line 133), git diff --cached -- (lines 134-141) and git commit -m ... -- (line 146). The -- only stops option parsing. Git still treats [ab].txt as a glob, so it also matches a.txt and b.txt. Those files, including the user's uncommitted edits, end up in the agent's commit.
Environment
- OS: Windows 11 (10.0.26300)
- Node version: 22.22.3
- Nanocoder version: 1.31.0 (main at 5c2e693)
- Git: 2.55.0.windows.3
- Provider / Model: not relevant (reproduced by calling
maybeAutoCommitdirectly)
Steps to Reproduce
- Create a repo with committed
a.txtandb.txt. Turn onnanocoder.autoCommit. - Edit both files without committing.
- Let the agent create a new file named
[ab].txt. - Run
git show HEAD --name-only --format=.
Expected Behavior
Only [ab].txt is committed.
Actual Behavior
The commit chore: update [ab].txt contains all three files:
[ab].txt
a.txt
b.txt
Suggested Fix
Make git treat the path literally in all three calls: set GIT_LITERAL_PATHSPECS=1 for these git commands, or use git --literal-pathspecs, or prefix the path with :(literal). Add a test with a glob-named file next to the other cases in source/services/auto-commit.spec.ts.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder
hey @addyCooks, @akramcodez, i would like to work on this issue could please assign this to me.
plan - i'd like to take this. I'll make commitFile's git calls use --literal-pathspecs so file names aren't read as patterns.
Good approach @karthikponna, go for it !