Skip to content

Commit 9ddf6d7

Browse files
committed
git.el: Remove the env parameter in git-call-process and git-call-process-string.
All callers that need to change the environment now set process-environment themselves. Signed-off-by: Alexandre Julliard <julliard@winehq.org>
1 parent 36d2078 commit 9ddf6d7

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

contrib/emacs/git.el

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,9 @@ if there is already one that displays the same directory."
183183
"Build a list of NAME=VALUE strings from a list of environment strings."
184184
(mapcar (lambda (entry) (concat (car entry) "=" (cdr entry))) env))
185185

186-
(defun git-call-process-env (buffer env &rest args)
186+
(defun git-call-process (buffer &rest args)
187187
"Wrapper for call-process that sets environment strings."
188-
(let ((process-environment (append (git-get-env-strings env)
189-
process-environment)))
190-
(apply #'call-process "git" nil buffer nil args)))
188+
(apply #'call-process "git" nil buffer nil args))
191189

192190
(defun git-call-process-display-error (&rest args)
193191
"Wrapper for call-process that displays error messages."
@@ -197,22 +195,22 @@ if there is already one that displays the same directory."
197195
(let ((default-directory dir)
198196
(buffer-read-only nil))
199197
(erase-buffer)
200-
(eq 0 (apply 'call-process "git" nil (list buffer t) nil args))))))
198+
(eq 0 (apply #'git-call-process (list buffer t) args))))))
201199
(unless ok (display-message-or-buffer buffer))
202200
ok))
203201

204-
(defun git-call-process-env-string (env &rest args)
205-
"Wrapper for call-process that sets environment strings,
206-
and returns the process output as a string, or nil if the git failed."
202+
(defun git-call-process-string (&rest args)
203+
"Wrapper for call-process that returns the process output as a string,
204+
or nil if the git command failed."
207205
(with-temp-buffer
208-
(and (eq 0 (apply #' git-call-process-env t env args))
206+
(and (eq 0 (apply #'git-call-process t args))
209207
(buffer-string))))
210208

211209
(defun git-call-process-string-display-error (&rest args)
212210
"Wrapper for call-process that displays error message and returns
213211
the process output as a string, or nil if the git command failed."
214212
(with-temp-buffer
215-
(if (eq 0 (apply #'git-call-process-env (list t t) nil args))
213+
(if (eq 0 (apply #'git-call-process (list t t) args))
216214
(buffer-string)
217215
(display-message-or-buffer (current-buffer))
218216
nil)))
@@ -235,7 +233,7 @@ the process output as a string, or nil if the git command failed."
235233
(let ((default-directory dir)
236234
(buffer-read-only nil))
237235
(erase-buffer)
238-
(apply #'git-call-process-env buffer nil args)))
236+
(apply #'git-call-process buffer args)))
239237
(message "Running git %s...done" (car args))
240238
buffer))
241239

@@ -336,7 +334,7 @@ the process output as a string, or nil if the git command failed."
336334
(let ((cdup (with-output-to-string
337335
(with-current-buffer standard-output
338336
(cd dir)
339-
(unless (eq 0 (call-process "git" nil t nil "rev-parse" "--show-cdup"))
337+
(unless (eq 0 (git-call-process t "rev-parse" "--show-cdup"))
340338
(error "cannot find top-level git tree for %s." dir))))))
341339
(expand-file-name (concat (file-name-as-directory dir)
342340
(car (split-string cdup "\n"))))))
@@ -357,7 +355,7 @@ the process output as a string, or nil if the git command failed."
357355
(sort-lines nil (point-min) (point-max))
358356
(save-buffer))
359357
(when created
360-
(git-call-process-env nil nil "update-index" "--add" "--" (file-relative-name ignore-name)))
358+
(git-call-process nil "update-index" "--add" "--" (file-relative-name ignore-name)))
361359
(git-update-status-files (list (file-relative-name ignore-name)) 'unknown)))
362360

363361
; propertize definition for XEmacs, stolen from erc-compat
@@ -376,16 +374,16 @@ the process output as a string, or nil if the git command failed."
376374
(defun git-rev-parse (rev)
377375
"Parse a revision name and return its SHA1."
378376
(git-get-string-sha1
379-
(git-call-process-env-string nil "rev-parse" rev)))
377+
(git-call-process-string "rev-parse" rev)))
380378

381379
(defun git-config (key)
382380
"Retrieve the value associated to KEY in the git repository config file."
383-
(let ((str (git-call-process-env-string nil "config" key)))
381+
(let ((str (git-call-process-string "config" key)))
384382
(and str (car (split-string str "\n")))))
385383

386384
(defun git-symbolic-ref (ref)
387385
"Wrapper for the git-symbolic-ref command."
388-
(let ((str (git-call-process-env-string nil "symbolic-ref" ref)))
386+
(let ((str (git-call-process-string "symbolic-ref" ref)))
389387
(and str (car (split-string str "\n")))))
390388

391389
(defun git-update-ref (ref newval &optional oldval reason)
@@ -463,7 +461,7 @@ the process output as a string, or nil if the git command failed."
463461

464462
(defun git-empty-db-p ()
465463
"Check if the git db is empty (no commit done yet)."
466-
(not (eq 0 (call-process "git" nil nil nil "rev-parse" "--verify" "HEAD"))))
464+
(not (eq 0 (git-call-process nil "rev-parse" "--verify" "HEAD"))))
467465

468466
(defun git-get-merge-heads ()
469467
"Retrieve the merge heads from the MERGE_HEAD file if present."
@@ -479,7 +477,7 @@ the process output as a string, or nil if the git command failed."
479477
(defun git-get-commit-description (commit)
480478
"Get a one-line description of COMMIT."
481479
(let ((coding-system-for-read (git-get-logoutput-coding-system)))
482-
(let ((descr (git-call-process-env-string nil "log" "--max-count=1" "--pretty=oneline" commit)))
480+
(let ((descr (git-call-process-string "log" "--max-count=1" "--pretty=oneline" commit)))
483481
(if (and descr (string-match "\\`\\([0-9a-f]\\{40\\}\\) *\\(.*\\)$" descr))
484482
(concat (substring (match-string 1 descr) 0 10) " - " (match-string 2 descr))
485483
descr))))
@@ -655,7 +653,7 @@ Return the list of files that haven't been handled."
655653
(let ((remaining (copy-sequence files))
656654
infolist)
657655
(with-temp-buffer
658-
(apply #'git-call-process-env t nil "diff-index" "-z" "-M" "HEAD" "--" files)
656+
(apply #'git-call-process t "diff-index" "-z" "-M" "HEAD" "--" files)
659657
(goto-char (point-min))
660658
(while (re-search-forward
661659
":\\([0-7]\\{6\\}\\) \\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\(\\([ADMUT]\\)\0\\([^\0]+\\)\\|\\([CR]\\)[0-9]*\0\\([^\0]+\\)\0\\([^\0]+\\)\\)\0"
@@ -688,7 +686,7 @@ Return the list of files that haven't been handled."
688686
Return the list of files that haven't been handled."
689687
(let (infolist)
690688
(with-temp-buffer
691-
(apply #'git-call-process-env t nil "ls-files" "-z" (append options (list "--") files))
689+
(apply #'git-call-process t "ls-files" "-z" (append options (list "--") files))
692690
(goto-char (point-min))
693691
(while (re-search-forward "\\([^\0]*?\\)\\(/?\\)\0" nil t 1)
694692
(let ((name (match-string 1)))
@@ -705,7 +703,7 @@ Return the list of files that haven't been handled."
705703
(let ((remaining (copy-sequence files))
706704
infolist)
707705
(with-temp-buffer
708-
(apply #'git-call-process-env t nil "ls-files" "-z" "-s" "-c" "--" files)
706+
(apply #'git-call-process t "ls-files" "-z" "-s" "-c" "--" files)
709707
(goto-char (point-min))
710708
(while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} 0\t\\([^\0]+\\)\0" nil t)
711709
(let* ((new-perm (string-to-number (match-string 1) 8))
@@ -719,7 +717,7 @@ Return the list of files that haven't been handled."
719717
(defun git-run-ls-unmerged (status files)
720718
"Run git-ls-files -u on FILES and parse the results into STATUS."
721719
(with-temp-buffer
722-
(apply #'git-call-process-env t nil "ls-files" "-z" "-u" "--" files)
720+
(apply #'git-call-process t "ls-files" "-z" "-u" "--" files)
723721
(goto-char (point-min))
724722
(let (unmerged-files)
725723
(while (re-search-forward "[0-7]\\{6\\} [0-9a-f]\\{40\\} [123]\t\\([^\0]+\\)\0" nil t)
@@ -893,8 +891,8 @@ Return the list of files that haven't been handled."
893891
(condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
894892
(with-current-buffer buffer (erase-buffer))
895893
(git-update-status-files (git-get-filenames files) 'uptodate)
896-
(git-call-process-env nil nil "rerere")
897-
(git-call-process-env nil nil "gc" "--auto")
894+
(git-call-process nil "rerere")
895+
(git-call-process nil "gc" "--auto")
898896
(git-refresh-files)
899897
(git-refresh-ewoc-hf git-status)
900898
(message "Committed %s." commit)
@@ -1311,7 +1309,7 @@ Return the list of files that haven't been handled."
13111309
(let (author-name author-email subject date msg)
13121310
(with-temp-buffer
13131311
(let ((coding-system (git-get-logoutput-coding-system)))
1314-
(git-call-process-env t nil "log" "-1" "--pretty=medium" commit)
1312+
(git-call-process t "log" "-1" "--pretty=medium" commit)
13151313
(goto-char (point-min))
13161314
(when (re-search-forward "^Author: *\\(.*\\) <\\(.*\\)>$" nil t)
13171315
(setq author-name (match-string 1))
@@ -1331,7 +1329,7 @@ Return the list of files that haven't been handled."
13311329
"Retrieve the list of files modified by COMMIT."
13321330
(let (files)
13331331
(with-temp-buffer
1334-
(git-call-process-env t nil "diff-tree" "-r" "-z" "--name-only" "--no-commit-id" commit)
1332+
(git-call-process t "diff-tree" "-r" "-z" "--name-only" "--no-commit-id" commit)
13351333
(goto-char (point-min))
13361334
(while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
13371335
(push (match-string 1) files)))
@@ -1395,7 +1393,7 @@ amended version of it."
13951393
(cur-name (and pos (git-fileinfo->name (ewoc-data pos)))))
13961394
(unless status (error "Not in git-status buffer."))
13971395
(message "Refreshing git status...")
1398-
(git-call-process-env nil nil "update-index" "--refresh")
1396+
(git-call-process nil "update-index" "--refresh")
13991397
(git-clear-status status)
14001398
(git-update-status-files nil)
14011399
; restore file marks
@@ -1588,7 +1586,7 @@ Meant to be used in `after-save-hook'."
15881586
(let ((filename (file-relative-name file dir)))
15891587
; skip files located inside the .git directory
15901588
(unless (string-match "^\\.git/" filename)
1591-
(git-call-process-env nil nil "add" "--refresh" "--" filename)
1589+
(git-call-process nil "add" "--refresh" "--" filename)
15921590
(git-update-status-files (list filename) 'uptodate)))))))
15931591

15941592
(defun git-help ()

0 commit comments

Comments
 (0)