Function: treemacs--parse-git-status-simple
treemacs--parse-git-status-simple is a byte-compiled function defined
in treemacs-async.el.
Signature
(treemacs--parse-git-status-simple GIT-FUTURE)
Documentation
Parse the output of GIT-FUTURE into a hash table.
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-async.el
(defun treemacs--parse-git-status-simple (git-future)
"Parse the output of GIT-FUTURE into a hash table."
(-let [git-info-hash (make-hash-table :test #'equal :size 300)]
(when git-future
(pfuture-await-to-finish git-future)
(when (= 0 (process-exit-status git-future))
(-let [git-output (pfuture-result git-future)]
(unless (s-blank? git-output)
;; need the actual git root since git status outputs paths relative to it
;; and the output must be valid also for files in dirs being reopened
(let* ((git-root (vc-call-backend 'Git 'root (process-get git-future 'default-directory)))
(status-list (->> (substring git-output 0 -1)
(s-split "\0")
(--map (s-split-up-to " " (s-trim it) 1)))))
(let ((len (length status-list))
(i 0))
(while (< i len)
(let* ((status-cons (nth i status-list))
(status (car status-cons))
(path (cadr status-cons)))
;; don't include directories since only a part of the untracked dirs
;; would be shown anway
(unless (eq ?/ (aref path (1- (length path))))
;; there's a NUL after every filename, so a rename looks like
;; 'R oldnameNULnewnameNUL' which would break parsing that expects that a NUL separates
;; status entries and not just filenames
(if (eq ?R (aref status 0))
(setq i (1+ i))
(ht-set! git-info-hash
(treemacs-join-path git-root (s-trim-left path))
(treemacs--git-status-face
(substring (s-trim-left status) 0 1)
'treemacs-git-unmodified-face)))))
(setq i (1+ i)))))))))
git-info-hash))