diff --git a/src/segments/git.go b/src/segments/git.go index 1ac5de3e..df120ab9 100644 --- a/src/segments/git.go +++ b/src/segments/git.go @@ -146,9 +146,6 @@ func (g *Git) Template() string { } func (g *Git) Enabled() bool { - statusFormats := g.props.GetKeyValueMap(StatusFormats, map[string]string{}) - g.Working = &GitStatus{ScmStatus: ScmStatus{Formats: statusFormats}} - g.Staging = &GitStatus{ScmStatus: ScmStatus{Formats: statusFormats}} g.User = &User{} if !g.shouldDisplay() { @@ -489,8 +486,9 @@ func (g *Git) setGitStatus() { ) // firstly assume that upstream is gone g.UpstreamGone = true - g.Working = &GitStatus{} - g.Staging = &GitStatus{} + statusFormats := g.props.GetKeyValueMap(StatusFormats, map[string]string{}) + g.Working = &GitStatus{ScmStatus: ScmStatus{Formats: statusFormats}} + g.Staging = &GitStatus{ScmStatus: ScmStatus{Formats: statusFormats}} untrackedMode := g.getUntrackedFilesMode() args := []string{"status", untrackedMode, "--branch", "--porcelain=2"} ignoreSubmodulesMode := g.getIgnoreSubmodulesMode() diff --git a/src/segments/git_test.go b/src/segments/git_test.go index 076f6981..8f112bab 100644 --- a/src/segments/git_test.go +++ b/src/segments/git_test.go @@ -554,6 +554,8 @@ func TestSetGitStatus(t *testing.T) { if tc.ExpectedStaging == nil { tc.ExpectedStaging = &GitStatus{} } + tc.ExpectedStaging.Formats = map[string]string{} + tc.ExpectedWorking.Formats = map[string]string{} g.setGitStatus() assert.Equal(t, tc.ExpectedStaging, g.Staging, tc.Case) assert.Equal(t, tc.ExpectedWorking, g.Working, tc.Case)