MCPcopy Create free account
hub / github.com/alibaba/open-code-review / workspaceTrackedDiff

Method workspaceTrackedDiff

internal/diff/git.go:628–642  ·  view source on GitHub ↗

workspaceTrackedDiff returns the tracked-file diff, git's stderr, and the failure if there was one. Stderr is returned separately so the caller can quote it without risking diff content in the error; see runGitSplit.

(ctx context.Context)

Source from the content-addressed store, hash-verified

626// failure if there was one. Stderr is returned separately so the caller can
627// quote it without risking diff content in the error; see runGitSplit.
628func (p *Provider) workspaceTrackedDiff(ctx context.Context) (string, string, error) {
629 resolution, err := p.ResolveWorkspaceComparison(ctx)
630 if err != nil {
631 return "", "", err
632 }
633 base := resolution.ResolvedBase
634 if resolution.BaseIsEmpty {
635 out, stderr, err := p.runGitSplit(ctx, "hash-object", "-t", "tree", "--stdin")
636 if err != nil {
637 return "", stderr, err
638 }
639 base = strings.TrimSpace(out)
640 }
641 return p.runGitSplit(ctx, "--no-optional-locks", "-c", "core.quotepath=false", "-c", "diff.autoRefreshIndex=false", "diff", "--no-ext-diff", "--no-textconv", "--find-renames", "--src-prefix=a/", "--dst-prefix=b/", "--no-color", "-U"+fmt.Sprint(DiffContextLines), "--end-of-options", base, "--")
642}
643
644// binarySniffWindow is the number of leading bytes inspected when deciding
645// whether an untracked file is binary. Matches git's own heuristic and the

Callers 1

GetDiffSetMethod · 0.95

Calls 2

runGitSplitMethod · 0.95

Tested by

no test coverage detected