From unknown Wed Sep 10 08:16:01 2025 X-Loop: help-debbugs@gnu.org Subject: bug#43297: 27.1; corrupts patch when diff-update-on-the-fly is set to nil Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Sep 2020 19:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43297 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 43297@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.159968113225296 (code B ref -1); Wed, 09 Sep 2020 19:53:01 +0000 Received: (at submit) by debbugs.gnu.org; 9 Sep 2020 19:52:12 +0000 Received: from localhost ([127.0.0.1]:34803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG68Z-0006Zw-OO for submit@debbugs.gnu.org; Wed, 09 Sep 2020 15:52:12 -0400 Received: from lists.gnu.org ([209.51.188.17]:56130) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kG68X-0006Zo-DL for submit@debbugs.gnu.org; Wed, 09 Sep 2020 15:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG68X-0002sD-57 for bug-gnu-emacs@gnu.org; Wed, 09 Sep 2020 15:52:09 -0400 Received: from world.peace.net ([64.112.178.59]:35420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kG68U-0000DI-Ri for bug-gnu-emacs@gnu.org; Wed, 09 Sep 2020 15:52:08 -0400 Received: from mhw by world.peace.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kG68H-0005Fc-8j; Wed, 09 Sep 2020 15:51:53 -0400 From: Mark H Weaver Date: Wed, 09 Sep 2020 15:50:36 -0400 Message-ID: <87r1rag254.fsf@netris.org> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=64.112.178.59; envelope-from=mhw@netris.org; helo=world.peace.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/09 15:51:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) I don't know if this behavior is new in 27.1, but that's the only version I've tried this on. When I set 'diff-update-on-the-fly' to nil, I find that some patches are consistently corrupted when I save them while in diff-mode. See below for an example patch that demonstrates this behavior. To reproduce: * Save the example patch below to "test.patch", and make another copy in "test2.patch". * Launch "emacs -nw -q" (I used Emacs 27.1) * Evaluate (setq diff-update-on-the-fly nil) * Find file "test2.patch". * Add a character anywhere in the buffer and then delete it, such that the buffer is now in a "modified" state. * Save the file. * Run "diff -u test.patch test2.patch" in the shell. * Here's the result that I see: --8<---------------cut here---------------start------------->8--- --- test.patch +++ test2.patch @@ -39,7 +39,7 @@ var elements = document.getElementsByTagName("style"); for(var i = 0; i < elements.length; i++){ -@@ -41,16 +48,20 @@ function reveal_css(){ +@@ -41,17 +48,20 @@ function reveal_css(){ } } --8<---------------cut here---------------end--------------->8--- Emacs corrupts the line count of the final hunk, making it one larger than it should be (17 instead of 16). This breaks the patch, such that attempts to apply it will fail. Note that the example patch includes the following footer immediately after the last hunk, added by "git format-patch": --8<---------------cut here---------------start------------->8--- -- 2.26.2 --8<---------------cut here---------------end--------------->8--- My guess is that the line with "--" is being interpreted as a deleted line, part of the hunk. This bug only seems to happen when 'diff-update-on-the-fly' is set to nil. The example patch that demonstrates this problem follows. Thanks, Mark --8<---------------cut here---------------start------------->8--- >From 2e8618d22568b6e00892a17303d437dd700eca98 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Tue, 5 May 2020 21:27:41 -0400 Subject: [PATCH] Revert "Update Reveal hidden HTML." I prefer the user interface of the old version. This reverts commit f6e3adb6b2344ee2c7bb453a305fd2d6fb4c194c. --- .../passive_improve_css.js | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/data/extensions/SubmitMe@0xbeef.coffee/passive_improve_css.js b/data/extensions/SubmitMe@0xbeef.coffee/passive_improve_css.js index 7692990..ca57982 100644 --- a/data/extensions/SubmitMe@0xbeef.coffee/passive_improve_css.js +++ b/data/extensions/SubmitMe@0xbeef.coffee/passive_improve_css.js @@ -10,6 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI */ +var bad = []; + function escapeHTML (unsafe_str) { return unsafe_str .replace(/&/g, '&') @@ -20,9 +22,14 @@ function escapeHTML (unsafe_str) { .replace(/\//g, '/') } +function dounhide(){ + for(var i = 0; i < bad.length; i++){ + bad[i].remove(); + } +} + console.log("passive_improve_css.js"); function reveal_css(){ - var bad = []; var elements = document.getElementsByTagName("style"); for(var i = 0; i < elements.length; i++){ @@ -41,16 +48,20 @@ function reveal_css(){ } } - if(bad.length > 0 && window.confirm("Hidden HTML detected, would you like to reveal it?")){ - for(var i = 0; i < bad.length; i++){ - bad[i].remove(); - } + if(bad.length > 0){ + const insertedDiv = document.createElement('div'); + insertedDiv.innerHTML= '

' + + 'Reveal hidden elements' + + ''; + insertedDiv.style="position:fixed; bottom:1em; right:1em; opacity:0.8; z-index: 2147483647 !important; border-radius: 3px !important; background-color: #fff !important; padding: 0.5em !important; box-shadow: 0 0 3px grey !important; font-color:#bbb!important; cursor: pointer!important;"; + insertedDiv.addEventListener("click", dounhide, false); + document.body.insertBefore(insertedDiv, document.body.firstChild); } } reveal_css(); - /* var a = document.getElementsByTagName("style")[2]; var btn = document.createElement("style"); // Create a