Subject: [PATCH] Teach 'git-apply --whitespace=strip' to remove empty lines at end of file

From: Marco Costalba <[email-masked]>
Date: Sat, 19 May 2007 15:12:50 +0200

Signed-off-by: Marco Costalba <[email-masked]>
---
  builtin-apply.c |    4 ++++
  1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/builtin-apply.c b/builtin-apply.c
index 0399743..f17f838 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1738,6 +1738,10 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag, i
  		newsize--;
  	}

+	if (new_whitespace == strip_whitespace)
+		while (newsize > 1 && !strncmp(new + newsize - 2, "\n\n", 2))
+			newsize--;
+
  	oldlines = old;
  	newlines = new;
  	leading = frag->leading;
-- 
1.5.2.rc3.87.g404fd-dirty