Skip to content

CLI: a script-safe way to get a workspace's changes out #41

Closed

Description

@lydakis

Found while dogfooding sandfs in a cloud container (fix for #31 made entirely inside a FUSE-mounted fork, PR #40).

Getting the changes out took a hand-written loop. After working in a fork, the files had to be copied to a real folder. The only way was to parse sandfs changes output:

sandfs changes work | while read k p; do case $k in A|M) mkdir -p "$(dirname "$p")"; cp "$W/$p" "$p";; D) rm -f "$p";; esac; done

That breaks on names with leading spaces or newlines, since sandfs changes prints one K path line per file with no quoting. Two small options, either enough:

  1. sandfs changes -0 (or --json): NUL-separated or JSON output, so scripts can't misread a name. The MCP tool now quotes such paths (Quote MCP paths that hold control characters #40).
  2. sandfs changes NAME --copy-to DIR: copy added and modified files into DIR and remove deleted ones. This writes only where the user explicitly points it, never back into a source implicitly.

Tool caches show up as changes. Running a build inside the fork wrote 288 cache files, which buried the 2 real changes in sandfs changes. Pointing the cache outside the mount (an env var) fixed it. Any program that writes temp or cache files next to its inputs will do the same. A path argument (sandfs changes NAME [PATH], like the MCP tool's path) would let a caller look at one subtree; anything more is probably the harness's job.

Not touching the CLI now since the performance work is changing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions