From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.bugs Subject: bug#54034: 29.0.50; Diff prettify broken for empty files Date: Thu, 07 Apr 2022 14:15:25 +0200 Message-ID: <87fsmpm6n6.fsf@gmail.com> References: <87iltex7bo.fsf@gmail.com> <87v8xakm0i.fsf@gmail.com> <87bkz1jxd9.fsf@gmail.com> <87sfsbakqo.fsf@gmail.com> <87ee3v9ylm.fsf@gmail.com> <87wng1omfa.fsf@gmail.com> <87sfqpnzar.fsf@gmail.com> <87o81dnyxl.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37687"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 54034@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 07 14:16:40 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 1ncR43-0009e4-Nr for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Apr 2022 14:16:39 +0200 Original-Received: from localhost ([::1]:59264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncR41-00022A-RI for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Apr 2022 08:16:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncR3W-00021u-Ig for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2022 08:16:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncR3S-0004Cw-13 for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2022 08:16:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ncR3R-000615-TS for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2022 08:16:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Matthias Meulien Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Apr 2022 12:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54034 X-GNU-PR-Package: emacs Original-Received: via spool by 54034-submit@debbugs.gnu.org id=B54034.164933373821608 (code B ref 54034); Thu, 07 Apr 2022 12:16:01 +0000 Original-Received: (at 54034) by debbugs.gnu.org; 7 Apr 2022 12:15:38 +0000 Original-Received: from localhost ([127.0.0.1]:60089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncR34-0005c3-02 for submit@debbugs.gnu.org; Thu, 07 Apr 2022 08:15:38 -0400 Original-Received: from mail-wm1-f47.google.com ([209.85.128.47]:53894) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncR32-0005Tw-9e for 54034@debbugs.gnu.org; Thu, 07 Apr 2022 08:15:36 -0400 Original-Received: by mail-wm1-f47.google.com with SMTP id p189so3397335wmp.3 for <54034@debbugs.gnu.org>; Thu, 07 Apr 2022 05:15:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=GS8Zn0Gcyxr7GkFczTGSa6v39DX5OTBa1frNivugzpg=; b=cI5WmnkWO9C4gKw58zlrBKufpkUffoMGpp1Ao7v2iJLsyo8pZLIwhWmeRO1Noti95r IJh9yGN1lxl9F1vW9/5JoFrezFis9fOhItLbnUCcu6QlIxWOxfKTLjDP9Blf0bqh8Ytw huWoWTnLo77j/afWv94VVE+jj56NjiEPf7BKqbLpoy7Zlv9otsZyIG6Fv75vhqteG4ig FrWfidCfN5/QJTkk9GonKxU70kJvSxO42NyCJmUXnfgc9DWNejSdUfxTLp4ZaMa0HJR1 ZgsiQt11x/R5fTZAHzf1BwH+M+Rxy0zYhkvnFvXmSrgYDa8A7b9ajHp3TP+Z66/KdiYx piTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=GS8Zn0Gcyxr7GkFczTGSa6v39DX5OTBa1frNivugzpg=; b=w4Ptq/0FWxx+UlgyqgJwI6TvKcQYn1ioSpwnOgWMXehD1g90JbxbaMZ22l6IWVoQLB 2GCnJ7LibCOZysOp96XAVS4dWv+xnO70F49b5aE9ew0MIT0e/usZPnIkOdZzIg/Efniv KtE0+mRCxmfVFXw5uT7Kipaeuc2FQHZwaXHjEQZ99l09UWkHrmQ2xt4RDl6JLTvozb3M BLUAvKwPfnD0Leutqwy0vxVzuzw0yaNYtZ/n0wGlee3ef3Ar2StaWltirLcWdYPfjmP8 IWqIbuXar8VZZKkQNe3TAyN1xffb/x/kOH5D0uUAUddHjZTPQrHESRKVRRPmUI+Pdy6q Gk9A== X-Gm-Message-State: AOAM530ayJKrE+rBXusn1mm7l7GfrMaP1BB2+U+BP9myZT1BjfQiwy9D HAYn4hJVrZaAxP8mPwTDGI8Fd6a3btE= X-Google-Smtp-Source: ABdhPJxl6pIOC7ipmjrUp3HtDmHRQkjTMoPgYbc6NQyVXcXnWRQZ4kmj/xGoEYrhpkPAwnwYmCQkeA== X-Received: by 2002:a05:600c:3d13:b0:38e:5132:7f9 with SMTP id bh19-20020a05600c3d1300b0038e513207f9mr12188364wmb.19.1649333730336; Thu, 07 Apr 2022 05:15:30 -0700 (PDT) Original-Received: from carbon.localdomain ([2a01:e0a:245:c850:98f5:429a:aa8e:95bb]) by smtp.gmail.com with ESMTPSA id l6-20020a1c2506000000b0038e6fe8e8d8sm10718639wml.5.2022.04.07.05.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 05:15:29 -0700 (PDT) In-Reply-To: <87o81dnyxl.fsf@gmail.com> (Matthias Meulien's message of "Thu, 07 Apr 2022 09:19:02 +0200") 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:229525 Archived-At: --=-=-= Content-Type: text/plain As seen in git-diff man page, file modes are printed as 6-digit octal numbers. I changed the corresponding regexp accordingly. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Display-file-mode-information-when-diff-font-lock-pr.patch >From 6ada335f2ff58bc9dd9cf9cf8d2a571087b49600 Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Thu, 7 Apr 2022 00:11:55 +0200 Subject: [PATCH] Display file mode information when diff font lock prettify enabled * lisp/vc/diff-mode.el (diff--font-lock-prettify): Make regexp capture file mode information. --- lisp/vc/diff-mode.el | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 511cc89778..5c13c7fc38 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2634,42 +2634,55 @@ diff--font-lock-prettify (binary (concat "Binary files " file4 " and " file5 " \\(?7:differ\\)\n")) - (horb (concat "\\(?:" header "\\|" binary "\\)"))) + (horb (concat "\\(?:" header "\\|" binary "\\)?"))) (concat "diff.*?\\(?: a/\\(.*?\\) b/\\(.*\\)\\)?\n" - "\\(?:\\(?:old\\|new\\) mode .*\n\\)*" "\\(?:" ;; For new/deleted files, there might be no ;; header (and no hunk) if the file is/was empty. - "\\(?3:new\\(?6:\\)\\|deleted\\) file.*\n" - index "\\(?:" horb "\\)?" - ;; Normal case. - "\\|" index horb "\\)"))))) + "\\(?3:new\\(?6:\\)\\|deleted\\) file mode \\(?10:[0-7]\\{6\\}\\)\n" + index horb + ;; Normal case. There might be no header + ;; (and no hunk) if only the file mode + ;; changed. + "\\|" + "\\(?:old mode \\(?8:[0-7]\\{6\\}\\)\n\\)?" + "\\(?:new mode \\(?9:[0-7]\\{6\\}\\)\n\\)?" + index horb "\\)"))))) ;; The file names can be extracted either from the `diff' line ;; or from the two header lines. Prefer the header line info if ;; available since the `diff' line is ambiguous in case the ;; file names include " b/" or " a/". ;; FIXME: This prettification throws away all the information - ;; about file modes (and the index hashes). + ;; about the index hashes. (let ((oldfile (or (match-string 4) (match-string 1))) (newfile (or (match-string 5) (match-string 2))) (kind (if (match-beginning 7) " BINARY" - (unless (or (match-beginning 4) (match-beginning 5)) - " empty")))) + (unless (or (match-beginning 4) + (match-beginning 5) + (not (match-beginning 3))) + " empty"))) + (filemode + (cond + ((match-beginning 10) + (concat " file with mode " (match-string 10) " ")) + ((and (match-beginning 8) (match-beginning 9)) + (concat " file (mode changed from " + (match-string 8) " to " (match-string 9) ") ")) + (t " file ")))) (add-text-properties (match-beginning 0) (1- (match-end 0)) (list 'display (propertize (cond ((match-beginning 3) - (concat (capitalize (match-string 3)) kind " file" - " " + (concat (capitalize (match-string 3)) kind filemode (if (match-beginning 6) newfile oldfile))) - ((null (match-string 4)) - (concat "New" kind " file " newfile)) + ((and (null (match-string 4)) (match-string 5)) + (concat "New " kind filemode newfile)) ((null (match-string 2)) - (concat "Deleted" kind " file " oldfile)) + (concat "Deleted" kind filemode oldfile)) (t - (concat "Modified" kind " file " oldfile))) + (concat "Modified" kind filemode oldfile))) 'face '(diff-file-header diff-header)) 'font-lock-multiline t)))))) nil) -- 2.30.2 --=-=-=--