diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index f01807e0113..b5da03764d1 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -2492,6 +2492,17 @@ The difference to `vc-do-command' is that this function always invokes `vc-git-program'." (let ((coding-system-for-read (or coding-system-for-read vc-git-log-output-coding-system)) + ;; Commands which pass command line arguments which might + ;; contain non-ASCII have to bind `coding-system-for-write' to + ;; `locale-coding-system' when (eq system-type 'windows-nt) + ;; because MS-Windows has the limitation that command line + ;; arguments must be in the system codepage. We do that only + ;; within the commands which must do it, instead of implementing + ;; it here, even though that means code repetition. This is + ;; because this let-binding has the disadvantage of overriding + ;; any `coding-system-for-write' explicitly selected by the user + ;; (e.g. with C-x RET c), or by enclosing function calls. So we + ;; want to do it only for commands which really require it. (coding-system-for-write (or coding-system-for-write vc-git-commits-coding-system)) (process-environment diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 3a6580c16f4..7b65084a108 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1638,6 +1638,18 @@ This function differs from `vc-do-command' in that - BUFFER may be nil - it invokes `vc-hg-program' and passes `vc-hg-global-switches' to it before FLAGS." + ;; Commands which pass command line arguments which might + ;; contain non-ASCII have to bind `coding-system-for-write' to + ;; `locale-coding-system' when (eq system-type 'windows-nt) + ;; because MS-Windows has the limitation that command line + ;; arguments must be in the system codepage. We do that only + ;; within the commands which must do it, instead of implementing + ;; it here, even though that means code repetition. This is + ;; because such a let-binding would have the disadvantage of + ;; overriding any `coding-system-for-write' explicitly selected + ;; by the user (e.g. with C-x RET c), or by enclosing function + ;; calls. So we want to do it only for commands which really + ;; require it. (vc-hg--command-1 #'vc-do-command (list (or buffer "*vc*") okstatus vc-hg-program file-or-list)