diff --git a/cmd/bd/sync.go b/cmd/bd/sync.go index bcbc8557..9f800b7d 100644 --- a/cmd/bd/sync.go +++ b/cmd/bd/sync.go @@ -166,6 +166,8 @@ Use --merge to merge the sync branch back to main branch.`, // GH#885: Preflight check for uncommitted JSONL changes // This detects when a previous sync exported but failed before commit, // leaving the JSONL in an inconsistent state across worktrees. + // Track if we already exported during pre-flight to avoid redundant export later. + alreadyExported := false if hasUncommitted, err := gitHasUncommittedBeadsChanges(ctx); err != nil { fmt.Fprintf(os.Stderr, "Warning: failed to check for uncommitted changes: %v\n", err) } else if hasUncommitted { @@ -176,6 +178,7 @@ Use --merge to merge the sync branch back to main branch.`, FatalError("re-exporting to reconcile state: %v", err) } fmt.Println("✓ State reconciled") + alreadyExported = true } // GH#638: Check sync.branch BEFORE upstream check @@ -287,7 +290,7 @@ Use --merge to merge the sync branch back to main branch.`, } } - if !skipExport { + if !skipExport && !alreadyExported { // Pre-export integrity checks if err := ensureStoreActive(); err == nil && store != nil { if err := validatePreExport(ctx, store, jsonlPath); err != nil {