[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH] header: Fix patch corruption when trailing newline i
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH] header: Fix patch corruption when trailing newline is missing |
Date: |
Mon, 1 May 2017 14:38:44 +0200 |
When editing a patch header with certain editors, it is possible that
no trailing newline character is present on the last line. In such
case, the patch would be corrupted. Prevent that by ensuring that a
newline character is always present.
This fixes bug #50841:
https://savannah.nongnu.org/bugs/?50841
Signed-off-by: Jean Delvare <address@hidden>
---
quilt/header.in | 7 +++++++
test/header.test | 13 +++++++++++++
2 files changed, 20 insertions(+)
--- quilt.orig/quilt/header.in 2017-05-01 14:36:11.587024039 +0200
+++ quilt/quilt/header.in 2017-05-01 14:36:18.776100191 +0200
@@ -154,6 +154,13 @@ else
LANG=$ORIGINAL_LANG $EDITOR "$tmp" || exit 1
fi
+ # Ensure there is a trailing newline before we append the rest
+ last_char=$(tail -c 1 "$tmp")
+ if ! [ -z "$last_char" -o "$last_char" = $'\n' -o "$last_char" = $'\r' ]
+ then
+ echo "" >> $tmp
+ fi
+
maybe_strip_diffstat < $tmp \
| maybe_strip_trailing_whitespace > $tmp2
--- quilt.orig/test/header.test 2017-05-01 14:36:12.265031221 +0200
+++ quilt/test/header.test 2017-05-01 14:36:24.003155560 +0200
@@ -42,3 +42,16 @@
> @@ -1 +1 @@
> -foo
> +bar
+
+ $ echo -n "No trailing newline" | quilt header -r
+ > Replaced header of patch patches/patch
+
+ $ cat patches/patch
+ > No trailing newline
+ > Index: b/foo
+ > ===================================================================
+ > --- a/foo
+ > +++ b/foo
+ > @@ -1 +1 @@
+ > -foo
+ > +bar
--
Jean Delvare
SUSE L3 Support
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Quilt-dev] [PATCH] header: Fix patch corruption when trailing newline is missing,
Jean Delvare <=