summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2022-05-05 21:41:44 +0900
committerRyooooooga <eial5q265e5@gmail.com>2022-05-05 21:41:44 +0900
commit2eb866fc622c76fb30c27f5cfdf66f163f1181e5 (patch)
tree9e51cc358b6f05ac85658291394be56258ddcf0b /pkg
parentf143d04d87320eda588a35763e4dcb562cc59047 (diff)
fix: fix a crash when pressing enter in empty commits, reflog, or stash panel
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/context/branches_context.go6
-rw-r--r--pkg/gui/context/local_commits_context.go6
-rw-r--r--pkg/gui/context/reflog_commits_context.go6
-rw-r--r--pkg/gui/context/remote_branches_context.go6
-rw-r--r--pkg/gui/context/stash_context.go6
-rw-r--r--pkg/gui/context/sub_commits_context.go6
-rw-r--r--pkg/gui/context/tags_context.go6
7 files changed, 35 insertions, 7 deletions
diff --git a/pkg/gui/context/branches_context.go b/pkg/gui/context/branches_context.go
index e64a83137..ba1982cbf 100644
--- a/pkg/gui/context/branches_context.go
+++ b/pkg/gui/context/branches_context.go
@@ -58,5 +58,9 @@ func (self *BranchesContext) GetSelectedItemId() string {
}
func (self *BranchesContext) GetSelectedRef() types.Ref {
- return self.GetSelected()
+ branch := self.GetSelected()
+ if branch == nil {
+ return nil
+ }
+ return branch
}
diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go
index c5fcc769a..7432cab95 100644
--- a/pkg/gui/context/local_commits_context.go
+++ b/pkg/gui/context/local_commits_context.go
@@ -84,7 +84,11 @@ func (self *LocalCommitsContext) CanRebase() bool {
}
func (self *LocalCommitsContext) GetSelectedRef() types.Ref {
- return self.GetSelected()
+ commit := self.GetSelected()
+ if commit == nil {
+ return nil
+ }
+ return commit
}
func (self *LocalCommitsViewModel) SetLimitCommits(value bool) {
diff --git a/pkg/gui/context/reflog_commits_context.go b/pkg/gui/context/reflog_commits_context.go
index 33c162aaf..1062009e9 100644
--- a/pkg/gui/context/reflog_commits_context.go
+++ b/pkg/gui/context/reflog_commits_context.go
@@ -62,7 +62,11 @@ func (self *ReflogCommitsContext) CanRebase() bool {
}
func (self *ReflogCommitsContext) GetSelectedRef() types.Ref {
- return self.GetSelected()
+ commit := self.GetSelected()
+ if commit == nil {
+ return nil
+ }
+ return commit
}
func (self *ReflogCommitsContext) GetCommits() []*models.Commit {
diff --git a/pkg/gui/context/remote_branches_context.go b/pkg/gui/context/remote_branches_context.go
index affcedf97..d8e9a91bf 100644
--- a/pkg/gui/context/remote_branches_context.go
+++ b/pkg/gui/context/remote_branches_context.go
@@ -61,5 +61,9 @@ func (self *RemoteBranchesContext) GetSelectedItemId() string {
}
func (self *RemoteBranchesContext) GetSelectedRef() types.Ref {
- return self.GetSelected()
+ remoteBranch := self.GetSelected()
+ if remoteBranch == nil {
+ return nil
+ }
+ return remoteBranch
}
diff --git a/pkg/gui/context/stash_context.go b/pkg/gui/context/stash_context.go
index 53d854669..89e0a250d 100644
--- a/pkg/gui/context/stash_context.go
+++ b/pkg/gui/context/stash_context.go
@@ -62,5 +62,9 @@ func (self *StashContext) CanRebase() bool {
}
func (self *StashContext) GetSelectedRef() types.Ref {
- return self.GetSelected()
+ stash := self.GetSelected()
+ if stash == nil {
+ return nil
+ }
+ return stash
}
diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go
index d9a1e7c6b..a58502ad0 100644
--- a/pkg/gui/context/sub_commits_context.go
+++ b/pkg/gui/context/sub_commits_context.go
@@ -83,7 +83,11 @@ func (self *SubCommitsContext) CanRebase() bool {
}
func (self *SubCommitsContext) GetSelectedRef() types.Ref {
- return self.GetSelected()
+ commit := self.GetSelected()
+ if commit == nil {
+ return nil
+ }
+ return commit
}
func (self *SubCommitsContext) GetCommits() []*models.Commit {
diff --git a/pkg/gui/context/tags_context.go b/pkg/gui/context/tags_context.go
index 09285aa76..e0a647868 100644
--- a/pkg/gui/context/tags_context.go
+++ b/pkg/gui/context/tags_context.go
@@ -58,5 +58,9 @@ func (self *TagsContext) GetSelectedItemId() string {
}
func (self *TagsContext) GetSelectedRef() types.Ref {
- return self.GetSelected()
+ tag := self.GetSelected()
+ if tag == nil {
+ return nil
+ }
+ return tag
}