lb-format may generate invalid patch for files without trailing newline
the problem can be reproduced with the following recipe on lxplus:
$ cd $TMPDIR
$ git init test_repo
Initialized empty Git repository in /tmp/test_repo/.git/
$ cd test_repo
$ echo -en "print('hello')\n\n " > test.py
$ git add test.py
$ git commit -m 'reference'
[master (root-commit) 23dc122] reference
1 file changed, 3 insertions(+)
create mode 100644 test.py
$ echo -en "print('hello')\n\nprint( 'test' )\n " > test.py
$ git commit -am 'to fix'
[master 4aa6ee9] to fix
1 file changed, 1 insertion(+)
$ lb-format --format-patch test.patch HEAD~
=======================================
You can fix formatting with:
git am test.patch
=======================================
$ git am test.patch
Applying: Fixed formatting
fatal: corrupt patch at line 8
Patch failed at 0001 Fixed formatting
The copy of the patch that failed is found in:
/tmp/test_repo/.git/rebase-apply/patch
When you have resolved this problem, run "git am --resolved".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
$ cat test.patch
From: Gitlab CI <noreply@cern.ch>
Date: Tue, 28 May 2019 10:13:00 -0000
Subject: [PATCH] Fixed formatting
patch generated by standalone job
--- a/test.py
+++ b/test.py
@@ -1,4 +1,3 @@
print('hello')
-print( 'test' )
- +print('test')
$
Edited by Marco Clemencic