Skip to content

Commit 950b2e6

Browse files
that-github-userunknownclaude
authored
Fix git add regression: use git reset instead of pathspec exclusion (#93)
The :!node_modules pathspec causes errors on repos that gitignore node_modules. Instead, stage everything then unstage node_modules if it got picked up from the worktree symlink. Co-authored-by: unknown <that-github-user@github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4d30513 commit 950b2e6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/utils/git.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ export async function getDiff(worktreePath: string): Promise<string> {
7878
try {
7979
// Include both staged and unstaged changes relative to HEAD
8080
// Exclude node_modules symlink (created by createWorktree for tool access)
81-
await exec("git", ["add", "-A", "--", ".", ":!node_modules"], { cwd: worktreePath });
81+
await exec("git", ["add", "-A"], { cwd: worktreePath });
82+
// Unstage node_modules symlink if it got picked up (created by createWorktree)
83+
await exec("git", ["reset", "HEAD", "--", "node_modules"], { cwd: worktreePath }).catch(() => {});
8284
const { stdout } = await exec("git", ["diff", "--cached", "HEAD"], {
8385
cwd: worktreePath,
8486
});
@@ -95,7 +97,9 @@ export async function getDiffStats(
9597
worktreePath: string,
9698
): Promise<{ filesChanged: string[]; linesAdded: number; linesRemoved: number }> {
9799
try {
98-
await exec("git", ["add", "-A", "--", ".", ":!node_modules"], { cwd: worktreePath });
100+
await exec("git", ["add", "-A"], { cwd: worktreePath });
101+
// Unstage node_modules symlink if it got picked up (created by createWorktree)
102+
await exec("git", ["reset", "HEAD", "--", "node_modules"], { cwd: worktreePath }).catch(() => {});
99103
const { stdout } = await exec("git", ["diff", "--cached", "--stat", "HEAD"], {
100104
cwd: worktreePath,
101105
});

0 commit comments

Comments
 (0)