From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#26066: 26.0.50; vc-git-status gives wrong result Date: Sun, 09 Apr 2017 22:58:11 -0400 Message-ID: <87inmdt1do.fsf@users.sourceforge.net> 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> <7fccafd3-e2c2-204a-05a0-a930a4cbb7e4@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1491793034 16247 195.159.176.226 (10 Apr 2017 02:57:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 10 Apr 2017 02:57:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: 26066@debbugs.gnu.org, Dmitry Gutov To: Jonathan Ganc Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 10 04:57:09 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 1cxPVp-00045m-9V for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Apr 2017 04:57:05 +0200 Original-Received: from localhost ([::1]:60347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxPVv-000302-Cm for geb-bug-gnu-emacs@m.gmane.org; Sun, 09 Apr 2017 22:57:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxPVp-0002zm-LY for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 22:57:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxPVm-00033M-Gl for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 22:57:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxPVm-000336-Cb for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 22:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cxPVm-0007m2-62 for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 22:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Apr 2017 02:57: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.149179301429862 (code B ref 26066); Mon, 10 Apr 2017 02:57:02 +0000 Original-Received: (at 26066) by debbugs.gnu.org; 10 Apr 2017 02:56:54 +0000 Original-Received: from localhost ([127.0.0.1]:40389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxPVd-0007la-RS for submit@debbugs.gnu.org; Sun, 09 Apr 2017 22:56:54 -0400 Original-Received: from mail-io0-f195.google.com ([209.85.223.195]:34968) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxPVc-0007lL-3l for 26066@debbugs.gnu.org; Sun, 09 Apr 2017 22:56:52 -0400 Original-Received: by mail-io0-f195.google.com with SMTP id t68so1355749iof.2 for <26066@debbugs.gnu.org>; Sun, 09 Apr 2017 19:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=yz6uGAAcD02pR7/J1unlhmHLhE8cCpIN7XLOhnBnKYg=; b=m11TZ7XIPFj4MGEoukohghTgQpkI+UcXf4Mtf1tJgkx4uD0O3gqTN3K7U+/Wc9Wg3i Z5t+edu6/NtPL6j8GOlqTfsxXVT8v643Ony/0pL5MRx8lijSrGnZUYjCjlE+0Iat/rzr nE5AJUMQkSD03n0ycKv4HI6RdjBY5YrsnhFUFK0GvzAWN1QVTymtrKEuSLhN7782aXFq 64C1uP9IWAn2ZedsacA3kPDZb0NIu79teRoMkt5FOAqVJGVntRdm49tvLq+r80mcW8S2 CbT/m699FTzC1CXvr4wRL0/mN0FlPaT0Eq+UdAf7XDHXJEuX5TLGuT0JWPND07r0Mt86 WlKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=yz6uGAAcD02pR7/J1unlhmHLhE8cCpIN7XLOhnBnKYg=; b=k/tI/Tqr/cm7n27y9mGWFFCR7IuKYBP2XchdViyxXzRyrALH8MBR/KMfKASSnA4zIC rpoo32BzPs4ccZyMJc00KB02tuTffHy/H/Mkszjb1+dn67E4nsppzdZPT3we/F9n1tUa lsDtaGnzz5aYmFUuDoZJF1c6HjNs7XvrJqOHKJPOafwybvCNGsfEYozsUCnayj0Qoy3d J1VbTmLUeg1EIaIY9FE0B8eziO+O55GRZB9XgF/PvWj3x8Vz9JripeXPzpUDmX53YNOc T4XZozBzRuuP0y2KqUMWuyr5ZYEfNPleIx3Ts1olLfuLPLxJ5PzRGU5Gk35XopTMspeJ UCKw== X-Gm-Message-State: AN3rC/4yY8UC2ZSKJEH34z0d546F9w254FK7RkR81MzN3Y0DhYIlqC5EzFeCxSe/jsAjQA== X-Received: by 10.107.6.6 with SMTP id 6mr11066758iog.78.1491793006503; Sun, 09 Apr 2017 19:56:46 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id u63sm439624itb.16.2017.04.09.19.56.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Apr 2017 19:56:46 -0700 (PDT) In-Reply-To: <7fccafd3-e2c2-204a-05a0-a930a4cbb7e4@gmail.com> (Jonathan Ganc's message of "Thu, 30 Mar 2017 23:16:02 -0400") 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:131430 Archived-At: Jonathan Ganc writes: > > +(defun vc-git--git-status-to-vc-state (code-list) > + (setq code-list (remq nil code-list)) > + (pcase code-list > + ('nil 'up-to-date) You seem to be handling nil in 2 different ways. > + ;; have only seen this with a file that is only present in the > + ;; index. let us call this `removed' Comments should be full sentences (start with uppercase, end with period), and sentences should be separated with double spaces. > (defun vc-git-state (file) > "Git-specific version of `vc-state'." > + > + (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) > + (while (string-match "^\\(..\\)[^\0]+\0\\(\\(?:a\\|[^a]\\)*\\)$" status) I think you're missing a space after the first 2 characters. alternate -z format recommended for machine parsing. [...] Second, a NUL (ASCII 0) follows each filename, [...] (but a space still separates the status field from the first filename). > + (add-to-list 'code-list (match-string 1 status) t 'ignore) Don't use `add-to-list' on local variables. The usual idiom for collecting a series of items in a list would be (let ((code-list nil)) (while ... (push ... code-list)) (setq code-list (nreverse code-list))) > + (setq status (match-string 2 status))) Instead of matching the rest of the string in the regexp, just set a position variable to (match-end 0), and then pass that position as the string-match's START parameter.