fix: show log for a specific reference

Ayman Bagabas created

don't reset log reference when already set

Change summary

pkg/git/repo.go       |  5 ++++-
pkg/tui/log/bubble.go | 12 +++++++-----
2 files changed, 11 insertions(+), 6 deletions(-)

Detailed changes

pkg/git/repo.go 🔗

@@ -7,8 +7,11 @@ import (
 )
 
 var (
-	DiffMaxFiles     = 1000
+	// DiffMaxFile is the maximum number of files to show in a diff.
+	DiffMaxFiles = 1000
+	// DiffMaxFileLines is the maximum number of lines to show in a file diff.
 	DiffMaxFileLines = 1000
+	// DiffMaxLineChars is the maximum number of characters to show in a line diff.
 	DiffMaxLineChars = 1000
 )
 

pkg/tui/log/bubble.go 🔗

@@ -136,12 +136,14 @@ func (b *Bubble) reset() tea.Cmd {
 	errMsg := func(err error) tea.Cmd {
 		return func() tea.Msg { return common.ErrMsg{Err: err} }
 	}
-	ref, err := b.repo.HEAD()
-	if err != nil {
-		return errMsg(err)
+	if b.ref == nil {
+		ref, err := b.repo.HEAD()
+		if err != nil {
+			return errMsg(err)
+		}
+		b.ref = ref
 	}
-	b.ref = ref
-	count, err := b.repo.CountCommits(ref)
+	count, err := b.repo.CountCommits(b.ref)
 	if err != nil {
 		return errMsg(err)
 	}