branch: elpa/git-commit commit b4b2098c91fbc4c6a5a4299e440ec065b572092e Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
Use with-environment-variables --- lisp/magit-commit.el | 23 ++++++++++--------- lisp/magit-extras.el | 62 +++++++++++++++++++++++++------------------------- lisp/magit-git.el | 4 +--- lisp/magit-sequence.el | 14 +++++------- lisp/magit.el | 11 ++++----- 5 files changed, 55 insertions(+), 59 deletions(-) diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el index 2b90762a5b..a5d4943cfb 100644 --- a/lisp/magit-commit.el +++ b/lisp/magit-commit.el @@ -267,10 +267,11 @@ to inverse the meaning of the prefix argument. \n(git commit magit-commit-extend-override-date))) (when (setq args (magit-commit-assert args)) (magit-commit-amend-assert) - (let ((process-environment process-environment)) - (unless override-date - (push (magit-rev-format "GIT_COMMITTER_DATE=%cD") process-environment)) - (magit-run-git-with-editor "commit" "--amend" "--no-edit" args)))) + (if override-date + (magit-run-git-with-editor "commit" "--amend" "--no-edit" args) + (with-environment-variables + (("GIT_COMMITTER_DATE" (magit-rev-format "%cD"))) + (magit-run-git-with-editor "commit" "--amend" "--no-edit" args))))) ;;;###autoload (defun magit-commit-reword (&optional args override-date) @@ -288,11 +289,12 @@ and ignore the option. (not magit-commit-reword-override-date) magit-commit-reword-override-date))) (magit-commit-amend-assert) - (let ((process-environment process-environment)) - (unless override-date - (push (magit-rev-format "GIT_COMMITTER_DATE=%cD") process-environment)) - (cl-pushnew "--allow-empty" args :test #'equal) - (magit-run-git-with-editor "commit" "--amend" "--only" args))) + (cl-pushnew "--allow-empty" args :test #'equal) + (if override-date + (magit-run-git-with-editor "commit" "--amend" "--only" args) + (with-environment-variables + (("GIT_COMMITTER_DATE" (magit-rev-format "%cD"))) + (magit-run-git-with-editor "commit" "--amend" "--only" args)))) ;;;###autoload (defun magit-commit-fixup (&optional commit args) @@ -467,8 +469,7 @@ is updated: 'magit--reshelve-history) update-author (magit-commit-arguments)))) - (let ((process-environment process-environment)) - (push (concat "GIT_COMMITTER_DATE=" date) process-environment) + (with-environment-variables (("GIT_COMMITTER_DATE" date)) (magit-run-git "commit" "--amend" "--no-edit" (and update-author (concat "--date=" date)) args))) diff --git a/lisp/magit-extras.el b/lisp/magit-extras.el index ea8f8e1655..c9e3145bb8 100644 --- a/lisp/magit-extras.el +++ b/lisp/magit-extras.el @@ -577,38 +577,38 @@ list returned by `magit-rebase-arguments'." (float-time (date-to-time (read-string "Date for first commit: " - time-now 'magit--reshelve-history))))) - (process-environment process-environment)) - (push "FILTER_BRANCH_SQUELCH_WARNING=1" process-environment) - (magit-with-toplevel - (magit-run-git-async - "filter-branch" "--force" "--env-filter" - (format - "case $GIT_COMMIT in %s\nesac" - (mapconcat - (lambda (rev) - (prog1 (concat - (format "%s) " rev) - (and (not magit-reshelve-since-committer-only) - (format "export GIT_AUTHOR_DATE=\"%s\"; " date)) - (format "export GIT_COMMITTER_DATE=\"%s\";;" date)) - (cl-incf date 60))) - (magit-git-lines "rev-list" "--reverse" range) - " ")) - (and keyid - (list "--commit-filter" - (format "git commit-tree --gpg-sign=%s \"$@\";" - keyid))) - range "--")) - (set-process-sentinel - magit-this-process - (lambda (process event) - (when (memq (process-status process) '(exit signal)) - (if (> (process-exit-status process) 0) + time-now 'magit--reshelve-history)))))) + (with-environment-variables (("FILTER_BRANCH_SQUELCH_WARNING" "1")) + (magit-with-toplevel + (magit-run-git-async + "filter-branch" "--force" "--env-filter" + (format + "case $GIT_COMMIT in %s\nesac" + (mapconcat + (lambda (rev) + (prog1 + (concat + (format "%s) " rev) + (and (not magit-reshelve-since-committer-only) + (format "export GIT_AUTHOR_DATE=\"%s\"; " date)) + (format "export GIT_COMMITTER_DATE=\"%s\";;" date)) + (cl-incf date 60))) + (magit-git-lines "rev-list" "--reverse" range) + " ")) + (and keyid + (list "--commit-filter" + (format "git commit-tree --gpg-sign=%s \"$@\";" + keyid))) + range "--")) + (set-process-sentinel + magit-this-process + (lambda (process event) + (when (memq (process-status process) '(exit signal)) + (if (> (process-exit-status process) 0) + (magit-process-sentinel process event) + (process-put process 'inhibit-refresh t) (magit-process-sentinel process event) - (process-put process 'inhibit-refresh t) - (magit-process-sentinel process event) - (magit-run-git "update-ref" "-d" backup)))))))))))) + (magit-run-git "update-ref" "-d" backup))))))))))))) ;;; Revision Stack diff --git a/lisp/magit-git.el b/lisp/magit-git.el index 2232173817..4a14ced045 100644 --- a/lisp/magit-git.el +++ b/lisp/magit-git.el @@ -2275,9 +2275,7 @@ and this option only controls what face is used.") (cons (concat "GIT_INDEX_FILE=" ,file) magit-tramp-process-environment))) ,@body) - (let ((process-environment - (cons (concat "GIT_INDEX_FILE=" ,file) - process-environment))) + (with-environment-variables (("GIT_INDEX_FILE" ,file)) ,@body))) (ignore-errors (delete-file (concat (file-remote-p default-directory) ,file))))))) diff --git a/lisp/magit-sequence.el b/lisp/magit-sequence.el index acca50ee73..9aabfcf578 100644 --- a/lisp/magit-sequence.el +++ b/lisp/magit-sequence.el @@ -313,12 +313,11 @@ the process manually." (magit-refresh))) (t (magit-git "checkout" src) - (let ((process-environment process-environment)) - (push (format "%s=%s -i -ne '/^pick (%s)/ or print'" - "GIT_SEQUENCE_EDITOR" - magit-perl-executable - (mapconcat #'magit-rev-abbrev commits "|")) - process-environment) + (with-environment-variables + (("GIT_SEQUENCE_EDITOR" + (format "%s -i -ne '/^pick (%s)/ or print'" + magit-perl-executable + (mapconcat #'magit-rev-abbrev commits "|")))) (magit-run-git-sequencer "rebase" "-i" keep)) (when checkout-dst (set-process-sentinel @@ -823,8 +822,7 @@ edit. With a prefix argument the old message is reused as-is." (magit-commit-amend-assert (magit-file-line (magit-git-dir "rebase-merge/orig-head")))) (if noedit - (let ((process-environment process-environment)) - (push "GIT_EDITOR=true" process-environment) + (with-environment-variables (("GIT_EDITOR" "true")) (magit-run-git-async (magit--rebase-resume-command) "--continue") (set-process-sentinel magit-this-process #'magit-sequencer-process-sentinel) diff --git a/lisp/magit.el b/lisp/magit.el index 9b85437ce7..6e7e625aea 100644 --- a/lisp/magit.el +++ b/lisp/magit.el @@ -445,12 +445,11 @@ is run in the top-level directory of the current working tree." (magit--shell-command command (magit-toplevel))) (defun magit--shell-command (command &optional directory) - (let ((default-directory (or directory default-directory)) - (process-environment process-environment)) - (push "GIT_PAGER=cat" process-environment) - (magit--with-connection-local-variables - (magit-start-process shell-file-name nil - shell-command-switch command))) + (let ((default-directory (or directory default-directory))) + (with-environment-variables (("GIT_PAGER" "cat")) + (magit--with-connection-local-variables + (magit-start-process shell-file-name nil + shell-command-switch command)))) (magit-process-buffer)) (defun magit-read-shell-command (&optional toplevel initial-input)