/** * Centralized git command wrapper. * All git commands should go through this module for consistency and testability. */ /** * Find the git repository root by walking up from the given directory. * * @param startDir - Directory to start searching from * @returns Path to git root, or null if not in a git repository */ export declare function gitFindRoot(startDir: string): string | null; /** * List files tracked by git, optionally filtered by patterns. * * @param options - Configuration options * @param options.cwd - Working directory (git repository root or subdirectory) * @param options.patterns - Optional glob patterns to filter files (e.g., '*.md', 'docs/**\/*.ts') * @param options.includeUntracked - Include untracked files that aren't gitignored (default: false) * @returns Array of file paths relative to the git root, or null if not in a git repo * * @example * ```typescript * // List all tracked markdown files * const files = gitLsFiles({ cwd: '/project', patterns: ['*.md', 'docs/**\/*.md'] }); * * // List all non-ignored files (tracked + untracked) * const allFiles = gitLsFiles({ cwd: '/project', includeUntracked: true }); * ``` */ export declare function gitLsFiles(options: { cwd: string; patterns?: string[]; includeUntracked?: boolean; }): string[] | null; /** * Check if a file path is ignored by git * * Uses git check-ignore which respects .gitignore, .git/info/exclude, and global gitignore. * * **Symlink handling**: When `git check-ignore` fails with exit code 128 ("beyond a symbolic * link"), this function walks up ancestor directories and checks each one. If any ancestor is * gitignored (e.g., `data/` is in `.gitignore`), the file is considered gitignored too. This * handles the common pattern where a gitignored directory contains symlinks to external content * (e.g., OneDrive, shared drives). * * **Outside a repository**: answered from the filesystem, with zero subprocesses (see below). * * **Performance warning**: This spawns a git subprocess for each file (plus up to N ancestor * checks when the path traverses a symlink). For bulk workflows, initialize a * {@link GitTracker} once and use `isIgnoredByActiveSet()` for O(1) in-repo lookups. * * @param filePath - Absolute or relative path to check * @param cwd - Working directory (defaults to process.cwd()) * @returns true if file is gitignored, false otherwise */ export declare function isGitIgnored(filePath: string, cwd?: string): boolean; //# sourceMappingURL=git-utils.d.ts.map