From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.bugs Subject: bug#25683: semi-working patch Date: Sat, 11 Feb 2017 13:45:06 -0700 Message-ID: <87wpcw319p.fsf_-_@tromey.com> References: <87ziht66bc.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1486845977 21899 195.159.176.226 (11 Feb 2017 20:46:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 11 Feb 2017 20:46:17 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux) To: 25683@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 11 21:46:10 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 1cceYa-0004zc-2D for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Feb 2017 21:46:08 +0100 Original-Received: from localhost ([::1]:49519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cceYd-0001JW-Rw for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Feb 2017 15:46:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cceYX-0001JP-Mg for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2017 15:46:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cceYU-0005Si-IC for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2017 15:46:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37732) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cceYU-0005Se-9t for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2017 15:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cceYU-0003eq-1g for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2017 15:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tom Tromey Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Feb 2017 20:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25683 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25683-submit@debbugs.gnu.org id=B25683.148684592614017 (code B ref 25683); Sat, 11 Feb 2017 20:46:01 +0000 Original-Received: (at 25683) by debbugs.gnu.org; 11 Feb 2017 20:45:26 +0000 Original-Received: from localhost ([127.0.0.1]:35931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cceXt-0003e1-W9 for submit@debbugs.gnu.org; Sat, 11 Feb 2017 15:45:26 -0500 Original-Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:55835) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1cceXr-0003do-R8 for 25683@debbugs.gnu.org; Sat, 11 Feb 2017 15:45:24 -0500 Original-Received: (qmail 8229 invoked by uid 0); 11 Feb 2017 20:45:13 -0000 Original-Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy8.mail.unifiedlayer.com with SMTP; 11 Feb 2017 20:45:13 -0000 Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id jYl91u00A2f2jeq01YlCvF; Sat, 11 Feb 2017 13:45:13 -0700 X-Authority-Analysis: v=2.1 cv=WOnsABcR c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=n2v9WMKugxEA:10 a=GHmabsiQ3GQj90nd3msA:9 a=ijeUF8T_eAQAkoz9:21 a=67i0tXVb-a6tdMIb:21 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=pNPDJgFuxIL0Yxfjh6EAG7kBSlh85JD1zf6GkBmwtrY=; b=ky1neSSylFh3baYv+cdfYcwz3X qay5se6FnYb1gJgja0Z/JW+ckuJs1yHOduHfD5yvbevxD+K4mhXwykgi4bwS2Xk1AAHeZAhFjVlhU JxOpPVo57hq8x6cAFV3nrh+tm; Original-Received: from 174-16-128-54.hlrn.qwest.net ([174.16.128.54]:51516 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cceXc-0007om-TE; Sat, 11 Feb 2017 13:45:09 -0700 X-Attribution: Tom In-Reply-To: (GNU bug Tracking System's message of "Fri, 10 Feb 2017 22:17:02 +0000") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.bluehost.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.128.54 X-Exim-ID: 1cceXc-0007om-TE X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-128-54.hlrn.qwest.net (bapiya) [174.16.128.54]:51516 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== 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:129249 Archived-At: This patch kind of works. That is, it correctly notices files that have a conflict. However, when typing "g" in vc-dir, such a file briefly appears as "edited", then switches to "conflict". This happens because a file is first noticed in the diff-index phase, then later its state is corrected in the new ls-files-conflict stage. Ideally it would be possible to get the conflict state directly from git diff-index, but I couldn't see a way to do that :(. The manual says: 8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree". ... but this just means the value can be all-0 for either the edited or conflict states. One fix for this might be to pass maintain more state here and only call the update-function when all the passes are done. Another idea for a fix would be to notice files with an all-0 sha in diff-index, then push these names on "files"; then let the new ls-files-conflict stage determine the result. Tom diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 24dabb6..db19eb0 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -417,10 +417,22 @@ vc-git-after-dir-status-stage result)))) (`ls-files-up-to-date (setq next-stage 'ls-files-unknown) - (while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} 0\t\\([^\0]+\\)\0" nil t) + (while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} \\([0-3]\\)\t\\([^\0]+\\)\0" nil t) + (let ((perm (string-to-number (match-string 1) 8)) + (state (match-string 2)) + (name (match-string 3))) + (push (list name (if (equal state "0") + 'up-to-date + 'conflict) + (vc-git-create-extra-fileinfo perm perm)) + result)))) + (`ls-files-conflict + (setq next-stage 'ls-files-unknown) + ;; It's enough to look for "3" to notice a conflict. + (while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} 3\t\\([^\0]+\\)\0" nil t) (let ((perm (string-to-number (match-string 1) 8)) (name (match-string 2))) - (push (list name 'up-to-date + (push (list name 'conflict (vc-git-create-extra-fileinfo perm perm)) result)))) (`ls-files-unknown @@ -435,7 +447,7 @@ vc-git-after-dir-status-stage (vc-git-create-extra-fileinfo 0 0)) result))) (`diff-index - (setq next-stage (if files 'ls-files-up-to-date 'ls-files-unknown)) + (setq next-stage (if files 'ls-files-up-to-date 'ls-files-conflict)) (while (re-search-forward ":\\([0-7]\\{6\\}\\) \\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\(\\([ADMUT]\\)\0\\([^\0]+\\)\\|\\([CR]\\)[0-9]*\0\\([^\0]+\\)\0\\([^\0]+\\)\\)\0" nil t 1) @@ -491,6 +503,9 @@ vc-git-dir-status-goto-stage (`ls-files-up-to-date (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-c" "-s" "--")) + (`ls-files-conflict + (vc-git-command (current-buffer) 'async files + "ls-files" "-z" "-c" "-s" "--")) (`ls-files-unknown (vc-git-command (current-buffer) 'async files "ls-files" "-z" "-o" "--directory"