From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: dick Newsgroups: gmane.emacs.bugs Subject: bug#58709: 29.0.50; [PATCH] Fallout 307ad21 Date: Sat, 22 Oct 2022 08:35:59 -0400 Message-ID: <87r0z0yr0w.fsf@dick> References: <87czal12oi.fsf@dick> Mime-Version: 1.0 Content-Type: text/x-diff Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2958"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.14 (Gnus v5.14) To: 58709@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 24 06:33:27 2022 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 1omp9S-0000Yd-9M for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Oct 2022 06:33:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omhuV-0003zy-7P for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 23 Oct 2022 16:49:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omGEF-0008RL-34 for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 11:16:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omGEE-0005qc-Sv for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 11:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1omGEE-0001XG-NW for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2022 11:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: dick Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Oct 2022 15:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58709 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58709-submit@debbugs.gnu.org id=B58709.16664517325839 (code B ref 58709); Sat, 22 Oct 2022 15:16:02 +0000 Original-Received: (at 58709) by debbugs.gnu.org; 22 Oct 2022 15:15:32 +0000 Original-Received: from localhost ([127.0.0.1]:42179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omGDh-0001W5-OP for submit@debbugs.gnu.org; Sat, 22 Oct 2022 11:15:32 -0400 Original-Received: from mail-qk1-f174.google.com ([209.85.222.174]:36434) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1omDjS-0005SI-M7 for 58709@debbugs.gnu.org; Sat, 22 Oct 2022 08:36:09 -0400 Original-Received: by mail-qk1-f174.google.com with SMTP id f8so3649216qkg.3 for <58709@debbugs.gnu.org>; Sat, 22 Oct 2022 05:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:user-agent:message-id:date :references:in-reply-to:subject:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z2wSYSmZWTQPVLed4uJjiI76DXKS9v7s0mdk3Aj4yl8=; b=VBSlY2Qg75g7RC9Xr8cJaGuvb/JPnrgfybIpxLxhdTK3iGMizDqBrBTg9tYjBIy+hC e7c4iN8tYcOO+T9cADoAt7NmkKnNy+fWmWNapILiKEjOAzXTZ2yF4CT0Sd9idjGcAyHu bLeelgf6Fsb7Umxy7s/X1AJRZE459+r8zluIa8C6KS8w94QaocpnqbysPJuqeHopQ2Un 0agxE06MlaxhKnpNuRWN/yfGHoscqo8RwWnRixy/FdAzPaVMt+reUJm0ZHeYcoMRhtjV gVhX69sPYcaTqyDbEQAOBX9s8zdLgaXXdPYcjMpJETMfmnZsd6LUXHRe7rw6RYFe2XY9 jV/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:user-agent:message-id:date :references:in-reply-to:subject:to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Z2wSYSmZWTQPVLed4uJjiI76DXKS9v7s0mdk3Aj4yl8=; b=PKx2Ay953PYUzJ0F49KCOLPNoBETNexXkxwH1mevHfJVCZlh7hJoaigpD+bpCr6iQR Yc/ibE3x2EUt/S3TQtHZrLs5tp4tPqX6DieDnKJn0GBZZPbEO7ZHndtZQpyWhp4VD4O/ zGiy1rIzHKFKRHTbWGe/XnA5k1NBhF2Thmn3Py3PaCVFEMg80gBcuDUxGmLIBJ3Vmb2d Y7pNjz0nAir8VyZ71VLM/7ZCTn68G6DzrNdjwR58E2ZhWXEds13tPV/ql3ub4L9zrM4d mlM7uxm9draOVOOVaqj7KQ1Crb5PLtAbhVGIAm9lfjzglBIS7i4diLRjVnV6/8BoV0A4 pp5A== X-Gm-Message-State: ACrzQf3xnJTv+g3e7UD0R6ombmcvpXR4u+IlZDvo7HYnCs/CcxJsdP75 CLQtIZ0+HHdoxTVM7PJdsBUdbbFf1sY= X-Google-Smtp-Source: AMsMyM5sd4jSkhRzPiFG+FRn9++gp4s2IJrjJ/a1T6Tmc2FuRTjQfIiGJJnTmL91I+vcK/UtHVGVrQ== X-Received: by 2002:a05:620a:24cf:b0:6ee:6fb:4adf with SMTP id m15-20020a05620a24cf00b006ee06fb4adfmr16917808qkn.755.1666442160930; Sat, 22 Oct 2022 05:36:00 -0700 (PDT) Original-Received: from localhost (pool-173-56-234-28.nycmny.fios.verizon.net. [173.56.234.28]) by smtp.gmail.com with ESMTPSA id h6-20020ac85846000000b0039a9b55b829sm9769263qth.29.2022.10.22.05.36.00 for <58709@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 05:36:00 -0700 (PDT) In-Reply-To: <87czal12oi.fsf@dick> (dick's message of "Fri, 21 Oct 2022 13:55:57 -0400") Content-Disposition: attachment; filename=0001-Fallout-307ad21.patch X-Mailman-Approved-At: Sat, 22 Oct 2022 11:15:28 -0400 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:246076 Archived-At: >From 2ad882ac82cbb03674699f09c98bdb5e7481843b Mon Sep 17 00:00:00 2001 From: dickmao Date: Sat, 22 Oct 2022 08:33:53 -0400 Subject: [PATCH] Fallout 307ad21 * lisp/vc/vc-git.el (vc-git-working-revision): For better or worse, 307ad21 dupes vc-git--symbolic-ref into this function. Throw the sha1 onto the retval as a hack to recover sha1. (vc-git-mode-line-string): Recover the sha1 for John Q. User. * test/lisp/vc/vc-git-tests.el (vc-git-test--mock-repo): (vc-git-test-detached-head): Test the failure when vc-refresh-state goes after a detached HEAD branch. --- lisp/vc/vc-git.el | 26 +++++++++----------------- test/lisp/vc/vc-git-tests.el | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 3c6afec0378..8682770635d 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -374,31 +374,23 @@ vc-git-state (defun vc-git-working-revision (_file) "Git-specific version of `vc-working-revision'." (let* ((process-file-side-effects nil) - (commit (vc-git--rev-parse "HEAD" t))) - (or (vc-git-symbolic-commit commit) commit))) - -(defun vc-git--symbolic-ref (file) - (or - (vc-file-getprop file 'vc-git-symbolic-ref) - (let* (process-file-side-effects - (str (vc-git--run-command-string nil "symbolic-ref" "HEAD"))) - (vc-file-setprop file 'vc-git-symbolic-ref - (if str - (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) - (match-string 2 str) - str)))))) + (commit (vc-git--rev-parse "HEAD" t)) + (name (vc-git-symbolic-commit commit))) + (or (prog1 name + (add-text-properties 0 (length name) `(commit ,commit) name)) + commit))) (defun vc-git-mode-line-string (file) "Return a string for `vc-mode-line' to put in the mode line for FILE." (let* ((rev (vc-working-revision file 'Git)) - (disp-rev (or (vc-git--symbolic-ref file) - (and rev (substring rev 0 7)))) (def-ml (vc-default-mode-line-string 'Git file)) (help-echo (get-text-property 0 'help-echo def-ml)) (face (get-text-property 0 'face def-ml))) - (propertize (concat (substring def-ml 0 4) disp-rev) + (propertize (concat (substring def-ml 0 4) rev) 'face face - 'help-echo (concat help-echo "\nCurrent revision: " rev)))) + 'help-echo (concat help-echo "\nCurrent revision: " + (when rev + (or (get-text-property 0 'commit rev) rev)))))) (cl-defstruct (vc-git-extra-fileinfo (:copier nil) diff --git a/test/lisp/vc/vc-git-tests.el b/test/lisp/vc/vc-git-tests.el index dc9641ed46b..c46e1c55942 100644 --- a/test/lisp/vc/vc-git-tests.el +++ b/test/lisp/vc/vc-git-tests.el @@ -56,6 +56,31 @@ vc-git-test-program-version-invalid-leading-dot "git version .2.30.1.5" "0")) +(defmacro vc-git-test--mock-repo (&rest body) + (declare (indent defun)) + `(let* ((dir (make-temp-file "vc-git-tests" t)) + (default-directory dir)) + (unwind-protect + (progn + (vc-git-create-repo) + (vc-git-command nil 0 nil "config" "--add" "user.name" "frou") + ,@body) + (delete-directory dir t)))) + +(ert-deftest vc-git-test-detached-head () + (skip-unless (executable-find vc-git-program)) + (require 'log-edit) + (vc-git-test--mock-repo + (with-temp-file "foo") + (condition-case err + (progn + (vc-git-register (split-string "foo")) + (vc-git-checkin (split-string "foo") "No-Verify: yes +his fooness") + (vc-git-checkout nil (vc-git--rev-parse "HEAD" t))) + (error (signal (car err) (with-current-buffer "*vc*" (buffer-string))))) + (find-file-noselect "foo"))) + (defun vc-git-test--run-program-version-test (mock-version-string expected-output) (cl-letf* (((symbol-function 'vc-git--run-command-string) -- 2.36.1