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