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, potentially add additional arguments to load
the hook configuration in "/path/to/magit/githooks/config" and/or
magit-user-githook-file.
* 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-20260822.1158/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, potentially add additional arguments to load
the hook configuration in \"/path/to/magit/githooks/config\" and/or
`magit-user-githook-file'.
* Flatten ARGS, removing nil arguments.
* If `system-type' is `windows-nt', encode ARGS to `w32-ansi-code-page'."
(let ((githookp (and async
(magit-git-version>= "2.54")
(not (file-remote-p default-directory)))))
(cond
((not githookp))
(magit-githook-directory)
((and (stringp magit-run-hooks-from-githooks)
(file-directory-p magit-run-hooks-from-githooks))
(setq magit-githook-directory
(magit-convert-filename-for-git
magit-run-hooks-from-githooks)))
(magit-run-hooks-from-githooks
(setq magit-githook-directory
(magit-convert-filename-for-git
(expand-file-name "githooks"
(locate-dominating-file
(locate-library "magit.el") "githooks"))))))
(setq args
(append magit-git-global-arguments
(and githookp
magit-githook-directory
`("-c" ,(format "include.path=%s/config"
magit-githook-directory)
,@(and magit-user-githook-file
(file-exists-p magit-user-githook-file)
`("-c" ,(concat "include.path="
magit-user-githook-file)))))
(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).
(let ((coding (intern (format "cp%d" w32-ansi-code-page))))
(mapcar (##encode-coding-string % coding) args))
args))