From 4599d09dc26634e4fce69fc6df40cd5c15b3d5de Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sat, 19 Aug 2017 21:00:34 +0200 Subject: prompt: handle newly initialized Git repo without any commits correctly --- pkg/prompt/git.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pkg/prompt') diff --git a/pkg/prompt/git.go b/pkg/prompt/git.go index 20f9445..054df36 100644 --- a/pkg/prompt/git.go +++ b/pkg/prompt/git.go @@ -63,8 +63,12 @@ func getRepoStatusField(repoRootPath string) string { bytes, err = ioutil.ReadFile(filepath.Join(repoRootPath, ".git", refSpec)) commitID := strings.TrimSpace(string(bytes)) if err != nil { - handleError(err) - commitID = withColor("1;41", "unknown") + if os.IsNotExist(err) { + commitID = withColor("37", "blank") + } else { + handleError(err) + commitID = withColor("1;41", "unknown") + } } return formatRepoStatusField(refSpecDisplay, commitID) -- cgit v1.3.1