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

Method workspaceTrackedDiff

internal/diff/git.go:622–636  ·  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

620// failure if there was one. Stderr is returned separately so the caller can
621// quote it without risking diff content in the error; see runGitSplit.
622func (p *Provider) workspaceTrackedDiff(ctx context.Context) (string, string, error) {
623 resolution, err := p.ResolveWorkspaceComparison(ctx)
624 if err != nil {
625 return "", "", err
626 }
627 base := resolution.ResolvedBase
628 if resolution.BaseIsEmpty {
629 out, stderr, err := p.runGitSplit(ctx, "hash-object", "-t", "tree", "--stdin")
630 if err != nil {
631 return "", stderr, err
632 }
633 base = strings.TrimSpace(out)
634 }
635 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, "--")
636}
637
638// binarySniffWindow is the number of leading bytes inspected when deciding
639// 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