From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#21457: 25.0.50; vc-test-git03-working-revision test fails Date: Sat, 12 Sep 2015 12:02:24 +0300 Message-ID: <83mvws2eov.fsf@gnu.org> References: <83d1xp4cn0.fsf@gnu.org> <01lhcc3day.fsf@fencepost.gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1442048606 17507 80.91.229.3 (12 Sep 2015 09:03:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Sep 2015 09:03:26 +0000 (UTC) Cc: 21457@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 12 11:03:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZagiE-0007p7-N3 for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Sep 2015 11:03:10 +0200 Original-Received: from localhost ([::1]:59982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZagiD-00015O-PX for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Sep 2015 05:03:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZagiA-000147-0v for bug-gnu-emacs@gnu.org; Sat, 12 Sep 2015 05:03:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zagi6-0000g0-Cr for bug-gnu-emacs@gnu.org; Sat, 12 Sep 2015 05:03:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zagi6-0000fw-8m for bug-gnu-emacs@gnu.org; Sat, 12 Sep 2015 05:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Zagi5-0003uE-S6 for bug-gnu-emacs@gnu.org; Sat, 12 Sep 2015 05:03:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Sep 2015 09:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21457 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21457-submit@debbugs.gnu.org id=B21457.144204855414978 (code B ref 21457); Sat, 12 Sep 2015 09:03:01 +0000 Original-Received: (at 21457) by debbugs.gnu.org; 12 Sep 2015 09:02:34 +0000 Original-Received: from localhost ([127.0.0.1]:57608 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zaghe-0003tV-8z for submit@debbugs.gnu.org; Sat, 12 Sep 2015 05:02:34 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:39463) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zaghb-0003tM-HE for 21457@debbugs.gnu.org; Sat, 12 Sep 2015 05:02:32 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NUK000003P7IL00@a-mtaout22.012.net.il> for 21457@debbugs.gnu.org; Sat, 12 Sep 2015 12:02:29 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NUK00M353S5W4B0@a-mtaout22.012.net.il>; Sat, 12 Sep 2015 12:02:29 +0300 (IDT) In-reply-to: <01lhcc3day.fsf@fencepost.gnu.org> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:106445 Archived-At: > From: Glenn Morris > Cc: 21457@debbugs.gnu.org > Date: Fri, 11 Sep 2015 16:34:45 -0400 > > Glenn Morris wrote: > > > Perhaps it should use (min (point-max) (+ (point-min) 40)). > > Scratch that, better to test for an actual hash, "[0-9a-f]\\{40\\}". But it doesn't return a hash in a repo that was just initted, it returns "HEAD". Try this: $ mkdir ttt $ cd ttt $ git init Initialized empty Git repository in D:/gnu/git/ttt/.git/ $ git rev-parse HEAD HEAD fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' $ echo $? 128 IOW, it returns "HEAD" and exits with an error status. Maybe the problem started when I upgraded Git to 2.5.1 lately. The patches below make this work for me. The first one should probably be applied regardless, as without it vc-git--rev-parse is not safe to call in some borderline cases. diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 8a0f554..af2b39f 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -1137,7 +1137,9 @@ (defun vc-git--rev-parse (rev) (with-temp-buffer (and (vc-git--out-ok "rev-parse" rev) - (buffer-substring-no-properties (point-min) (+ (point-min) 40))))) + (buffer-substring-no-properties (point-min) + (min (1- (point-max)) + (+ (point-min) 40)))))) (defun vc-git-next-revision (file rev) "Git-specific version of `vc-next-revision'." diff --git a/test/automated/vc-tests.el b/test/automated/vc-tests.el index a7242e9..3476846 100644 --- a/test/automated/vc-tests.el +++ b/test/automated/vc-tests.el @@ -367,12 +367,15 @@ (defun vc-test--working-revision (backend) ;; nil: CVS Mtn RCS SCCS ;; "0": Bzr Hg SRC SVN - ;; "master": Git + ;; "master" or "HEAD": Git + (message "%s: %s" + backend + (vc-working-revision default-directory backend)) (should (eq (vc-working-revision default-directory) (vc-working-revision default-directory backend))) (should (member - (vc-working-revision default-directory) '(nil "0" "master"))) + (vc-working-revision default-directory) '(nil "0" "master" "HEAD"))) (let ((tmp-name (expand-file-name "foo" default-directory))) ;; Check initial working revision, should be nil until @@ -380,22 +383,22 @@ (defun vc-test--working-revision (backend) ;; nil: CVS Mtn RCS SCCS SVN ;; "0": Bzr Hg SRC - ;; "master": Git + ;; "master" or "HEAD: Git (should (eq (vc-working-revision tmp-name) (vc-working-revision tmp-name backend))) (should - (member (vc-working-revision tmp-name) '(nil "0" "master"))) + (member (vc-working-revision tmp-name) '(nil "0" "master" "HEAD"))) ;; Write a new file. Check working revision. (write-region "foo" nil tmp-name nil 'nomessage) ;; nil: CVS Mtn RCS SCCS SVN ;; "0": Bzr Hg SRC - ;; "master": Git + ;; "master" or "HEAD": Git (should (eq (vc-working-revision tmp-name) (vc-working-revision tmp-name backend))) (should - (member (vc-working-revision tmp-name) '(nil "0" "master"))) + (member (vc-working-revision tmp-name) '(nil "0" "master" "HEAD"))) ;; Register a file. Check working revision. (vc-register @@ -403,11 +406,11 @@ (defun vc-test--working-revision (backend) ;; nil: Mtn RCS SCCS ;; "0": Bzr CVS Hg SRC SVN - ;; "master": Git + ;; "master" or "HEAD": Git (should (eq (vc-working-revision tmp-name) (vc-working-revision tmp-name backend))) (should - (member (vc-working-revision tmp-name) '(nil "0" "master"))) + (member (vc-working-revision tmp-name) '(nil "0" "master" "HEAD"))) ;; Unregister the file. Check working revision. (condition-case nil @@ -416,13 +419,13 @@ (defun vc-test--working-revision (backend) ;; nil: RCS ;; "0": Bzr Hg - ;; "master": Git + ;; "master" or "HEAD": Git ;; unsupported: CVS Mtn SCCS SRC SVN (should (eq (vc-working-revision tmp-name) (vc-working-revision tmp-name backend))) (should (member - (vc-working-revision tmp-name) '(nil "0" "master")))) + (vc-working-revision tmp-name) '(nil "0" "master" "HEAD")))) (vc-not-supported t)))) ;; Save exit.