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)
| 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. |
| 622 | func (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 |
no test coverage detected