{"record":{"id":"1f70b9127f865c27","repo":"paperclipai/paperclip","slug":"source-and-target-paperclip-configs-are-the-same-1f70b9","errorCode":null,"errorMessage":"Source and target Paperclip configs are the same. Choose different --from/--to worktrees.","messagePattern":"Source and target Paperclip configs are the same\\. Choose different --from/--to worktrees\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":3309,"sourceCode":"  if (opts.apply && opts.dry) {\n    throw new Error(\"Use either --apply or --dry, not both.\");\n  }\n\n  if (sourceArg && opts.from) {\n    throw new Error(\"Use either the positional source argument or --from, not both.\");\n  }\n\n  const targetEndpoint = opts.to\n    ? resolveWorktreeEndpointFromSelector(opts.to, { allowCurrent: true })\n    : resolveCurrentWorktreeEndpoint();\n  const sourceEndpoint = opts.from\n    ? resolveWorktreeEndpointFromSelector(opts.from, { allowCurrent: true })\n    : sourceArg\n      ? resolveWorktreeEndpointFromSelector(sourceArg, { allowCurrent: true })\n      : await promptForSourceEndpoint(targetEndpoint.rootPath);\n\n  if (path.resolve(sourceEndpoint.configPath) === path.resolve(targetEndpoint.configPath)) {\n    throw new Error(\"Source and target Paperclip configs are the same. Choose different --from/--to worktrees.\");\n  }\n\n  const scopes = parseWorktreeMergeScopes(opts.scope);\n  const sourceHandle = await openConfiguredDb(sourceEndpoint.configPath);\n  const targetHandle = await openConfiguredDb(targetEndpoint.configPath);\n  const sourceStorages = resolveAttachmentLookupStorages({\n    sourceEndpoint,\n    targetEndpoint,\n  });\n  const targetStorage = openConfiguredStorage(targetEndpoint.configPath);\n\n  try {\n    const company = await resolveMergeCompany({\n      sourceDb: sourceHandle.db,\n      targetDb: targetHandle.db,\n      selector: opts.company,\n    });\n    let collected = await collectMergePlan({","sourceCodeStart":3291,"sourceCodeEnd":3327,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L3291-L3327","documentation":"Thrown by worktreeMergeHistoryCommand after resolving both endpoints when path.resolve(sourceEndpoint.configPath) === path.resolve(targetEndpoint.configPath). Merging a worktree into itself is a no-op at best and corrupts counts at worst, so the CLI refuses. The check is on the config file path, meaning two different selectors that resolve to the same worktree (e.g. --from current --to current, or a branch name whose worktree is the current checkout) trip it.","triggerScenarios":"Calling merge-history where --from and --to resolve to the same worktree: omitting both (both default to current), passing --from current with default --to, or passing a branch/dir selector that points at the current checkout.","commonSituations":"A developer forgets to set --to and the default (current) happens to equal --from. Or they pass --from <branch> where <branch> is checked out in the current worktree.","solutions":["Set --to explicitly to a different worktree: `paperclipai worktree:merge-history --from current --to <other>`.","If you only have one instance, use `worktree reseed` with a different source config instead."],"exampleFix":"// before\npaperclipai worktree:merge-history --from current\n// after\npaperclipai worktree:merge-history --from current --to /path/to/target-worktree --apply","handlingStrategy":"validation","validationCode":"import path from \"node:path\";\n\nfunction validateDistinctEndpoints(sourceConfigPath: string, targetConfigPath: string): void {\n  if (path.resolve(sourceConfigPath) === path.resolve(targetConfigPath)) {\n    throw new Error(\"Source and target Paperclip configs are the same. Choose different --from/--to worktrees.\");\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --to explicitly when using --from current (and vice versa) so the defaults cannot collide.","In scripts, assert the resolved config paths differ before invoking merge-history."],"tags":["worktree","cli","merge","validation"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}