Fix git status breaking in brand new repos with nil checks

This commit is contained in:
mir 2024-02-25 15:22:13 -09:00
parent f8d42c6828
commit 1502872174

View File

@ -236,15 +236,18 @@ Use 'window-width' to calculate the total final width."
(--> "git status -s" (--> "git status -s"
(shell-command-to-string it) (shell-command-to-string it)
(split-string it "\n" 'omit-nulls search-whitespace-regexp) (split-string it "\n" 'omit-nulls search-whitespace-regexp)
(if it
(--map (let ((parts (split-string it))) (--map (let ((parts (split-string it)))
(cons (car parts) (cadr parts))) (cons (car parts) (cadr parts)))
it))) it) nil)))
(branch (--> "git branch" (branch (--> "git branch"
(shell-command-to-string it) (shell-command-to-string it)
(split-string it "\n" 'omit-nulls search-whitespace-regexp) (split-string it "\n" 'omit-nulls search-whitespace-regexp)
(if it (progn
(--filter (string-match-p (rx bol "* " (+ word)) it) it) (--filter (string-match-p (rx bol "* " (+ word)) it) it)
(split-string (car it)) (split-string (car it))
(cadr it))) (cadr it))
"")))
(modcount (--> status-alist (modcount (--> status-alist
(--map (car it) it) (--map (car it) it)
(--count (string-match-p "M" it) it) (--count (string-match-p "M" it) it)