diff options
-rw-r--r-- | quilt/header.in | 7 | ||||
-rw-r--r-- | test/header.test | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/quilt/header.in b/quilt/header.in index 6a9121f..c01778f 100644 --- a/quilt/header.in +++ b/quilt/header.in @@ -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 diff --git a/test/header.test b/test/header.test index f6367b5..7e0cbca 100644 --- a/test/header.test +++ b/test/header.test @@ -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 |