all repos — dotfiles @ 2ce3e9e9c6714e6ea7e780fdf606292efd7af0b4

my *nix dotfiles

prompt: Fix crash when ref is nil
Anirudh Oppiliappan x@icyphox.sh
Sun, 12 Sep 2021 09:46:39 +0530
commit

2ce3e9e9c6714e6ea7e780fdf606292efd7af0b4

parent

084354a68af04e082cff3ca42c2ec85e76bc0abf

1 files changed, 5 insertions(+), 0 deletions(-)

jump to
M prompt/git.goprompt/git.go

@@ -27,6 +27,11 @@

// Returns the current git branch or current ref sha. func gitBranch(repo *git.Repository) string { ref, _ := repo.Head() + // Quick hack to fix crash when ref is nil; + // i.e., new repo with no commits. + if ref == nil { + return "no commit" + } if ref.IsBranch() { name, _ := ref.Branch().Name() return name