[BUG] apply: test for trailing whitespace & no new line bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: SZEDER Gábor <szeder@xxxxxxxxxx>

If a patch adds a new line to the end of a file and this line ends
with trailing whitespace but has no newline, then 'git apply
--whitespace=fix' does not remove the trailing whitespace from that
line.

Signed-off-by: SZEDER Gábor <szeder@xxxxxxxxxx>
---

Noticed last week, but couldn't fix it myself during the weekend.

 t/t4124-apply-ws-rule.sh |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh
index f83322e..0db9b59 100755
--- a/t/t4124-apply-ws-rule.sh
+++ b/t/t4124-apply-ws-rule.sh
@@ -148,4 +148,22 @@ do
 	done
 done
 
+create_patch () {
+	sed -e "s/_/ /" <<-\EOF
+		diff --git a/target b/target
+		index e69de29..8bd6648 100644
+		--- a/target
+		+++ b/target
+		@@ -0,0 +1 @@
+		+A line with trailing whitespace and no newline_
+		\ No newline at end of file
+	EOF
+}
+
+test_expect_failure 'trailing whitespace & no newline at the end of file' '
+	>target &&
+	create_patch | git apply --whitespace=fix - &&
+	git diff --check -- target
+'
+
 test_done
-- 
1.6.3.2.370.g6bb4.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]