diff --git a/src/segment_git.go b/src/segment_git.go index e02fe8a9..88c00186 100644 --- a/src/segment_git.go +++ b/src/segment_git.go @@ -280,6 +280,8 @@ func (g *git) setGitStatus() { UPSTREAM = "# branch.upstream " BRANCHSTATUS = "# branch.ab " ) + g.Working = &GitStatus{} + g.Staging = &GitStatus{} output := g.getGitCommandOutput("status", "-unormal", "--branch", "--porcelain=2") for _, line := range strings.Split(output, "\n") { if strings.HasPrefix(line, HASH) { diff --git a/src/segment_git_test.go b/src/segment_git_test.go index feebbe1c..501a3cd4 100644 --- a/src/segment_git_test.go +++ b/src/segment_git_test.go @@ -364,8 +364,6 @@ func TestSetGitStatus(t *testing.T) { if tc.ExpectedStaging == nil { tc.ExpectedStaging = &GitStatus{} } - g.Working = &GitStatus{} - g.Staging = &GitStatus{} g.setGitStatus() assert.Equal(t, tc.ExpectedStaging, g.Staging, tc.Case) assert.Equal(t, tc.ExpectedWorking, g.Working, tc.Case)