From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#51497: 29.0.50; (vc-print-log) broken over TRAMP Date: Mon, 3 Jan 2022 05:59:47 +0200 Message-ID: References: <877ddv9ue0.fsf@jpl.nasa.gov> <87tugyptju.fsf@gnus.org> <87tugy8h3a.fsf@secretsauce.net> <87pmrl8yhy.fsf@secretsauce.net> <60fea707-a9b2-d9f4-cc45-ffd4539887b6@yandex.ru> <87o87253sv.fsf@secretsauce.net> <60af7952-d702-d40f-928e-1320e6d9520f@yandex.ru> <83f40a2a-ae5a-2c6c-cf6a-44ff7c933d16@yandex.ru> <831r3tb7un.fsf@gnu.org> <7e04f090-81de-d5bd-746c-7f09ed0c38b0@yandex.ru> <83lf219i3u.fsf@gnu.org> <86r1btvsso.fsf@gmail.com> <86ilx4x4xv.fsf@gmail.com> <1f17978c-0498-a19b-6bb0-6f316a536f8e@yandex.ru> <83h7coa2cs.fsf@gnu.org> <92da67f0-9133-98ba-69e3-7408fab30539@yandex.ru> <83o86u7qxg.fsf@gnu.org> <5bbcd838-45a3-3d1d-5dd8-d58a0e8be4dc@yandex.ru> <838rxy7bq3.fsf@gnu.org> <90ac6d38-e448-2415-60c3-aacd10f73172@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------08BE47B8BD166EC9BC76A96B" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19777"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 Cc: 51497@debbugs.gnu.org, andrewjmoreton@gmail.com, Dima Kogan To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 03 05:03:05 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n4EYq-0004wb-Mz for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Jan 2022 05:03:04 +0100 Original-Received: from localhost ([::1]:55402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n4EYp-000099-Qs for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 02 Jan 2022 23:03:03 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n4EXq-00074d-Lt for bug-gnu-emacs@gnu.org; Sun, 02 Jan 2022 23:02:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n4EXp-0001wu-RQ for bug-gnu-emacs@gnu.org; Sun, 02 Jan 2022 23:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n4EXp-000055-Qd for bug-gnu-emacs@gnu.org; Sun, 02 Jan 2022 23:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Jan 2022 04:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51497 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 51497-submit@debbugs.gnu.org id=B51497.164118247032694 (code B ref 51497); Mon, 03 Jan 2022 04:02:01 +0000 Original-Received: (at 51497) by debbugs.gnu.org; 3 Jan 2022 04:01:10 +0000 Original-Received: from localhost ([127.0.0.1]:33992 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n4EWz-0008VE-EE for submit@debbugs.gnu.org; Sun, 02 Jan 2022 23:01:09 -0500 Original-Received: from mail-wr1-f51.google.com ([209.85.221.51]:39806) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n4EWx-0008Ur-Qu for 51497@debbugs.gnu.org; Sun, 02 Jan 2022 23:01:08 -0500 Original-Received: by mail-wr1-f51.google.com with SMTP id s1so67513210wra.6 for <51497@debbugs.gnu.org>; Sun, 02 Jan 2022 20:01:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=qQGO7Rx2gbQODSFdCYwIKyNTyPwxdb8bvI0fN4eeb8c=; b=XHD5O0KbcB0rM5d4+tQHPOgOzhg+iLVrukYId2dqL1mv3zzXjoSJRBEuCXw1cdOLxT OCkd9/algDRjp3VsSbw+7iTygYUGWUYd7sI3iuEkLb2KAUZ94pX/CJIh87NJQCziDUr0 Ji75ogFJ69NdFZDr4mfrRVEEvuDs2cIXTa5tJG7OI+qcpwSau8oVRUJeTHSWe7+flxaG 48EMNsfjg/XjiOob5Zf6V/R3JYI+YJzSxJWOMXjd3//YURTFNGWCMaVifvDUhC0trYH9 +Il1nen9IBRVdqTdmjV2aksvvUZm+qVOUjlezaL9n8GAoF1rEcKA8rf3eG1XMtXaY7V1 EbBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:from:to:cc:references:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=qQGO7Rx2gbQODSFdCYwIKyNTyPwxdb8bvI0fN4eeb8c=; b=TY69GdXVenWoANYUuOc0YeN5hmPKPPLsC2fJNQh+1w9UeHMx6WMDUtPy0lyOX3s5Ty 77HSSLqubAFGuEDuuk++glxlwioy4RmFMexgFhiNVjpKtqoy1HKHX0226tdpAShfUBxy Wy1xYHdeJb03bbLbctJoD1acl8gqd/IHyywo5genye0gzOMdq9MiaUWqvT8bpFJdNxey ZnXMDoRd/nyRJXRPHTJTxfwCfK3yn6O9zF5WArEwcU2IE+cZ+faIMK/95u5oMks+uwaG cGmO3gWOOW1hjVKOrXEpdQNxvVpvBWq1gCoBeu7hE9Zzsw+/9fSgWCwXM5xOlcGLXpoZ 8w0g== X-Gm-Message-State: AOAM531gks4QEs2BC4DvwB3Wr8fLuEc1T2d9Rw3kuAjJnvdurUHoOn84 GMSWauRhpqe+eTUALucDY/4= X-Google-Smtp-Source: ABdhPJyAW2P9WspGAh0CdlH279Z/k8G4BC4AC8ktyVEZO2XuXO8by4T2d3TuIZx7p4do8t69Uq6FbA== X-Received: by 2002:a5d:6050:: with SMTP id j16mr36823362wrt.175.1641182461834; Sun, 02 Jan 2022 20:01:01 -0800 (PST) Original-Received: from [10.111.255.129] ([194.36.25.39]) by smtp.googlemail.com with ESMTPSA id o38sm31774814wms.11.2022.01.02.20.00.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 02 Jan 2022 20:01:01 -0800 (PST) In-Reply-To: <90ac6d38-e448-2415-60c3-aacd10f73172@yandex.ru> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:223575 Archived-At: This is a multi-part message in MIME format. --------------08BE47B8BD166EC9BC76A96B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 27.12.2021 04:36, Dmitry Gutov wrote: > So here's the patch (my current preferred solution for both emacs-28 and > master). > > Waiting for feedback from AndyM. Sorry, here's a version of the patch that doesn't break vc-checkin. Waiting for Andy's feedback, I wouldn't mind some testing from Dima as well, BTW. --------------08BE47B8BD166EC9BC76A96B Content-Type: text/x-patch; charset=UTF-8; name="redo-literal-pathspecs.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="redo-literal-pathspecs.diff" diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 2d35061b26..4c873b7264 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -223,6 +223,12 @@ vc-git-revision-complete-only-branches ;; History of Git commands. (defvar vc-git-history nil) +;; Default to t because commands which don't support literal pathspecs +;; ignore the environment variable silently. +(defvar vc-git-use-literal-pathspecs t + "Non-nil to treat pathspecs in commands literally. +Good example of file name that needs this: \"test[56].xx\".") + ;; Clear up the cache to force vc-call to check again and discover ;; new functions when we reload this file. (put 'Git 'vc-functions nil) @@ -242,20 +248,6 @@ vc-git-update-on-retrieve-tag ;;;###autoload (load "vc-git" nil t) ;;;###autoload (vc-git-registered file)))) -;; Good example of file name that needs this: "test[56].xx". -(defun vc-git--literal-pathspec (file) - "Prepend :(literal) path magic to FILE." - (when file - ;; Expand abbreviated file names. - (when (file-name-absolute-p file) - (setq file (expand-file-name file))) - (concat ":(literal)" (file-local-name file)))) - -(defun vc-git--literal-pathspecs (files) - "Prepend :(literal) path magic to FILES." - (unless (vc-git--file-list-is-rootdir files) - (mapcar #'vc-git--literal-pathspec files))) - (defun vc-git-registered (file) "Check whether FILE is registered with git." (let ((dir (vc-git-root file))) @@ -269,12 +261,12 @@ vc-git-registered (name (file-relative-name file dir)) (str (with-demoted-errors "Error: %S" (cd dir) - (vc-git--out-ok "ls-files" "-c" "-z" "--" (vc-git--literal-pathspec name)) + (vc-git--out-ok "ls-files" "-c" "-z" "--" name) ;; If result is empty, use ls-tree to check for deleted ;; file. (when (eq (point-min) (point-max)) (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD" - "--" (vc-git--literal-pathspec name))) + "--" name)) (buffer-string)))) (and str (> (length str) (length name)) @@ -356,7 +348,7 @@ vc-git-state ,@(when (version<= "1.7.6.3" (vc-git--program-version)) '("--ignored")) "--")) - (status (apply #'vc-git--run-command-string (vc-git--literal-pathspec file) args))) + (status (apply #'vc-git--run-command-string file args))) (if (null status) ;; If status is nil, there was an error calling git, likely because ;; the file is not in a git repo. @@ -634,28 +626,28 @@ vc-git-dir-status-goto-stage (pcase (vc-git-dir-status-state->stage git-state) ('update-index (if files - (vc-git-command (current-buffer) 'async (vc-git--literal-pathspecs files) "add" "--refresh" "--") + (vc-git-command (current-buffer) 'async files "add" "--refresh" "--") (vc-git-command (current-buffer) 'async nil "update-index" "--refresh"))) ('ls-files-added - (vc-git-command (current-buffer) 'async (vc-git--literal-pathspecs files) + (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-c" "-s" "--")) ('ls-files-up-to-date - (vc-git-command (current-buffer) 'async (vc-git--literal-pathspecs files) + (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-c" "-s" "--")) ('ls-files-conflict - (vc-git-command (current-buffer) 'async (vc-git--literal-pathspecs files) + (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-u" "--")) ('ls-files-unknown - (vc-git-command (current-buffer) 'async (vc-git--literal-pathspecs files) + (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-o" "--exclude-standard" "--")) ('ls-files-ignored - (vc-git-command (current-buffer) 'async (vc-git--literal-pathspecs files) + (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-o" "-i" "--directory" "--no-empty-directory" "--exclude-standard" "--")) ;; --relative added in Git 1.5.5. ('diff-index - (vc-git-command (current-buffer) 'async (vc-git--literal-pathspecs files) + (vc-git-command (current-buffer) 'async files "diff-index" "--relative" "-z" "-M" "HEAD" "--"))) (vc-run-delayed (vc-git-after-dir-status-stage git-state)))) @@ -883,12 +875,12 @@ vc-git-register (when flist (vc-git-command nil 0 flist "update-index" "--add" "--")) (when dlist - (vc-git-command nil 0 (vc-git--literal-pathspecs dlist) "add")))) + (vc-git-command nil 0 dlist "add")))) (defalias 'vc-git-responsible-p #'vc-git-root) (defun vc-git-unregister (file) - (vc-git-command nil 0 (vc-git--literal-pathspec file) "rm" "-f" "--cached" "--")) + (vc-git-command nil 0 file "rm" "-f" "--cached" "--")) (declare-function log-edit-mode "log-edit" ()) (declare-function log-edit-toggle-header "log-edit" (header value)) @@ -954,7 +946,7 @@ vc-git-checkin (lambda (value) (when (equal value "yes") (list argument))))) ;; When operating on the whole tree, better pass "-a" than ".", since "." ;; fails when we're committing a merge. - (apply #'vc-git-command nil 0 (if only (vc-git--literal-pathspecs files)) + (apply #'vc-git-command nil 0 (if only files) (nconc (if msg-file (list "commit" "-F" (file-local-name msg-file)) (list "commit" "-m")) @@ -981,7 +973,7 @@ vc-git-find-revision (coding-system-for-write 'binary) (fullname (let ((fn (vc-git--run-command-string - (vc-git--literal-pathspec file) "ls-files" "-z" "--full-name" "--"))) + file "ls-files" "-z" "--full-name" "--"))) ;; ls-files does not return anything when looking for a ;; revision of a file that has been renamed or removed. (if (string= fn "") @@ -998,14 +990,14 @@ vc-git-find-ignore-file (vc-git-root file))) (defun vc-git-checkout (file &optional rev) - (vc-git-command nil 0 (vc-git--literal-pathspec file) "checkout" (or rev "HEAD"))) + (vc-git-command nil 0 file "checkout" (or rev "HEAD"))) (defun vc-git-revert (file &optional contents-done) "Revert FILE to the version stored in the git repository." (if contents-done (vc-git-command nil 0 file "update-index" "--") - (vc-git-command nil 0 (vc-git--literal-pathspec file) "reset" "-q" "--") - (vc-git-command nil nil (vc-git--literal-pathspec file) "checkout" "-q" "--"))) + (vc-git-command nil 0 file "reset" "-q" "--") + (vc-git-command nil nil file "checkout" "-q" "--"))) (defvar vc-git-error-regexp-alist '(("^ \\(.+\\)\\> *|" 1 nil nil 0)) @@ -1089,7 +1081,7 @@ vc-git-merge-branch (defun vc-git-conflicted-files (directory) "Return the list of files with conflicts in DIRECTORY." (let* ((status - (vc-git--run-command-string (vc-git--literal-pathspec directory) "status" "--porcelain" "--")) + (vc-git--run-command-string directory "status" "--porcelain" "--")) (lines (when status (split-string status "\n" 'omit-nulls))) files) (dolist (line lines files) @@ -1178,7 +1170,7 @@ vc-git-print-log (let ((inhibit-read-only t)) (with-current-buffer buffer (apply #'vc-git-command buffer - 'async (vc-git--literal-pathspecs files) + 'async files (append '("log" "--no-color") (when (and vc-git-print-log-follow @@ -1432,7 +1424,7 @@ vc-git-diff (if vc-git-diff-switches (apply #'vc-git-command (or buffer "*vc-diff*") 1 ; bug#21969 - (vc-git--literal-pathspecs files) + files command "--exit-code" (append (vc-switches 'git 'diff) @@ -1517,7 +1509,7 @@ vc-git-previous-revision (let* ((fname (file-relative-name file)) (prev-rev (with-temp-buffer (and - (vc-git--out-ok "rev-list" "-2" rev "--" (vc-git--literal-pathspec fname)) + (vc-git--out-ok "rev-list" "-2" rev "--" fname) (goto-char (point-max)) (bolp) (zerop (forward-line -1)) @@ -1545,7 +1537,7 @@ vc-git-next-revision (current-rev (with-temp-buffer (and - (vc-git--out-ok "rev-list" "-1" rev "--" (vc-git--literal-pathspec file)) + (vc-git--out-ok "rev-list" "-1" rev "--" file) (goto-char (point-max)) (bolp) (zerop (forward-line -1)) @@ -1557,7 +1549,7 @@ vc-git-next-revision (and current-rev (with-temp-buffer (and - (vc-git--out-ok "rev-list" "HEAD" "--" (vc-git--literal-pathspec file)) + (vc-git--out-ok "rev-list" "HEAD" "--" file) (goto-char (point-min)) (search-forward current-rev nil t) (zerop (forward-line -1)) @@ -1567,13 +1559,13 @@ vc-git-next-revision (or (vc-git-symbolic-commit next-rev) next-rev))) (defun vc-git-delete-file (file) - (vc-git-command nil 0 (vc-git--literal-pathspec file) "rm" "-f" "--")) + (vc-git-command nil 0 file "rm" "-f" "--")) (defun vc-git-rename-file (old new) (vc-git-command nil 0 (list old new) "mv" "-f" "--")) (defun vc-git-mark-resolved (files) - (vc-git-command nil 0 (vc-git--literal-pathspecs files) "add")) + (vc-git-command nil 0 files "add")) (defvar vc-git-extra-menu-map (let ((map (make-sparse-keymap))) @@ -1796,6 +1788,8 @@ vc-git-command (process-environment (append `("GIT_DIR" + ,@(when vc-git-use-literal-pathspecs + '("GIT_LITERAL_PATHSPECS=1")) ;; Avoid repository locking during background operations ;; (bug#21559). ,@(when revert-buffer-in-progress-p @@ -1833,6 +1827,8 @@ vc-git--call (process-environment (append `("GIT_DIR" + ,@(when vc-git-use-literal-pathspecs + '("GIT_LITERAL_PATHSPECS=1")) ;; Avoid repository locking during background operations ;; (bug#21559). ,@(when revert-buffer-in-progress-p --------------08BE47B8BD166EC9BC76A96B--