at v192 2.3 kB view raw
1From 58987954647f51dc42fb13b7759923c6170dd905 Mon Sep 17 00:00:00 2001 2From: Tim Waugh <twaugh@redhat.com> 3Date: Fri, 9 May 2014 16:23:27 +0100 4Subject: Make --clean drop comments after '@@' lines as well (trac #29). 5 6 7diff --git a/Makefile.am b/Makefile.am 8index 99ad2a3..f3c6dbc 100644 9--- a/Makefile.am 10+++ b/Makefile.am 11@@ -198,6 +198,7 @@ TESTS = tests/newline1/run-test \ 12 tests/convert1/run-test \ 13 tests/convert2/run-test \ 14 tests/clean1/run-test \ 15+ tests/clean2/run-test \ 16 tests/stdin/run-test 17 18 # These ones don't work yet. 19diff --git a/src/filterdiff.c b/src/filterdiff.c 20index 383e72b..6ca2316 100644 21--- a/src/filterdiff.c 22+++ b/src/filterdiff.c 23@@ -2,7 +2,7 @@ 24 * filterdiff - extract (or exclude) a diff from a diff file 25 * lsdiff - show which files are modified by a patch 26 * grepdiff - show files modified by a patch containing a regexp 27- * Copyright (C) 2001, 2002, 2003, 2004, 2008, 2009, 2011 Tim Waugh <twaugh@redhat.com> 28+ * Copyright (C) 2001, 2002, 2003, 2004, 2008, 2009, 2011, 2013, 2014 Tim Waugh <twaugh@redhat.com> 29 * 30 * This program is free software; you can redistribute it and/or modify 31 * it under the terms of the GNU General Public License as published by 32@@ -408,7 +408,8 @@ do_unified (FILE *f, char *header[2], int match, char **line, 33 " Hunk #%lu, %s", 34 hunknum, bestname); 35 36- fputs (trailing, output_to); 37+ fputs (clean_comments ? "\n" : trailing, 38+ output_to); 39 break; 40 case Before: 41 // Note the initial line number 42diff --git a/tests/clean2/run-test b/tests/clean2/run-test 43new file mode 100755 44index 0000000..42320df 45--- /dev/null 46+++ b/tests/clean2/run-test 47@@ -0,0 +1,34 @@ 48+#!/bin/sh 49+ 50+# This is a filterdiff(1) testcase. 51+# Test: Make sure --clean removes hunk-level comments. 52+ 53+ 54+. ${top_srcdir-.}/tests/common.sh 55+ 56+cat << EOF > diff 57+non-diff line 58+--- a/file1 59++++ b/file1 60+@@ -0,0 +1 @@ this is a hunk-level comment 61++a 62+EOF 63+ 64+${FILTERDIFF} --clean diff 2>errors >filtered || exit 1 65+[ -s errors ] && exit 1 66+ 67+cat << EOF | cmp - filtered || exit 1 68+--- a/file1 69++++ b/file1 70+@@ -0,0 +1 @@ 71++a 72+EOF 73+ 74+${FILTERDIFF} --clean -x file1 diff 2>errors >filtered || exit 1 75+[ -s errors ] && exit 1 76+cat << EOF | cmp - filtered || exit 1 77+--- a/file1 78++++ b/file1 79+@@ -0,0 +1 @@ 80++a 81+EOF 82-- 83cgit v0.10.1 84