/**
 * Git Merge Utilities
 *
 * Shared squash-merge-in-temp-worktree logic used by both the Merge Steward
 * and the Docs Steward services.
 *
 * Pattern:
 *  1. Fetch origin (skipped when local-only / no remote)
 *  2. (Optional) Pre-flight conflict detection via git merge-tree
 *  3. Create temp worktree with detached HEAD at origin/<target> or local <target>
 *  4. Squash merge (or regular merge) source branch
 *  5. Commit with provided message
 *  6. Push HEAD:<target> to remote (skipped when local-only)
 *  7. Remove temp worktree (always, in finally)
 *  8. (Optional) Sync local target branch via fast-forward
 *
 * Local-only mode is auto-detected when no 'origin' remote exists, or can
 * be forced via the `localOnly` option in MergeBranchOptions.
 *
 * @module
 */
export interface MergeBranchOptions {
    /** Workspace root (the main repo checkout) */
    workspaceRoot: string;
    /** Branch to merge from */
    sourceBranch: string;
    /** Branch to merge into (auto-detected if omitted) */
    targetBranch?: string;
    /** 'squash' (default) or 'merge' (--no-ff) */
    mergeStrategy?: 'squash' | 'merge';
    /** Push to remote after merge (default: true) */
    autoPush?: boolean;
    /** Commit message (required for squash, auto-generated for merge) */
    commitMessage?: string;
    /** Run pre-flight conflict detection via merge-tree (default: true) */
    preflight?: boolean;
    /** Fast-forward local target branch after push (default: true) */
    syncLocal?: boolean;
    /**
     * When true, skip all remote operations (fetch, push).
     * Auto-detected when no remote named 'origin' is configured.
     */
    localOnly?: boolean;
}
export interface MergeBranchResult {
    /** Whether the merge succeeded */
    success: boolean;
    /** Merge/squash commit hash if successful */
    commitHash?: string;
    /** Whether a conflict was detected */
    hasConflict: boolean;
    /** Error message if merge failed */
    error?: string;
    /** Files with conflicts, if any */
    conflictFiles?: string[];
    /** Whether the source branch was already fully merged into the target (zero commits ahead) */
    alreadyMerged?: boolean;
}
/**
 * Run a git command in a worktree directory.
 * Refuses to run in the workspace root to prevent corrupting the main repo HEAD.
 */
export declare function execGitSafe(command: string, worktreePath: string, workspaceRoot: string): Promise<{
    stdout: string;
    stderr: string;
}>;
/**
 * Check whether a named remote exists in the repo.
 *
 * Runs `git remote get-url <remoteName>` which exits 0 when the remote
 * exists and non-zero otherwise.
 */
export declare function hasRemote(workspaceRoot: string, remoteName?: string): Promise<boolean>;
/**
 * Canonical branch detection function.
 *
 * All consumers in the codebase should delegate to this single function
 * to ensure consistent default-branch detection everywhere. The unified
 * fallback order is:
 *
 *  1. `configBaseBranch` (if provided — from user configuration)
 *  2. `git symbolic-ref refs/remotes/origin/HEAD` (most reliable remote indicator)
 *  3. `git remote show origin` HEAD branch (slower but authoritative)
 *  4. Check existence of origin/main, then origin/master
 *  5. Check existence of local main, then local master
 *  6. Fallback: "main"
 *
 * @param workspaceRoot - The git repository root directory
 * @param configBaseBranch - Optional config-provided base branch name (checked first)
 */
export declare function detectTargetBranch(workspaceRoot: string, configBaseBranch?: string): Promise<string>;
/**
 * Perform a merge of `sourceBranch` into `targetBranch` using a temporary
 * worktree. This never touches the main repo's HEAD or index.
 */
export declare function mergeBranch(options: MergeBranchOptions): Promise<MergeBranchResult>;
/**
 * Fast-forward the local target branch ref to match origin, without
 * the dangerous checkout dance.
 *
 * - When NOT on the target branch: `git fetch origin target:target`
 *   updates the local ref without touching the working tree at all.
 * - When ON the target branch: `git merge --ff-only origin/target`
 *   fast-forwards in place (unavoidably touches working tree files).
 * - If either fails (e.g. non-ff divergence): logs a warning and
 *   returns silently. The merge is already pushed to remote.
 */
export declare function syncLocalBranch(workspaceRoot: string, targetBranch: string): Promise<void>;
/**
 * Fast-forward the local target branch to a specific commit hash.
 *
 * Used in local-only mode where there is no remote to sync from.
 * Updates the branch ref directly using `git branch -f` when not on
 * the target branch, or `git merge --ff-only <hash>` when on it.
 */
export declare function syncLocalBranchFromCommit(workspaceRoot: string, targetBranch: string, commitHash: string): Promise<void>;
//# sourceMappingURL=merge.d.ts.map