Function: magit-process-git-arguments
magit-process-git-arguments is a byte-compiled function defined in
magit-git.el.
Signature
(magit-process-git-arguments ARGS &optional ASYNC)
Documentation
Prepare ARGS for a function that invokes Git.
Magit has many specialized functions for running Git; they all pass arguments through this function before handing them to Git, to do the following.
* Prepend magit-git-global-arguments to ARGS.
* If ASYNC is non-nil and magit-overriding-githook-directory is non-nil
and valid, set core.hooksPath by adding additional arguments to ARGS.
* Flatten ARGS, removing nil arguments.
* If system-type is windows-nt, encode ARGS to w32-ansi-code-page.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-git.el
(defun magit-process-git-arguments (args &optional async)
"Prepare ARGS for a function that invokes Git.
Magit has many specialized functions for running Git; they all
pass arguments through this function before handing them to Git,
to do the following.
* Prepend `magit-git-global-arguments' to ARGS.
* If ASYNC is non-nil and `magit-overriding-githook-directory' is non-nil
and valid, set `core.hooksPath' by adding additional arguments to ARGS.
* Flatten ARGS, removing nil arguments.
* If `system-type' is `windows-nt', encode ARGS to `w32-ansi-code-page'."
(cond ((not async))
(magit--overriding-githook-directory)
((eq magit-overriding-githook-directory 'magit)
(setq magit--overriding-githook-directory
(expand-file-name "git-hooks"
(locate-dominating-file
(locate-library "magit.el") "git-hooks"))))
((and magit-overriding-githook-directory
(file-directory-p magit-overriding-githook-directory))
(setq magit--overriding-githook-directory
magit-overriding-githook-directory)))
(setq args
(append magit-git-global-arguments
(and magit--overriding-githook-directory
(list "-c" (format "core.hooksPath=%s"
magit--overriding-githook-directory)))
(flatten-tree args)))
(if (and (eq system-type 'windows-nt) (boundp 'w32-ansi-code-page))
;; On w32, the process arguments *must* be encoded in the
;; current code-page (see #3250).
(mapcar (lambda (arg)
(encode-coding-string
arg (intern (format "cp%d" w32-ansi-code-page))))
args)
args))