From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Jonathan Ganc Newsgroups: gmane.emacs.bugs Subject: bug#26066: 26.0.50; vc-git-status gives wrong result Date: Thu, 30 Mar 2017 23:16:02 -0400 Message-ID: <7fccafd3-e2c2-204a-05a0-a930a4cbb7e4@gmail.com> References: <9bf82bf1-fefa-ab84-bac1-cf748ae5ccfb@gmail.com> <87efxy59wx.fsf@users.sourceforge.net> <0d87686b-c7d2-deab-ebe4-ab1c8aa4faca@yandex.ru> <29d4a5ae-0ca0-3a86-6b9a-ab616803f39e@gmail.com> <4741bddf-9765-0d94-d0cd-b94e3e4914e1@yandex.ru> <8530cd03-0158-f198-9b14-ade983e1c7f4@gmail.com> <022c0e0a-e039-24ef-66ff-82bcedbacd93@yandex.ru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------22756C2F6450B47F54C776CB" X-Trace: blaine.gmane.org 1490930241 32176 195.159.176.226 (31 Mar 2017 03:17:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 31 Mar 2017 03:17:21 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 To: Dmitry Gutov , npostavs@users.sourceforge.net, 26066@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 31 05:17:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctn3o-0007F0-UH for geb-bug-gnu-emacs@m.gmane.org; Fri, 31 Mar 2017 05:17:13 +0200 Original-Received: from localhost ([::1]:38623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctn3r-00087B-Bc for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 Mar 2017 23:17:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctn3h-00086n-Q4 for bug-gnu-emacs@gnu.org; Thu, 30 Mar 2017 23:17:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctn3e-0007Vi-Jk for bug-gnu-emacs@gnu.org; Thu, 30 Mar 2017 23:17:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55207) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ctn3e-0007VL-D7 for bug-gnu-emacs@gnu.org; Thu, 30 Mar 2017 23:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ctn3e-000349-4Y for bug-gnu-emacs@gnu.org; Thu, 30 Mar 2017 23:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jonathan Ganc Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 31 Mar 2017 03:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26066 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 26066-submit@debbugs.gnu.org id=B26066.149093017211725 (code B ref 26066); Fri, 31 Mar 2017 03:17:02 +0000 Original-Received: (at 26066) by debbugs.gnu.org; 31 Mar 2017 03:16:12 +0000 Original-Received: from localhost ([127.0.0.1]:53406 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctn2q-000333-2z for submit@debbugs.gnu.org; Thu, 30 Mar 2017 23:16:12 -0400 Original-Received: from mail-qt0-f193.google.com ([209.85.216.193]:36435) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctn2o-00032q-Ji for 26066@debbugs.gnu.org; Thu, 30 Mar 2017 23:16:11 -0400 Original-Received: by mail-qt0-f193.google.com with SMTP id n37so8728322qtb.3 for <26066@debbugs.gnu.org>; Thu, 30 Mar 2017 20:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to; bh=fvXdrcDgI9xxqXfXKSX19ixlHRXimdDbxGTsDP0ExBM=; b=ZaftMZjQF3s/Kfe9cjdRJMISeJnkXP9zcc4ghg8Z1Iab3E8xkyat+aW6N6XSYbQAiM hxY5krs16FnsSa+jl+x92Vzr/0bEXTIBOic2bHPSm1CgNcrjAEh7GviHJn/wOBkuY2P1 XejJaWlxj8ExdFmhKN7S2sOHQkP0/rpmYwfsF0MrG2eaeAyEcT/fOQ2S9fNh4jVj4UXa BNMFsmRUA/BahdvwT9KZZTcobbTQk8QpGvaOqyWzqtTTtkQXJZ+F364Bklf7UUuHpAut JsBQgilr2JW3BmYg3K6RhFk7SQTX5XyolcHzSTjd3Z4Jpg0jGoRB8HbcQGDXjAq8tb+V 4wIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=fvXdrcDgI9xxqXfXKSX19ixlHRXimdDbxGTsDP0ExBM=; b=qDjRhRT2II2kuS59h+xVPopRo9/1HGbEMsCgy8OUgD5S/m3i5krAx8wFHfvdfgNXiK 8S2R/fpqGytKMt4+IHtQyrbOxxVRapzSFvBXix7MpQM6O0YzO/V9iC3t4lyDCStkj0xK jlfPWZUz9gPTLI1uc1H2K+1A5EiB7cUi8QBTqn0b304ogqOjCNfcbcpYlsXWcrq+pQxX ElVlGk7uAOv/otdqLSguoqQajBGcn73JITNPJR9k8tixjfIVc4vkYRnv0BWkrMeYw4CI V7xLb+B0ddl911oaofCBavQCzn75X+bQrBNv/v0OFzr0GEqDwnsKkiOgf6b5KaMOYwPL n0tw== X-Gm-Message-State: AFeK/H1LvSLTLBUHK0nQbnb+daB5iL8qIbRcQrxkESQLobZs1EGXZyVhy9pfu/+tVxZ0Qw== X-Received: by 10.237.33.46 with SMTP id 43mr798572qtc.72.1490930164877; Thu, 30 Mar 2017 20:16:04 -0700 (PDT) Original-Received: from [192.168.1.198] (static-98-118-34-152.bstnma.fios.verizon.net. [98.118.34.152]) by smtp.gmail.com with ESMTPSA id j100sm2727983qkh.38.2017.03.30.20.16.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 20:16:04 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131119 Archived-At: This is a multi-part message in MIME format. --------------22756C2F6450B47F54C776CB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I have attached my proposed patch to use 'git status' for finding the git status of files. I have also attached git-test.sh, which generates a subdirectory git-test with files in all the relevant git states I could think of (if you use it, look at the mods, repo2, repo3 directories for interesting files). I then verified that 1) my function gives the same result as vc-git-dir-status-files where vc-git-dir-status-files shows the file, with one exception: if a file has a merge conflict (i.e. the status is "UU"), my function returns conflict; 2) it is the same speed as the current vc-git-state. I may try eventually try rewriting vc-git-dir-status-files using this since it appears to be about an order of magnitude faster than the current implementation. On 03/22/2017 10:18 PM, Jonathan Ganc wrote: > Hi, > > Thanks for both responses. > > >>> 3. It would be nice to be able to show mutiple directory trees at >>> once in Neotree, though this is not as important. >> >> If it's unable to show the non-current projects, how is the bug >> triggered? default-directory would have to be outside of the project. > > I'm not actually sure why it is causing me problems. I just tried > using Neotree and encountered this problem. I didn't try anything > special besides opening the window. I'm not sure how/why Neotree sets > default-directory. I need to look into this. > > >> The problem might have gone unnoticed until now because file's status >> is cached, and because it can only be apparent if several projects >> are opened at the same time. >> >> While the problem is fairly obvious, a proper fix would most likely >> touch other backends and commands, to the point that the >> default-directory binding might have to be done inside vc-call-backend. > > Yeah, I'm not really sure what the workflow should be; I'm just > getting started with the vc functions in emacs. One issue, though, is > that default-directory can only be set for functions that identify a > filename, because we need to have a directory to set things to. For > this reason, I don't know that one could generally set > default-directory in vc-call-backend. It could make sense to set > default-directory for vc-git--run-command-string (although to get > vc-git-state to work, one would still need to set it for > vc-git--empty-db-p). > > It's worth nothing there seems to be inconsistency within vc-git. Some > commands like vc-git-checkin, vc-git-next-revision, do set > default-directory to the directory of the input file; other comands > like vc-git-merge-branch seem to do the opposite and assume the root > is already given by default-directory. > > At the very least, the documentation for vc-git-state should note that > default-directory needs to be set. > >> >> There is a very simple workaround on the caller's side, though: bind >> default-directory inside the Neotree code, to the respective project >> root (or just the file's parent directory). That will be necessary >> anyway for it to work in the released Emacs versions. >> > > That may be the best answer. I am not so familiar with the Neotree > code but it should be doable. > >>> 2. I would like to be able to color directories as well as files. I >>> don't know if that is something that would have a component in >>> vc-git.el / vc-....el or would go entirely in some package (e.g. >>> Neotree) >> >> This differs from one version control system to another, but Git >> doesn't actually track directories. So the notion of "directory >> status" is poorly defined. But see the previously mentioned >> diff-hl-dired-mode. >> > > You're right, in principle, but atom handles it by coloring > directories based on if they have modified files within. I don't know > if there is a "canonical" way to do this, although one idea would be > to return a list of all file status in the directory, e.g. > `(up-to-date modified ignored)`. > > I started looking through diff-hl. It looks like it has a bunch of > neat and useful features, though I admit I was a bit confused by the > workflow. > --------------22756C2F6450B47F54C776CB Content-Type: application/x-shellscript; name="git-test.sh" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="git-test.sh" IyEvYmluL2Jhc2gKCnNldCAtdQoKIyMgIHNjcmlwdCBmb3IgbWFraW5nIGEgZ2l0IGRpciB3 aXRoIGFsbCBraW5kcyBvZiBmaWxlcwoKIyMgIHdlIG1ha2UgdHdvIGRpcmVjdG9yeSBzdHJ1 Y3R1cmVzCiMjCiMjICBhIHJlcG8gdGhhdCBoYXMgbW9kaWZpZWQgZmlsZXM6ICBtb2RzLwoj IwojIyAgICBiYXJlLyAgIGNvbW1vbiBiYXJlIHJlcG8KIyMgICAgcmVwbzEvICBiYXNlIHJl cG8gZm9yIGVkaXRpbmcKIyMgICAgcmVwbzIvICBhIHJlcG8gd2hlcmUgd2UgbWFrZSBjaGFu Z2VzIGFuZCBjb21taXQgdGhlbQojIyAgICByZXBvMy8gIGEgcmVwbyB3aGVyZSB3ZSBtYWtl IGNoYW5nZXMgdGhhdCBhcmUgYWxzbyBpbgojIyAgICAgICAgICAgICAgICAgICAgICB0aGUg d29ya2luZyB0cmVlIGFuZC9vciBpbmRleAojIwojIyAgaW4gb3RoZXIgd29yZHMsIGxvb2sg Zm9yIGludGVyZXN0aW5nIHN0YXR1c2VzIGluIG1vZHMvIGFuZAojIyAgcmVwbzIvLCByZXBv My8KCmVycm9yICgpIHsKICAgIDE+JjIgZWNobyAiZXJyb3I6ICQqIgogICAgZXhpdCAxCn0K CmVycm9yX2NuICgpIHsKICAgIGVycm9yICJjb3VsZCBub3QgJCoiCn0KCmVycm9yX2NubSAo KSB7CiAgICBlcnJvciAiY291bGQgbm90OiBtb2RzICQqIgp9CgplcnJvcl9jbmMgKCkgewog ICAgZXJyb3IgImNvdWxkIG5vdDogY29uZmxpY3RzICQqIgp9CgplcnJvcl9jbmwgKCkgewog ICAgZXJyb3IgImNvdWxkIG5vdDogbG9ncyAkKiIKfQoKcmFuZG9tX3N0cmluZyAoKSB7CiAg ICAjIHNoZWxsY2hlY2sgZGlzYWJsZT0yMDA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cnQuc2gi ID4gIiRsb2dfcHJlZi1maW5kLmxvZyIgXAogICAgICAgICAgICB8fCBlcnJvcl9jbmwgIm1h a2UgbG9nICRsb2dfcHJlZi1maW5kLmxvZyIKICAgICAgICBmaW5kIC4gLW1heGRlcHRoIDEg LW1pbmRlcHRoIDEgLXR5cGUgZiAtZXhlYyBcCiAgICAgICAgICAgICBiYXNoIC1jICJlY2hv ICd7fTonICYmICQqIHt9ICYmIGVjaG8iIFw7IFwKICAgICAgICAgICAgID4gIiRsb2dfcHJl Zi1maW5kLXdpdGhuYW1lLmxvZyIgXAogICAgICAgICAgICB8fCBlcnJvcl9jbmwgIm1ha2Ug bG9nICRsb2dfcHJlZi1maW5kLXdpdGhuYW1lLmxvZyIKICAgICAgICAjIyAgYWRkIGRlbGV0 ZWQgZmlsZXMgaWYgcHJlc2VudAogICAgICAgIGlmIFtbIC12ICIke3JlcG99X2RlbGV0ZWRf YXJyIiBdXTsgdGhlbgogICAgICAgICAgICBkZWNsYXJlIC1uIGRlbGV0ZWRfYXJyPSIke3Jl cG99X2RlbGV0ZWRfYXJyIgogICAgICAgICAgICBmb3IgZmlsZSBpbiAiJHtkZWxldGVkX2Fy cltAXX0iOyBkbwogICAgICAgICAgICAgICAgZWNobyAiJGZpbGU6IiA+PiAiJGxvZ19wcmVm LWRlbGV0ZWQtd2l0aGZpbGVuYW1lLmxvZyIKICAgICAgICAgICAgICAgICRAICIkZmlsZSIg fCB0ZWUgLWEgIiRsb2dfcHJlZi1kZWxldGVkLXdpdGhmaWxlbmFtZS5sb2ciIFwKICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgPj4gIiRsb2dfcHJlZi1kZWxldGVkLmxvZ34i CiAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgIiRpbml0ZGlyL2dpdC1zdGF0dXMtc29y dC5zaCIgPCAiJGxvZ19wcmVmLWRlbGV0ZWQubG9nfiIgXAogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICA+ICIkbG9nX3ByZWYtZGVsZXRlZC5sb2ciCiAgICAg ICAgZmkKICAgIH0KfQoKcHJpbnRfZ2l0X3N0YXR1cyAibW9kcyIKcHJpbnRfZ2l0X3N0YXR1 cyAicmVwbzIiCnByaW50X2dpdF9zdGF0dXMgInJlcG8zIgoKZWNobyAiU3VjY2VzcyIK --------------22756C2F6450B47F54C776CB Content-Type: text/x-patch; name="0001-Use-git-status-in-vc-git-status.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Use-git-status-in-vc-git-status.patch" >From ba77e001b719ff289cf0b1d3dcffd647af6d175d Mon Sep 17 00:00:00 2001 From: Jonathan Ganc Date: Thu, 30 Mar 2017 23:13:15 -0400 Subject: [PATCH] Use 'git status' in vc-git-status --- lisp/vc/vc-git.el | 79 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 26 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 1a3f1bf..ce662fb 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -231,34 +231,61 @@ (defun vc-git--state-code (code) (?U 'edited) ;; FIXME (?T 'edited))) ;; FIXME +(defun vc-git--git-status-to-vc-state (code-list) + "Convert a list CODE-LIST of two-letter git status strings to a vc status. + +Each element of CODE-LIST comes from the first two characters of +a line returned by 'git status' and should be passed in the order given by 'git status'. Elements that are nil are simply ignored. + +Note that this function may destroy and/or alter `code-list'. + +\(It is necessary to allow CODE-LIST to be a list because +sometimes git status returns multiple lines, e.g. for a file that +is removed from the index but is present in the HEAD and working +tree.) " + (setq code-list (remq nil code-list)) + (pcase code-list + ('nil 'up-to-date) + (`(,code) + (pcase code + ("!!" 'ignored) + ("??" 'unregistered) + ;; have only seen this with a file that is only present in the + ;; index. let us call this `removed' + ("AD" 'removed) + (_ (cond + ((string-match-p "^[ RD]+$" code) 'removed) + ((string-match-p "^[ M]+$" code) 'edited) + ((string-match-p "^[ A]+$" code) 'added) + ((string-match-p "^[ U]+$" code) 'conflict) + (t 'edited))))) + ;; I know of two times when git state returns more than one element, + ;; in both cases returning '("D " "??")': + ;; 1. when a file is removed from the index but present in the + ;; HEAD and working tree, the CODE-LIST will be + ;; 2. when a file A is renamed to B in the index and then back to A + ;; in the working tree, the CODE-LIST will be '("??" "RD") + ;; In both these instances, `unregistered' is a reasonable response. + (`("D " "??") 'unregistered) + ;; In other cases, let us return `edited' + (_ 'edited))) + (defun vc-git-state (file) "Git-specific version of `vc-state'." - ;; FIXME: This can't set 'ignored or 'conflict yet - ;; The 'ignored state could be detected with `git ls-files -i -o - ;; --exclude-standard` It also can't set 'needs-update or - ;; 'needs-merge. The rough equivalent would be that upstream branch - ;; for current branch is in fast-forward state i.e. current branch - ;; is direct ancestor of corresponding upstream branch, and the file - ;; was modified upstream. But we can't check that without a network - ;; operation. - ;; This assumes that status is known to be not `unregistered' because - ;; we've been successfully dispatched here from `vc-state', that - ;; means `vc-git-registered' returned t earlier once. Bug#11757 - (let ((diff (vc-git--run-command-string - file "diff-index" "-p" "--raw" "-z" "HEAD" "--"))) - (if (and diff - (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0[^\0]+\0\\(.*\n.\\)?" - diff)) - (let ((diff-letter (match-string 1 diff))) - (if (not (match-beginning 2)) - ;; Empty diff: file contents is the same as the HEAD - ;; revision, but timestamps are different (eg, file - ;; was "touch"ed). Update timestamp in index: - (prog1 'up-to-date - (vc-git--call nil "add" "--refresh" "--" - (file-relative-name file))) - (vc-git--state-code diff-letter))) - (if (vc-git--empty-db-p) 'added 'up-to-date)))) + + (save-match-data + (let* ((default-directory (file-name-directory (expand-file-name file))) + (status + (vc-git--run-command-string file "status" "--porcelain" "-z" + "--untracked-files" "--ignored" "--")) + code-list) + ;; if this code is adapted to parse git-status for a directory, note + ;; that a renamed file takes up two null values and needs to be + ;; treated slightly more carefully + (while (string-match "^\\(..\\)[^\0]+\0\\(\\(?:a\\|[^a]\\)*\\)$" status) + (add-to-list 'code-list (match-string 1 status) t 'ignore) + (setq status (match-string 2 status))) + (vc-git--git-status-to-vc-state code-list)))) (defun vc-git-working-revision (_file) "Git-specific version of `vc-working-revision'." -- 2.9.3 --------------22756C2F6450B47F54C776CB--