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>
Alexandre Julliard committed
Nov 1, 2008 at 20:42 UTC
9ddf6d7c105e58d76ea6762d8cc8eebdf463903e
1 file changed
+26
-28
contrib/emacs/git.el
+26
-28
@@ -183,11 +183,9 @@ if there is already one that displays the same directory."
183
"Build a list of NAME=VALUE strings from a list of environment strings."
184
(mapcar (lambda (entry) (concat (car entry) "=" (cdr entry))) env))
185
186
-(defun git-call-process-env (buffer env &rest args)
186
+(defun git-call-process (buffer &rest args)
187
"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))
189
190
(defun git-call-process-display-error (&rest args)
191
"Wrapper for call-process that displays error messages."
@@ -197,22 +195,22 @@ if there is already one that displays the same directory."
195
(let ((default-directory dir)
196
(buffer-read-only nil))
197
(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))))))
199
(unless ok (display-message-or-buffer buffer))
200
ok))
201
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."
205
(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))
207
(buffer-string))))
208
209
(defun git-call-process-string-display-error (&rest args)
210
"Wrapper for call-process that displays error message and returns
211
the process output as a string, or nil if the git command failed."
212
(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))
214
(buffer-string)
215
(display-message-or-buffer (current-buffer))
216
nil)))
@@ -235,7 +233,7 @@ the process output as a string, or nil if the git command failed."
233
(let ((default-directory dir)
234
(buffer-read-only nil))
235
(erase-buffer)
238
- (apply #'git-call-process-env buffer nil args)))
236
+ (apply #'git-call-process buffer args)))
237
(message "Running git %s...done" (car args))
238
buffer))
239
@@ -336,7 +334,7 @@ the process output as a string, or nil if the git command failed."
334
(let ((cdup (with-output-to-string
335
(with-current-buffer standard-output
336
(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"))
338
(error "cannot find top-level git tree for %s." dir))))))
339
(expand-file-name (concat (file-name-as-directory dir)
340
(car (split-string cdup "\n"))))))
@@ -357,7 +355,7 @@ the process output as a string, or nil if the git command failed."
355
(sort-lines nil (point-min) (point-max))
356
(save-buffer))
357
(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)))
359
(git-update-status-files (list (file-relative-name ignore-name)) 'unknown)))
360
361
; 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."
374
(defun git-rev-parse (rev)
375
"Parse a revision name and return its SHA1."
376
(git-get-string-sha1
379
- (git-call-process-env-string nil "rev-parse" rev)))
377
+ (git-call-process-string "rev-parse" rev)))
378
379
(defun git-config (key)
380
"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)))
382
(and str (car (split-string str "\n")))))
383
384
(defun git-symbolic-ref (ref)
385
"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)))
387
(and str (car (split-string str "\n")))))
388
389
(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."
461
462
(defun git-empty-db-p ()
463
"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"))))
465
466
(defun git-get-merge-heads ()
467
"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."
477
(defun git-get-commit-description (commit)
478
"Get a one-line description of COMMIT."
479
(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)))
481
(if (and descr (string-match "\\`\\([0-9a-f]\\{40\\}\\) *\\(.*\\)$" descr))
482
(concat (substring (match-string 1 descr) 0 10) " - " (match-string 2 descr))
483
descr))))
@@ -655,7 +653,7 @@ Return the list of files that haven't been handled."
653
(let ((remaining (copy-sequence files))
654
infolist)
655
(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)
657
(goto-char (point-min))
658
(while (re-search-forward
659
":\\([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."
686
Return the list of files that haven't been handled."
687
(let (infolist)
688
(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))
690
(goto-char (point-min))
691
(while (re-search-forward "\\([^\0]*?\\)\\(/?\\)\0" nil t 1)
692
(let ((name (match-string 1)))
@@ -705,7 +703,7 @@ Return the list of files that haven't been handled."
703
(let ((remaining (copy-sequence files))
704
infolist)
705
(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)
707
(goto-char (point-min))
708
(while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} 0\t\\([^\0]+\\)\0" nil t)
709
(let* ((new-perm (string-to-number (match-string 1) 8))
@@ -719,7 +717,7 @@ Return the list of files that haven't been handled."
717
(defun git-run-ls-unmerged (status files)
718
"Run git-ls-files -u on FILES and parse the results into STATUS."
719
(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)
721
(goto-char (point-min))
722
(let (unmerged-files)
723
(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."
891
(condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
892
(with-current-buffer buffer (erase-buffer))
893
(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")
896
(git-refresh-files)
897
(git-refresh-ewoc-hf git-status)
898
(message "Committed %s." commit)
@@ -1311,7 +1309,7 @@ Return the list of files that haven't been handled."
1309
(let (author-name author-email subject date msg)
1310
(with-temp-buffer
1311
(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)
1313
(goto-char (point-min))
1314
(when (re-search-forward "^Author: *\\(.*\\) <\\(.*\\)>$" nil t)
1315
(setq author-name (match-string 1))
@@ -1331,7 +1329,7 @@ Return the list of files that haven't been handled."
1329
"Retrieve the list of files modified by COMMIT."
1330
(let (files)
1331
(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)
1333
(goto-char (point-min))
1334
(while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
1335
(push (match-string 1) files)))
@@ -1395,7 +1393,7 @@ amended version of it."
1393
(cur-name (and pos (git-fileinfo->name (ewoc-data pos)))))
1394
(unless status (error "Not in git-status buffer."))
1395
(message "Refreshing git status...")
1398
- (git-call-process-env nil nil "update-index" "--refresh")
1396
+ (git-call-process nil "update-index" "--refresh")
1397
(git-clear-status status)
1398
(git-update-status-files nil)
1399
; restore file marks
@@ -1588,7 +1586,7 @@ Meant to be used in `after-save-hook'."
1586
(let ((filename (file-relative-name file dir)))
1587
; skip files located inside the .git directory
1588
(unless (string-match "^\\.git/" filename)
1591
- (git-call-process-env nil nil "add" "--refresh" "--" filename)
1589
+ (git-call-process nil "add" "--refresh" "--" filename)
1590
(git-update-status-files (list filename) 'uptodate)))))))
1591
1592
(defun git-help ()