Re: some question about the patches

Mitch Davis (mjd@tpg.tpg.oz.au)
Fri, 20 Sep 1996 19:24:32 +1000 (EST)


I know this is replying to an old article, but I've only just caught up.
While it's about a bug in patch, it's relevant because it prevents the
rolling back of kernel versions.

> > kernel. now the question. if i decide to go to kernel 2.0.10 lets say but
> > not downloading it completely but going through patches what is the
> > correct way to do it?
> > b) install patch 2.0.5 , then 2.0.6 then 2.0.7 and so on untill i get to
> > 2.0.10?
>
> The correct answer is option b). :-) The patches are incremental
> and differential between versions not cumulative, so you have to get all
> the patches between two versions to switch up (or down, if you apply the
> patches in reverse-mode) to a different kernel.

Have you tried downward patches? There's a bug in the most recent patch
(still 2.1 after many years, AFAIK) which will often prevent you from doing
this.

Let's say your patch (which applied forwards) takes a file with "n" lines,
and reduces it to none. This arises if a file gets moved.

The bug in patch strikes when you try to reverse-apply this patch. Even
though the file it has to work with doesn't need to exist to do its job,
patch complains.

I wrote to the GNU people 2 years ago about this a couple of times, but
never got any response.

When I found this out, the patch I had trouble reversing was for linux 1.1.77.

If anyone can suggest a patch to patch (!), I'd be most grateful.

Mitch.

Here's how to reproduce it:

# touch hello.c
# cp hello.c hello.c~
# cat > hello.c
#include <stdio.h>

int main()
{
printf("Hello, world!\n");

return 0;
}
# diff -u hello.c~ hello.c > hello-a-b.diff
# cat hello-a-b.diff
--- hello.c~ Fri Sep 20 17:19:14 1996
+++ hello.c Fri Sep 20 17:19:29 1996
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main()
+{
+ printf("Hello, world!\n");
+
+ return 0;
+}
# mv hello.c hello.c~
# touch hello.c
# diff -u hello.c~ hello.c > hello-b-c.diff
# cat hello-b-c.diff
--- hello.c~ Fri Sep 20 17:19:29 1996
+++ hello.c Fri Sep 20 17:23:27 1996
@@ -1,8 +0,0 @@
-#include <stdio.h>
-
-int main()
-{
- printf("Hello, world!\n");
-
- return 0;
-}
# rm hello.c
# patch < hello-a-b.diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- hello.c~ Fri Sep 20 17:19:14 1996
|+++ hello.c Fri Sep 20 17:19:29 1996
--------------------------
(Creating file hello.c...)
Patching file hello.c using Plan A...
Hunk #1 succeeded at 1.
done
# patch -R < hello-a-b.diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- hello.c~ Fri Sep 20 17:19:14 1996
|+++ hello.c Fri Sep 20 17:19:29 1996
--------------------------
Patching file hello.c using Plan A...
Hunk #1 succeeded at 1.
done
# patch < hello-a-b.diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- hello.c~ Fri Sep 20 17:19:14 1996
|+++ hello.c Fri Sep 20 17:19:29 1996
--------------------------
Patching file hello.c using Plan A...
Hunk #1 succeeded at 1.
done
# patch < hello-b-c.diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- hello.c~ Fri Sep 20 17:19:29 1996
|+++ hello.c Fri Sep 20 17:23:27 1996
--------------------------
Patching file hello.c using Plan A...
Hunk #1 succeeded at 0.
done
# patch -R < hello-b-c.diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- hello.c~ Fri Sep 20 17:19:29 1996
|+++ hello.c Fri Sep 20 17:23:27 1996
--------------------------
Patching file hello.c using Plan A...
Hunk #1 failed at 1.
1 out of 1 hunks failed--saving rejects to hello.c.rej
done
# patch -E -R < hello-b-c.diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- hello.c~ Fri Sep 20 17:19:29 1996
|+++ hello.c Fri Sep 20 17:23:27 1996
--------------------------
Patching file hello.c using Plan A...
Hunk #1 failed at 1.
Removing hello.c (empty after patching).
1 out of 1 hunks failed--saving rejects to hello.c.rej
done
#