Skip to content

"Context" and "Unified" renderers should handle "No EOL at EOF" #23

@jfcherng

Description

@jfcherng

When it involves in "No EOL at EOF", the current diff output can not be successfully applied via GNU patch. The correct result can be generated by GNU diff with

# for Context with extra one line context
# " | tail -n +3" removes those 2 file path headers
$ diff --context=1 old_file.txt new_file.txt | tail -n +3

# for Unified with extra one line context
# " | tail -n +3" removes those 2 file path headers
$ diff --unified=1 old_file.txt new_file.txt | tail -n +3

old_file.txt (no EOL at EOF):

A
B
X

new_file.txt (has EOL at EOF):

A
C
X


Our current outputs (Context):

***************
*** 1,3 ****
  A
! B
  X
--- 1,4 ----
  A
! C
  X
+ 

GNU diff (Context):

***************
*** 1,3 ****
  A
! B
! X
\ No newline at end of file
--- 1,3 ----
  A
! C
! X

Our current outputs (Unified):

@@ -1,3 +1,4 @@
 A
-B
+C
 X
+

GNU diff (Unified):

@@ -1,3 +1,3 @@
 A
-B
-X
\ No newline at end of file
+C
+X

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions