Project

General

Profile

Actions

Defect #17809

closed

wrong syntax highlighting "---" header and "--" footer of git diff

Added by Tobias Fischer over 9 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
UI
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

Rendering of patches adds an additional "deletion" line for the following (standard) diff syntax:

Whereas the "deletion" of line 22 in the screenshot isn't part of the changeset at all:

From 9b1992fe9db52e1df90a6a963a686cd2cf20e706 Mon Sep 17 00:00:00 2001
From: Tobias Fischer
Date: Sat, 6 Sep 2014 12:22:02 +0200
Subject: [PATCH]  Additional view hook "body_top" 

In the same way as "view_layouts_base_body_bottom" exists...
---
 app/views/layouts/base.html.erb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb
index 99ad13f..45ef5bd 100644
--- a/app/views/layouts/base.html.erb
+++ b/app/views/layouts/base.html.erb
@@ -16,6 +16,7 @@
 <%= yield :header_tags -%>
 </head>
 <body class="<%=h body_css_classes %>">
+<%= call_hook :view_layouts_base_body_top %>
 <div id="wrapper">
 <div id="wrapper2">
 <div id="wrapper3">
-- 
1.8.5.2 (Apple Git-48)

And also this diff gets wrong syntax highlighting for the meta-lines "---" and "-- "

So I would expect the line 22 not to be rendered at all and an the syntax highlighting, there should be no highlighting for "---" and "-- "


Files

patch_screenshot.png (28 KB) patch_screenshot.png Tobias Fischer, 2014-09-06 12:31
3.4.png (33.3 KB) 3.4.png Toshi MARUYAMA, 2020-04-26 17:13
4.1.png (30 KB) 4.1.png Toshi MARUYAMA, 2020-04-26 17:13
Actions #1

Updated by Toshi MARUYAMA over 9 years ago

  • Subject changed from rendering of patch files (attachments) has a bug in reading the patch/diff format to rendering extra "--" footer of git patch
Actions #2

Updated by Toshi MARUYAMA over 9 years ago

Tobias Fischer wrote:

the following (standard) diff syntax:

It is not standard diff format.
It is git additional footer.
Mercurial patch does not have such footer.
source:tags/2.5.2/test/fixtures/diffs/issue-12641-ja.diff

Actions #3

Updated by Toshi MARUYAMA over 9 years ago

  • Subject changed from rendering extra "--" footer of git patch to rendering extra "---" header and "--" footer of git patch
Actions #4

Updated by Tobias Fischer over 9 years ago

Toshi MARUYAMA wrote:

Tobias Fischer wrote:

the following (standard) diff syntax:

It is not standard diff format.
It is git additional footer.
Mercurial patch does not have such footer.

Oh, okay, sorry then.
But anyways, the "deletion" line shouldn't be rendered for git diffs then ;-)

Actions #5

Updated by Go MAEDA about 4 years ago

It can be fixed with the following code:

diff --git a/lib/redmine/unified_diff.rb b/lib/redmine/unified_diff.rb
index 67292cf0f..5c258b564 100644
--- a/lib/redmine/unified_diff.rb
+++ b/lib/redmine/unified_diff.rb
@@ -78,7 +78,7 @@ module Redmine
           @parsing = true
         end
       else
-        if %r{^[^\+\-\s@\\]}.match?(line)
+        if /^([^\+\-\s@\\]|-- $)/.match?(line)
           @parsing = false
           return false
         elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/
Actions #6

Updated by Toshi MARUYAMA almost 4 years ago

  • Category changed from Attachments to UI
Actions #7

Updated by Toshi MARUYAMA almost 4 years ago

Go MAEDA wrote:

It can be fixed with the following code:

No.

I have created new #33357.

Actions #8

Updated by Toshi MARUYAMA almost 4 years ago

  • File 3.4.png 3.4.png added
  • File 4.1.png 4.1.png added
  • Subject changed from rendering extra "---" header and "--" footer of git patch to wrong syntax highlighting "---" header and "--" footer of git diff
  • Status changed from New to Closed

3.4

4.1

Actions #9

Updated by Toshi MARUYAMA almost 4 years ago

Toshi MARUYAMA wrote:

Go MAEDA wrote:

It can be fixed with the following code:

No.

I have created new #33357.

I have written reason at #33357#note-2.

Actions

Also available in: Atom PDF