firstLine returns the first non-empty trimmed line of git output, so a stray trailing newline or an unexpected second line never pollutes a resolved SHA.
(out string)
| 524 | // firstLine returns the first non-empty trimmed line of git output, so a stray |
| 525 | // trailing newline or an unexpected second line never pollutes a resolved SHA. |
| 526 | func firstLine(out string) string { |
| 527 | for _, line := range strings.Split(out, "\n") { |
| 528 | if s := strings.TrimSpace(line); s != "" { |
| 529 | return s |
| 530 | } |
| 531 | } |
| 532 | return "" |
| 533 | } |
| 534 | |
| 535 | func (p *Provider) workspaceTrackedDiff(ctx context.Context) (string, error) { |
| 536 | out, err := p.runGit(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", "--") |
no outgoing calls