[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-patch] Skip hunks already applied [was: "zero exit status when all
From: |
Tom Hale |
Subject: |
[bug-patch] Skip hunks already applied [was: "zero exit status when all hunks are applied"] |
Date: |
Fri, 26 Aug 2016 11:17:53 +0700 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
Bruno wrote to me and asked a very good question:
On 2016-08-26 00:53, Bruno Haible wrote:
I'm of making a pull request that allows patch to exit(0) when all
rejected hunks are already applied.
This will allow idempotent patching, ie, patch to return 0 when a patch
has already been applied.
How does your proposal differ from the -N / --forward option?
I hoped that -N would do the trick for me too, but there is a limitation
of -N:
The current (git repository) manual says:
"When a patch does not apply, patch usually checks if the patch looks
like it has been reversed. The --forward option prevents that."
Version 2.7.1 said (in worse English but giving far more insight the
code's behaviour):
"Ignore patches that seem to be reversed or already applied. It is only
checked if the first hunk of a patch can be reversed. ..."
In the case of a some previously applied hunks, the current git code
with "-N" will create a ".rej" file and exit(1).
Perhaps better than `-z' would be:
-s Skip hunks already applied
Would the maintainers accept a pull request for this?
There's no way I'm aware of to have patch skip hunks which have already
been applied. Here's a demonstration of the current limitation:
address@hidden:~/tmp/patch-test$ cat numbers
1
2
3
4
5
6
7
address@hidden:~/tmp/patch-test$ cat num-1-7
one
2
3
4
5
6
seven
address@hidden:~/tmp/patch-test$ cat num-1-4-7
one
2
3
four
5
6
seven
address@hidden:~/tmp/patch-test$ diff -u2 numbers num-1-7 > 1-7
address@hidden:~/tmp/patch-test[1]$ diff -u2 numbers num-1-4-7 > 1-4-7
address@hidden:~/tmp/patch-test[1]$ cat 1-7
--- numbers 2016-08-26 10:36:17.848926420 +0700
+++ num-1-7 2016-08-26 10:15:21.167754859 +0700
@@ -1,3 +1,3 @@
-1
+one
2
3
@@ -5,3 +5,3 @@
5
6
-7
+seven
address@hidden:~/tmp/patch-test$ cat 1-4-7
--- numbers 2016-08-26 10:36:17.848926420 +0700
+++ num-1-4-7 2016-08-26 10:15:11.175572637 +0700
@@ -1,7 +1,7 @@
-1
+one
2
3
-4
+four
5
6
-7
+seven
address@hidden:~/tmp/patch-test$ patch numbers -i 1-7
patching file numbers
address@hidden:~/tmp/patch-test$ patch numbers -Ni 1-4-7
patching file numbers
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file numbers.rej
address@hidden:~/tmp/patch-test[1]$ cat numbers.rej
--- numbers 2016-08-26 10:36:17.848926420 +0700
+++ num-1-4-7 2016-08-26 10:15:11.175572637 +0700
@@ -1,7 +1,7 @@
-1
+one
2
3
-4
+four
5
6
-7
+seven
address@hidden:~/tmp/patch-test$
--
Tom Hale