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)
| 566 | // failure if there was one. Stderr is returned separately so the caller can |
| 567 | // quote it without risking diff content in the error; see runGitSplit. |
| 568 | func (p *Provider) workspaceTrackedDiff(ctx context.Context) (string, string, error) { |
| 569 | out, _, err := p.runGitSplit(ctx, "-c", "core.quotepath=false", "diff", "--no-ext-diff", "--no-textconv", "--find-renames", "--src-prefix=a/", "--dst-prefix=b/", "--no-color", "-U"+fmt.Sprint(DiffContextLines), "--end-of-options", "HEAD", "--") |
| 570 | if err == nil && out != "" { |
| 571 | return out, "", nil |
| 572 | } |
| 573 | if ctx.Err() != nil { |
| 574 | return "", "", ctx.Err() |
| 575 | } |
| 576 | // Fall back to the staged diff when `git diff HEAD` errored or was empty. This is |
| 577 | // not redundant with the call above: in a repository with no commits yet there is no |
| 578 | // HEAD, so `git diff HEAD` fails with "bad revision 'HEAD'", but `git diff --staged` |
| 579 | // still surfaces staged changes by diffing the index against the empty tree — the only |
| 580 | // way to review a workspace before its first commit. |
| 581 | return p.runGitSplit(ctx, "-c", "core.quotepath=false", "diff", "--no-ext-diff", "--no-textconv", "--find-renames", "--src-prefix=a/", "--dst-prefix=b/", "--no-color", "-U"+fmt.Sprint(DiffContextLines), "--staged", "--") |
| 582 | } |
| 583 | |
| 584 | func (p *Provider) untrackedFileDiffs(ctx context.Context) ([]string, error) { |
| 585 | files, err := p.untrackedFilesList(ctx) |
no test coverage detected