diff --git a/environment.go b/environment.go index fa63d02eb6ce..4e649d899160 100755 --- a/environment.go +++ b/environment.go @@ -48,7 +48,7 @@ func (env *environment) getcwd() string { // on Windows, and being case sentisitive and not consistent and all, this gives silly issues return strings.Replace(pwd, "c:", "C:", 1) } - if env.args.PWD != nil && *env.args.PWD != "" { + if env.args != nil && *env.args.PWD != "" { return correctPath(*env.args.PWD) } dir, err := os.Getwd() diff --git a/segment_git.go b/segment_git.go index a5347cb69162..94435a709fd0 100755 --- a/segment_git.go +++ b/segment_git.go @@ -41,6 +41,8 @@ const ( BranchAheadIcon Property = "branch_ahead_icon" //BranchBehindIcon the icon to display when the local branch is behind the remote BranchBehindIcon Property = "branch_behind_icon" + //BranchGoneIcon the icon to use when ther's no remote + BranchGoneIcon Property = "branch_gone_icon" //LocalWorkingIcon the icon to use as the local working area changes indicator LocalWorkingIcon Property = "local_working_icon" //LocalStagingIcon the icon to use as the local staging area changes indicator @@ -74,7 +76,6 @@ func (g *git) string() string { if !displayStatus { return buffer.String() } - // TODO: Add upstream gone icon // if ahead, print with symbol if g.repo.ahead > 0 { fmt.Fprintf(buffer, " %s%d", g.props.getString(BranchAheadIcon, "+"), g.repo.ahead) @@ -83,8 +84,10 @@ func (g *git) string() string { if g.repo.behind > 0 { fmt.Fprintf(buffer, " %s%d", g.props.getString(BranchBehindIcon, "-"), g.repo.behind) } - if g.repo.behind == 0 && g.repo.ahead == 0 { + if g.repo.behind == 0 && g.repo.ahead == 0 && g.repo.upstream != "" { fmt.Fprintf(buffer, " %s", g.props.getString(BranchIdenticalIcon, "=")) + } else if g.repo.upstream == "" { + fmt.Fprintf(buffer, " %s", g.props.getString(BranchGoneIcon, "!=")) } // if staging, print that part if g.hasStaging() { diff --git a/segment_git_test.go b/segment_git_test.go index 173c05c66be4..5ef792d3685d 100755 --- a/segment_git_test.go +++ b/segment_git_test.go @@ -261,3 +261,11 @@ func TestParseGitBranchInfoBehindandAhead(t *testing.T) { assert.Equal(t, "2", got["behind"]) assert.Equal(t, "1", got["ahead"]) } + +func TestParseGitBranchInfoNoRemote(t *testing.T) { + g := git{} + branchInfo := "## master" + got := g.parseGitStatusInfo(branchInfo) + assert.Equal(t, "master", got["local"]) + assert.Empty(t, got["upstream"]) +}