patchutils
patchutils copied to clipboard
interdiff does not reverse a patch correctly
According to man interdiff:
To reverse a patch, use /dev/null for diff2.
(that is, interdiff file.patch /dev/null is supposed to reverse the patch in file.patch)
That's bullshit. The output is not (or not always) a valid reversed patch.
I attach a patch file 550.patch which is the diff from file1.php to file2.php. I have tried:
interdiff file.patch /dev/null > 550reversed.patch
and then to apply the output supposed-to-be reversed patch to file2.php. Some parts were rejected.
550.patch.txt 550reversed.patch.txt

EDIT: adds interdiff’s version.
Hello @teo1978, did you try to use the option --quiet? It avoids to add lines reverted: inside the output, which might breaks some tools.
But anyway, I have too an issue with interdiff, it doesn't output correct reversed patchs, and I have a fairly simple example.
The current version:
interdiff - patchutils version 0.3.4
You can grab this patch as an example (click on the "plain" link for downloading the raw content)
https://gitweb.gentoo.org/repo/gentoo.git/tree/mate-base/mate-applets/files/mate-applets-1.22.0-cpupower.patch?id=ea97b37dd8393df4c055f829e49eeeb07cbdad77 (it should take the content of commit 9c1a80e937589a82215b8fe182d0d72b74b0e450)
And here the original files for the configure.ac and cpufreq/src/cpufreq-monitor-libcpufreq.c files from the 1.22.0 version:
https://github.com/mate-desktop/mate-applets/blob/v1.22.0/configure.ac
https://github.com/mate-desktop/mate-applets/blob/v1.22.0/cpufreq/src/cpufreq-monitor-libcpufreq.c
When I apply the vanilla patch, it works as intended, and I can recreate this patch simply with the diff command.
However, when I call interdiff with the following request, I don't have a correct reverse patch relevant to the vanilla patch:
% interdiff --quiet mate-applets-1.22.0-cpupower.patch /dev/null
--- b/configure.ac
+++ a/configure.ac
@@ -370,8 +370,6 @@
AM_CONDITIONAL(HAVE_LIBCPUFREQ, test x$have_libcpufreq = xyes)
AC_SUBST(LIBCPUFREQ_LIBS)
-AC_CHECK_HEADERS([cpupower.h])
-
build_cpufreq_applet=no
if test x$disable_cpufreq = xno; then
--- b/cpufreq/src/cpufreq-monitor-libcpufreq.c
+++ a/cpufreq/src/cpufreq-monitor-libcpufreq.c
@@ -19,16 +19,12 @@
* Authors : Carlos Garc�a Campos <[email protected]>
*/
-#include <config.h>
-
#include <glib.h>
#include <glib/gi18n.h>
#include <stdlib.h>
+#include <linux/version.h>
#include <cpufreq.h>
-#ifdef HAVE_CPUPOWER_H
-#include <cpupower.h>
-#endif
#include "cpufreq-monitor-libcpufreq.h"
#include "cpufreq-utils.h"
return CPUFREQ_MONITOR (monitor);
And of course, when I apply this reverse patch, it doesn’t correctly reverse to the original file:
% patch -p 1 < reverse_mate-applets-1.22.0-cpupower.patch
patching file configure.ac
patching file cpufreq/src/cpufreq-monitor-libcpufreq.c
Hunk #1 succeeded at 19 with fuzz 1.
% diff -u cpufreq/src/cpufreq-monitor-libcpufreq.c{.backup,}
--- cpufreq/src/cpufreq-monitor-libcpufreq.c.backup
+++ cpufreq/src/cpufreq-monitor-libcpufreq.c
@@ -98,7 +98,7 @@
return CPUFREQ_MONITOR (monitor);
}
-#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 7, 0)
+#ifndef HAVE_CPUPOWER_H
extern int cpupower_is_cpu_online (unsigned int cpu);
#endif
@@ -115,7 +115,7 @@
/* Check whether it failed because
* cpu is not online.
*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
+#ifndef HAVE_CPUPOWER_H
if (!cpufreq_cpu_exists (cpu)) {
#else
if (cpupower_is_cpu_online (cpu)) {
As you might noticed, the modifications from the 3rd and 4th hunks of text are missing in the "new" cpufreq/src/cpufreq-monitor-libcpufreq.c file, and the last line (return […]) should not be there in the interdiff output.
Best regards,
Sorry, I forgot to mention the current version:
interdiff - patchutils version 0.3.4
interdiff --quiet mate-applets-1.22.0-cpupower.patch /dev/null
interdiff without quiet ends prematurely with "interdiff: Whitespace damage detected in patch #1"