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)
| 608 | // firstLine returns the first non-empty trimmed line of git output, so a stray |
| 609 | // trailing newline or an unexpected second line never pollutes a resolved SHA. |
| 610 | func firstLine(out string) string { |
| 611 | for _, line := range strings.Split(out, "\n") { |
| 612 | if s := strings.TrimSpace(line); s != "" { |
| 613 | return s |
| 614 | } |
| 615 | } |
| 616 | return "" |
| 617 | } |
| 618 | |
| 619 | // workspaceTrackedDiff returns the tracked-file diff, git's stderr, and the |
| 620 | // failure if there was one. Stderr is returned separately so the caller can |
no outgoing calls