forked from pool/patch
88d552055b
test in another_hunk(). - reject-print-function-02-handle-unified-format.patch: Preserve C function name in unified rejects (bnc#904519). OBS-URL: https://build.opensuse.org/package/show/devel:tools/patch?expand=0&rev=41
82 lines
2.0 KiB
Diff
82 lines
2.0 KiB
Diff
From: Jean Delvare <jdelvare@suse.de>
|
|
Subject: Preserve C function name in unified rejects
|
|
Upstream: Submitted (2014-11-10)
|
|
References: bnc#904519
|
|
|
|
We already support that in context rejects, just do the same for
|
|
unified rejects.
|
|
---
|
|
src/patch.c | 3 ++-
|
|
tests/preserve-c-function-names | 16 ++++++++++++++++
|
|
tests/reject-format | 4 ++--
|
|
3 files changed, 20 insertions(+), 3 deletions(-)
|
|
|
|
--- a/src/patch.c
|
|
+++ b/src/patch.c
|
|
@@ -1237,6 +1237,7 @@ abort_hunk_unified (bool header, bool re
|
|
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 re
|
|
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++;
|
|
--- a/tests/preserve-c-function-names
|
|
+++ b/tests/preserve-c-function-names
|
|
@@ -34,6 +34,7 @@ EOF
|
|
preserve_trailing_blank=
|
|
|
|
diff -p -c -L a -L b a b > ab.diff
|
|
+diff -p -u -L a -L b a b > ab-unified.diff
|
|
touch c
|
|
check 'patch c < ab.diff || cat c.rej' <<EOF
|
|
patching file c
|
|
@@ -55,3 +56,18 @@ Hunk #1 FAILED at 2.
|
|
! return 2;
|
|
}
|
|
EOF
|
|
+rm -f c.rej
|
|
+check 'patch c < ab-unified.diff || cat c.rej' <<EOF
|
|
+patching file c
|
|
+Hunk #1 FAILED at 2.
|
|
+1 out of 1 hunk FAILED -- saving rejects to file c.rej
|
|
+--- a
|
|
++++ b
|
|
+@@ -2,5 +2,5 @@ int foo()
|
|
+ {
|
|
+ /* waste a line */
|
|
+ $preserve_trailing_blank
|
|
+- return 1;
|
|
++ return 2;
|
|
+ }
|
|
+EOF
|
|
--- 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
|