[PR #12185] fix: prevent snapshot from tracking large files #14108

Open
opened 2026-02-16 18:18:55 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12185

State: open
Merged: No


This PR prevents the Snapshot.track() flow from adding (untracked) big files into the snapshot system (git).

It changes the code to first do git add -N . which stage the files without content.
Next it iterates over the staged files to find any files larger then defined threshold (1 gig). unstages them AND adds them to $gitdir/info/exclude to prevent them from getting staged again.
Finally it calls git add -- $stagedFiles to stage the files content as well.

To handle existing bloated snapshot dirs, the cleanup method was updated to detect if any existing object blob is bigger then threshold -> nukes the whole snapshot dir.
Leaving the big files causes the git gc --prune process to blow up on memory and hog the system.

Additionally, this PR cleans up the Snapshot code a bit.

Don't be scared from the lines added, I've added tests too 😆

Fixes #6845

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12185 **State:** open **Merged:** No --- This PR prevents the `Snapshot.track()` flow from adding (untracked) big files into the snapshot system (git). It changes the code to first do `git add -N .` which stage the files **without content**. Next it iterates over the staged files to find any files larger then defined threshold (1 gig). unstages them AND adds them to $gitdir/info/exclude to prevent them from getting staged again. Finally it calls `git add -- $stagedFiles` to stage the files content as well. To handle existing bloated snapshot dirs, the cleanup method was updated to detect if any existing object blob is bigger then threshold -> nukes the whole snapshot dir. Leaving the big files causes the `git gc --prune` process to blow up on memory and hog the system. Additionally, this PR cleans up the Snapshot code a bit. Don't be scared from the lines added, I've added tests too 😆 Fixes #6845
yindo added the pull-request label 2026-02-16 18:18:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14108