From 86136ce6152d2125a53fa98adb6e6ed4db949190 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 25 Jan 2024 02:23:56 -0600 Subject: avoid a few nil's Signed-off-by: Jeff Carr --- git.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'git.go') diff --git a/git.go b/git.go index 67def68..a004ef2 100644 --- a/git.go +++ b/git.go @@ -153,6 +153,20 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) { } func (rs *RepoStatus) SetMainWorkingName(s string) { + if rs == nil { + log.Info("rs == nil", s) + return + } + if rs.gitConfig == nil { + log.Info("rs.gitConfig == nil", s) + rs.mainWorkingName.SetValue(s) + return + } + if rs.gitConfig.branches == nil { + log.Info("rs.gitConfig.branches == nil", s) + rs.mainWorkingName.SetValue(s) + return + } _, ok := rs.gitConfig.branches[s] if ok { log.Info("git branch", s, "seems to exist") -- cgit v1.2.3