From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#42145: vc-git file order mismatch between vc-dir and vc-diff Date: Tue, 30 Mar 2021 22:23:59 +0300 Message-ID: <871rbwtq5w.fsf@mail.linkov.net> References: <87bll048br.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35569"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 42145@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 30 21:25:13 2021 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 1lRJzD-00097E-Pc for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 30 Mar 2021 21:25:11 +0200 Original-Received: from localhost ([::1]:42978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRJzC-0008Fy-C4 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 30 Mar 2021 15:25:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRJz3-0008Fb-UU for bug-gnu-emacs@gnu.org; Tue, 30 Mar 2021 15:25:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRJz3-0000PZ-NK for bug-gnu-emacs@gnu.org; Tue, 30 Mar 2021 15:25:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lRJz3-0002K3-Jj for bug-gnu-emacs@gnu.org; Tue, 30 Mar 2021 15:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Mar 2021 19:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42145 X-GNU-PR-Package: emacs Original-Received: via spool by 42145-submit@debbugs.gnu.org id=B42145.16171322998916 (code B ref 42145); Tue, 30 Mar 2021 19:25:01 +0000 Original-Received: (at 42145) by debbugs.gnu.org; 30 Mar 2021 19:24:59 +0000 Original-Received: from localhost ([127.0.0.1]:52862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lRJz1-0002Jk-9a for submit@debbugs.gnu.org; Tue, 30 Mar 2021 15:24:59 -0400 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:37429) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lRJyt-0002JD-N4 for 42145@debbugs.gnu.org; Tue, 30 Mar 2021 15:24:53 -0400 X-Originating-IP: 91.129.107.223 Original-Received: from mail.gandi.net (m91-129-107-223.cust.tele2.ee [91.129.107.223]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 755C01BF206; Tue, 30 Mar 2021 19:24:43 +0000 (UTC) In-Reply-To: (Dmitry Gutov's message of "Wed, 1 Jul 2020 01:08:04 +0300") 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:203327 Archived-At: >> There is an old usability problem in vc-dir. >> Typing ‘=’ in a vc-dir buffer displays a vc-diff buffer where files are >> sorted by different order than files are sorted in the vc-dir buffer. > > vc-dir has its own presentation logic, it's pretty complex. > > 'git diff' has a '-O' argument, which accepts . Maybe it'll > help, but I kind of doubt that. Ideas welcome. I solved this problem by adding two advises: 1. vc-dir-deduce-fileset - create orderfile 2. vc-git-diff - use orderfile #+begin_src emacs-lisp (defvar vc-git-orderfile nil) (advice-add 'vc-dir-deduce-fileset :after (lambda (&rest _) (when (and vc-ewoc (eq this-command 'vc-diff)) (let* ((tmpfile (make-temp-file "vc-git-orderfile-")) files) (ewoc-map (lambda (filearg) (push (vc-dir-fileinfo->name filearg) files)) vc-ewoc) (with-temp-file tmpfile (mapcar (lambda (file) (insert file "\n")) (nreverse files))) (setq vc-git-orderfile tmpfile)))) '((name . vc-dir-create-orderfile))) (advice-add 'vc-git-diff :around (lambda (orig-fun &rest args) (if (and vc-git-orderfile (file-exists-p vc-git-orderfile)) (let ((vc-git-diff-switches (append (list (format "-O%s" vc-git-orderfile)) vc-git-diff-switches))) (unwind-protect (apply orig-fun args) (delete-file vc-git-orderfile) (setq vc-git-orderfile nil))) (apply orig-fun args))) '((name . vc-git-diff-use-orderfile))) #+end_src Ideas welcome how to integrate this nicely to the vc package. Also it has one limitation: revert-buffer in the *vc-diff* buffer doesn't keep the original order, but this is a very minor problem.