From 150287217404b66a177cb2a8c4819b08016f5fc4 Mon Sep 17 00:00:00 2001 From: mir Date: Sun, 25 Feb 2024 15:22:13 -0900 Subject: [PATCH] Fix git status breaking in brand new repos with nil checks --- p11k.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/p11k.el b/p11k.el index 04aaf9c..6af6eda 100644 --- a/p11k.el +++ b/p11k.el @@ -236,15 +236,18 @@ Use 'window-width' to calculate the total final width." (--> "git status -s" (shell-command-to-string it) (split-string it "\n" 'omit-nulls search-whitespace-regexp) - (--map (let ((parts (split-string it))) - (cons (car parts) (cadr parts))) - it))) + (if it + (--map (let ((parts (split-string it))) + (cons (car parts) (cadr parts))) + it) nil))) (branch (--> "git branch" (shell-command-to-string it) (split-string it "\n" 'omit-nulls search-whitespace-regexp) - (--filter (string-match-p (rx bol "* " (+ word)) it) it) - (split-string (car it)) - (cadr it))) + (if it (progn + (--filter (string-match-p (rx bol "* " (+ word)) it) it) + (split-string (car it)) + (cadr it)) + ""))) (modcount (--> status-alist (--map (car it) it) (--count (string-match-p "M" it) it)