Bug 1905282

Summary: filterdiff not removing the header from excluded files in a git patch
Product: Red Hat Enterprise Linux 7 Reporter: Brian J. Murrell <brian.murrell>
Component: patchutilsAssignee: Than Ngo <than>
Status: CLOSED ERRATA QA Contact: Jakub Haruda <jharuda>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.9CC: jharuda, ovasik
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: patchutils-0.3.3-5.el7_9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-02 12:03:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Brian J. Murrell 2020-12-07 23:04:09 UTC
Description of problem:
If I have a patch produced from git such as:

diff --git a/selftests/functional/test_basic.py b/selftests/functional/test_basic.py
index 468b7d57..ed494733 100644
--- a/selftests/functional/test_basic.py
+++ b/selftests/functional/test_basic.py
@@ -184,6 +184,13 @@ class RunnerOperationTest(unittest.TestCase):
         self.assertIn('    data     ' + mapping['data_dir'], result.stdout)
         self.assertIn('    logs     ' + mapping['logs_dir'], result.stdout)
 
+    def test_runner_phases(self):
+        cmd_line = ('%s run --sysinfo=off --job-results-dir %s '
+                    'phases.py' % (AVOCADO, self.tmpdir))
+        result = process.run(cmd_line)
+        expected_rc = exit_codes.AVOCADO_ALL_OK
+        self.assertEqual(result.exit_status, expected_rc,
+                         "Avocado did not return rc %d:\n%s" % (expected_rc, result))
     def test_runner_all_ok(self):
         os.chdir(basedir)
         cmd_line = ('%s run --sysinfo=off --job-results-dir %s '

and run it through filterdiff -p1 -x selftests/\*, the header of the file being excluded from the patch is still included:

$ filterdiff -p1 -x selftests/\* < foo.patch
diff --git a/selftests/functional/test_basic.py b/selftests/functional/test_basic.py
index 468b7d57..ed494733 100644
Which causes patch to barf:

$ filterdiff -p1 -x selftests/\* < foo.patch | patch -p1 --dry-run
can't find file to patch at input line 2
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/selftests/functional/test_basic.py b/selftests/functional/test_basic.py
|index 468b7d57..ed494733 100644
--------------------------
File to patch: 

Version-Release number of selected component (if applicable):
patchutils-0.3.3-4.el7.x86_64.rpm

How reproducible:
100%

Steps to Reproduce:
1. See description.  It's quite detailed.

Actual results:
Patch fails on filterdiff output

Expected results:
Patch should not fail

Comment 2 Brian J. Murrell 2020-12-07 23:04:55 UTC
Per the Linked upstream ticket, this is fixed in a newer version of patchutils.

Comment 3 Than Ngo 2020-12-16 11:15:34 UTC
Hi, i backported the upstream fix and uploaded new build on
https://than.fedorapeople.org/rhel7/patchutils/

Could you please test and give me feedbacks?

Thanks

Comment 4 Brian J. Murrell 2020-12-16 13:38:48 UTC
Yeah, seems to work.

Thanks for the fix!

How long will this take to get into EL7?

Comment 16 errata-xmlrpc 2021-02-02 12:03:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (patchutils bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:0342