beads/internal/storage/versioncontrolops
Bùi Phan Viết Cường 0e2e2a4741
fix(dolt): scrub stderr-directed git tracing before git-remote transfers (#5323)
* fix(dolt): scrub stderr-directed git tracing before git-remote transfers

Dolt's git blobstore drives git plumbing through a runner that captures
stdout and stderr into a single buffer and parses object ids out of the
result (store/blobstore/internal/git/runner.go). Any stderr chatter
therefore corrupts every captured value: with GIT_TRACE=1 in the
environment, bd dolt push/fetch/clone against a git+ remote dies with
"failed to get remote db", and the credential hints Dolt appends to the
error point the user at auth instead of tracing. #3996 fixed the same
combined-output class in bd's own git helpers, but the vendored Dolt
runner is out of reach.

What bd can do is keep the poison out of the environment the runner
inherits. New internal/gittraceenv knows the GIT_TRACE* family and
strips only stderr-directed values: absolute-path targets
(GIT_TRACE=/tmp/log) and trace2 af_unix: sockets keep working, and
disabled values (0/false/empty) are left alone. Like githooksenv it
refcounts a process-wide scope so concurrent remote ops nest safely.

Wiring mirrors #5186: the in-process CALL DOLT_PUSH/FETCH/CLONE path
gets the scrub through a single withRemoteEnvGuards helper in
versioncontrolops, which now owns both env guards so a call site cannot
pick up one and silently miss the other, and the dolt CLI fallback
scrubs the child environment in prepareDoltCLITransferCommand.

Repro on stock bd, any git+file remote: GIT_TRACE=1 bd dolt push fails
every time; with this change the traced and untraced pushes both pass.

* fix(dolt): close git-trace scrub gaps from review

The scrub covered the in-process engine path and the dolt CLI transfer
route, but three subprocess spawns still inherited stderr-directed git
tracing, and the value classifier accepted af_unix: targets for
variables that do not support them.

- githooksenv gains DisabledEnv, the subprocess-env counterpart of
  WithDisabled, with exec last-wins replace semantics. Combined with
  gittraceenv.ScrubEnv it forms the guarded env every dolt spawn that
  can touch a git-protocol remote needs, so a spawn site cannot pick up
  one guard and miss the other.

- Server spawns: the directly-managed sql-server spawn and the proxied
  one now build their child env through a shared
  doltserver.ServerSpawnEnv(). A server auto-started from a shell
  carrying GIT_TRACE=1 no longer poisons every server-side git-protocol
  transfer until restart.

- Bootstrap clone: BootstrapFromRemoteWithDB spawns dolt clone via
  bootstrapCloneCmd with the guarded env; it does not route through
  prepareDoltCLITransferCommand, so it needs the guards itself.

- remotecache: cross-rig cache push/clone/pull spawn dolt through one
  doltCmd choke point with the guarded env; previously all three
  inherited the caller's environment with neither guard.

- Classifier: stderrDirected is name-aware; af_unix:[<mode>:]<path> is
  a file target only for the GIT_TRACE2 family, so GIT_TRACE=af_unix:...
  is now scrubbed instead of drawing "warning: unknown trace value" on
  stderr per plumbing call. On Windows, env names match
  case-insensitively (Set Git_Trace=1 enables tracing in the child all
  the same) and a leading dir separator counts as a file target, the
  way git's is_absolute_path reads it.

- domain/db: the dormant Fetch/Push/Pull/Clone verbs get a comment
  routing future wiring to the right guard site. The Runner behind this
  repository is a connection to the sql-server, so the git plumbing
  spawns from the server's environment — process-env guards in bd would
  be inert here; ServerSpawnEnv at spawn time is the protection.

Regression tests assert the guarded env at each spawn site (effective
GIT_CONFIG_PARAMETERS via last-wins Extract), the survival of
file-target tracing, and the classifier table including the Windows
name/path semantics.

---------

Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
2026-08-10 05:25:15 -07:00
..
automerge.go fix(automerge): settled merges must mint a row_lock distinct from both parents (absorbed from #4682) (#5245) 2026-08-02 06:21:35 -07:00
automerge_test.go fix(automerge): settled merges must mint a row_lock distinct from both parents (absorbed from #4682) (#5245) 2026-08-02 06:21:35 -07:00
backup.go fix: suppress auto-backup address conflict warning (#2927) 2026-04-02 20:28:47 -07:00
backup_test.go fix: suppress auto-backup address conflict warning (#2927) 2026-04-02 20:28:47 -07:00
blocked_recompute.go feat(recompute-blocked): port to proxied-server mode + cross-mode cascade parity suite (bd-04vav) (#5363) 2026-08-05 12:11:53 -07:00
branches.go /{cmd,internal}: wip sync and data EmbeddedDoltStore methods 2026-03-24 12:01:16 -07:00
clone.go fix(dolt): scrub stderr-directed git tracing before git-remote transfers (#5323) 2026-08-10 05:25:15 -07:00
clone_test.go fix: pass remote auth user during clone (#4484) 2026-07-05 11:28:24 -07:00
commit.go fix(storage): skip empty Dolt commit when nothing is staged (re-port of #4288) (#5403) 2026-08-07 10:32:31 -07:00
commit_empty_test.go fix(storage): skip empty Dolt commit when nothing is staged (re-port of #4288) (#5403) 2026-08-07 10:32:31 -07:00
compact.go fix(gc): prune remote-tracking refs before post-squash GC (bd-agctw) 2026-07-18 07:26:17 -07:00
conflicts.go fix(automerge): tell a no-op merge write from a vanished row (wy-o8swn) 2026-07-25 04:50:05 -07:00
conflicts_test.go fix(automerge): tell a no-op merge write from a vanished row (wy-o8swn) 2026-07-25 04:50:05 -07:00
db.go /{cmd,internal}: wip sync and data EmbeddedDoltStore methods 2026-03-24 12:01:16 -07:00
envguards.go fix(dolt): scrub stderr-directed git tracing before git-remote transfers (#5323) 2026-08-10 05:25:15 -07:00
fastforward.go feat(gate): non-destructive fast-forward adopt detection (adopt-ff, #4551 follow-up 2) (#4586) 2026-07-07 05:58:28 -07:00
fastforward_test.go feat(gate): non-destructive fast-forward adopt detection (adopt-ff, #4551 follow-up 2) (#4586) 2026-07-07 05:58:28 -07:00
flatten.go fix(gc): prune remote-tracking refs before post-squash GC (bd-agctw) 2026-07-18 07:26:17 -07:00
gc.go Use Snappy output for Dolt garbage collection (#4986) 2026-07-23 08:55:29 -07:00
gc_test.go Use Snappy output for Dolt garbage collection (#4986) 2026-07-23 08:55:29 -07:00
mergesettle.go fix(vc): make merge --strategy actually resolve conflicts (autocommit was rejecting first) (#4992) (#5119) 2026-07-28 17:52:51 -07:00
remoterefs.go fix(gc): prune remote-tracking refs before post-squash GC (bd-agctw) 2026-07-18 07:26:17 -07:00
remotes.go fix(dolt): scrub stderr-directed git tracing before git-remote transfers (#5323) 2026-08-10 05:25:15 -07:00
remotes_githooks_test.go fix(dolt): disable git hooks on the in-process push path too (#4272) (#5186) 2026-07-31 09:42:50 -07:00
remotes_gittrace_test.go fix(dolt): scrub stderr-directed git tracing before git-remote transfers (#5323) 2026-08-10 05:25:15 -07:00
version_control.go fix(vc): make merge --strategy actually resolve conflicts (autocommit was rejecting first) (#4992) (#5119) 2026-07-28 17:52:51 -07:00