twaugh / patchutils

Manipulate patch files
GNU General Public License v2.0
139 stars 22 forks source link

filterdiff not removing the header from excluded files in a git patch #46

Closed brianjmurrell closed 3 years ago

brianjmurrell commented 3 years ago

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: 
brianjmurrell commented 3 years ago

Interestingly, this doesn't seem to happen if my patch has two files that it patches and I exclude the first file in my filterdiff command.

sergiomb2 commented 3 years ago

filterdiff -p1 -x selftests/* < foo.patch returned one empty line

version of filterdiif

filterdiff --version
filterdiff - patchutils version 0.4.2
brianjmurrell commented 3 years ago

Hrm.

$ filterdiff --version
filterdiff - patchutils version 0.3.3

I'll go bug RHEL to update, fix the bug at least. Sorry for the noise.