MCPcopy Create free account
hub / github.com/LegacyCodeHQ/clarity-cli / GetCommitDeletedFiles

Function GetCommitDeletedFiles

vcs/git/git_diff.go:293–317  ·  view source on GitHub ↗

GetCommitDeletedFiles finds all files that were deleted by a specific commit. Returns absolute paths. Their content no longer exists in the commit, so read it from the commit's parent (see ResolveFirstParent).

(repoPath, commitID string)

Source from the content-addressed store, hash-verified

291// Returns absolute paths. Their content no longer exists in the commit, so read
292// it from the commit's parent (see ResolveFirstParent).
293func GetCommitDeletedFiles(repoPath, commitID string) ([]string, error) {
294 if _, err := os.Stat(repoPath); os.IsNotExist(err) {
295 return nil, fmt.Errorf("repository path does not exist: %s", repoPath)
296 }
297 if !isGitRepository(repoPath) {
298 return nil, fmt.Errorf("%s is not a git repository (use 'git init' to initialize)", repoPath)
299 }
300 if err := validateCommit(repoPath, commitID); err != nil {
301 return nil, err
302 }
303
304 repoRoot, err := GetRepositoryRoot(repoPath)
305 if err != nil {
306 return nil, fmt.Errorf("failed to get repository root: %w", err)
307 }
308
309 // --diff-filter=D (uppercase) selects only deleted files, the inverse of the
310 // lowercase d used elsewhere to exclude them.
311 stdout, stderr, err := runGitCommand(repoPath, "diff-tree", "--no-commit-id", "--name-only", "-r", "--root", "--diff-filter=D", commitID)
312 if err != nil {
313 return nil, gitCommandError(err, stderr)
314 }
315
316 return toAbsolutePaths(repoRoot, parseNonEmptyLines(stdout)), nil
317}
318
319// GetCommitRangeDeletedFiles finds all files deleted between two commits.
320// Returns absolute paths. Their content should be read from fromCommit.

Calls 7

isGitRepositoryFunction · 0.85
validateCommitFunction · 0.85
GetRepositoryRootFunction · 0.85
runGitCommandFunction · 0.85
gitCommandErrorFunction · 0.85
toAbsolutePathsFunction · 0.85
parseNonEmptyLinesFunction · 0.85