Function: magit-git-string

magit-git-string is a byte-compiled function defined in magit-git.el.

Signature

(magit-git-string &rest ARGS)

Documentation

Execute Git with ARGS, returning the first line of its output (stdout).

If the exit code isn't zero or if there is no output, then return nil. Neither of these results is considered an error; if that is what you want, then use magit-git-string-ng instead.

Aliases

magit-git-string-p (obsolete since Magit 4.6.0)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit-git-string (&rest args)
  "Execute Git with ARGS, returning the first line of its output (stdout).
If the exit code isn't zero or if there is no output, then return nil.
Neither of these results is considered an error; if that is what you
want, then use `magit-git-string-ng' instead."
  (setq args (flatten-tree args))
  (magit--with-refresh-cache (cons default-directory args)
    (magit--with-temp-process-buffer
      (and (zerop (apply #'magit-git-insert args))
           (not (bobp))
           (progn
             (goto-char (point-min))
             (buffer-substring-no-properties (point) (line-end-position)))))))