summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2013-08-19 22:35:18 +0200
committerAndreas Gruenbacher <agruen@linbit.com>2013-08-19 22:44:46 +0200
commita2f4bfe0f3f54181a8f1077cde9ebef0b4f891c0 (patch)
treea045098cc1059d2af718cf79bdc45cc2e5b2ce06
parent89dbba72299f5bf32ecb757d5a568954d0a11b2d (diff)
downloadpatch-a2f4bfe0f3f54181a8f1077cde9ebef0b4f891c0.tar.gz
Preserve function names in reject files
* src/patch.c (main): Preserve function names in reject files. * tests/reject-format: Update the test case. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
-rw-r--r--NEWS2
-rw-r--r--src/patch.c3
-rw-r--r--tests/reject-format4
3 files changed, 6 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 28d0e91..7c2284d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+* Function names in hunks (from diff -p) are now preserved in reject files.
+
Changes in version 2.7.1:
* Two critical bug fixes in the "diff --git" format support.
diff --git a/src/patch.c b/src/patch.c
index 010c14a..2f46243 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -1237,6 +1237,7 @@ abort_hunk_unified (bool header, bool reverse)
lin old = 1;
lin lastline = pch_ptrn_lines ();
lin new = lastline + 1;
+ char const *c_function = pch_c_function();
if (header)
{
@@ -1251,7 +1252,7 @@ abort_hunk_unified (bool header, bool reverse)
print_unidiff_range (rejfp, pch_first () + out_offset, lastline);
fprintf (rejfp, " +");
print_unidiff_range (rejfp, pch_newfirst () + out_offset, pch_repl_lines ());
- fprintf (rejfp, " @@\n");
+ fprintf (rejfp, " @@%s\n", c_function ? c_function : "");
while (pch_char (new) == '=' || pch_char (new) == '\n')
new++;
diff --git a/tests/reject-format b/tests/reject-format
index be710f5..0b02af6 100644
--- a/tests/reject-format
+++ b/tests/reject-format
@@ -79,7 +79,7 @@ check 'cat f.rej' <<EOF
Index: f
--- f.orig
+++ f
-@@ -2,6 +2,6 @@
+@@ -2,6 +2,6 @@ a() {
2
3
$preserve_trailing_blank
@@ -102,7 +102,7 @@ EOF
check 'cat f.rej' <<EOF
--- f.orig
+++ f
-@@ -2,6 +2,6 @@
+@@ -2,6 +2,6 @@ a() {
2
3
$preserve_trailing_blank