Unix Programming - patch rejects?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > patch rejects?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author patch rejects?
Pascal Bourguignon

2004-01-23, 5:19 pm


Why does patch reject this patch?


% diff -NaurtbB --exclude 'zmg-dom.lisp*' zebu-3.5.5-original/COMPILE-ZEBU.lisp zebu-3.5.5/COMPILE-ZEBU.lisp
--- zebu-3.5.5-original/COMPILE-ZEBU.lisp 1997-10-03 00:57:58.000000000 +0200
+++ zebu-3.5.5/COMPILE-ZEBU.lisp 2003-11-13 03:45:35.000000000 +0100
@@ -174,6 +174,7 @@
(when (or (null odate) (> idate odate))
;; now do the postponed loads
(do-post-poned-load)
+ (ensure-directories-exist ofile)
(compile-file ifile :output-file ofile))))
(load ; postpone load
(push file-path load-before-compile))


while at the same time, it can patch three other files in the same batch:

% patch -p0 < zebu-clisp.patch
patching file zebu-3.5.5/COMPILE-ZEBU.lisp
Hunk #1 FAILED at 174.
1 out of 1 hunk FAILED -- saving rejects to file zebu-3.5.5/COMPILE-ZEBU.lisp.rej
patching file zebu-3.5.5/ZEBU-init.lisp
Hunk #1 succeeded at 38 with fuzz 2.
patching file zebu-3.5.5/zebu-aux.lisp
patching file zebu-3.5.5/zebu-package.lisp


--
__Pascal_Bourguignon__
http://www.informatimago.com/
Juha Laiho

2004-01-23, 5:20 pm

Pascal Bourguignon <spam@thalassa.informatimago.com> said:
quote:

>Why does patch reject this patch?



Because the old file doesn't in that rejected chunk match what patch
expected to be there.
quote:

>% diff -NaurtbB --exclude 'zmg-dom.lisp*'
>zebu-3.5.5-original/COMPILE-ZEBU.lisp zebu-3.5.5/COMPILE-ZEBU.lisp
>--- zebu-3.5.5-original/COMPILE-ZEBU.lisp 1997-10-03 00:57:58.000000000 +0200
>+++ zebu-3.5.5/COMPILE-ZEBU.lisp 2003-11-13 03:45:35.000000000 +0100
>@@ -174,6 +174,7 @@
> (when (or (null odate) (> idate odate))
> ;; now do the postponed loads
> (do-post-poned-load)
>+ (ensure-directories-exist ofile)
> (compile-file ifile :output-file ofile))))
> (load ; postpone load
> (push file-path load-before-compile))



.... so, look at the six lines starting at line 174 in COMPILE-ZEBU.lisp.
They should match the piece above - except that the original file
should not contain the fourth line of above listing (the one that starts
with a + -sign).

Note that the difference can also be a very small one - even different
amounts of whitespace (or different whitespace - space against TAB) can
cause the patch to fail.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
Pascal Bourguignon

2004-01-23, 5:20 pm


Juha Laiho <Juha.Laiho@iki.fi> writes:
quote:

> Pascal Bourguignon <spam@thalassa.informatimago.com> said:
>
> Because the old file doesn't in that rejected chunk match what patch
> expected to be there.
>
>
> ... so, look at the six lines starting at line 174 in COMPILE-ZEBU.lisp.
> They should match the piece above - except that the original file
> should not contain the fourth line of above listing (the one that starts
> with a + -sign).
>
> Note that the difference can also be a very small one - even different
> amounts of whitespace (or different whitespace - space against TAB) can
> cause the patch to fail.



Well, I would have tried very hard to avoid asking the question if
such was the case, but it's not:

$ diff {zebu-3.5.5-original,zebu-3.5.5}/COMPILE-ZEBU.lisp
176a177
quote:

> (ensure-directories-exist ofile)


$ patch --version
patch 2.5.4
Copyright 1984-1988 Larry Wall
Copyright 1989-1999 Free Software Foundation, Inc.

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

written by Larry Wall and Paul Eggert
$


It's rather easy to insert just one line either with vi or emacs
without damaging surrounding lines...


So, is this a bug in patch?


--
__Pascal_Bourguignon__
http://www.informatimago.com/
Bjorn Reese

2004-01-23, 5:20 pm

On Fri, 14 Nov 2003 14:28:33 +0100, Pascal Bourguignon wrote:
quote:

> So, is this a bug in patch?



Does the problem persist if you use contextual, rather than
unified diff?

--
mail1dotstofanetdotdk

Pascal Bourguignon

2004-01-23, 5:20 pm

"Bjorn Reese" <breese@see.signature> writes:
quote:

> On Fri, 14 Nov 2003 14:28:33 +0100, Pascal Bourguignon wrote:
>
>
> Does the problem persist if you use contextual, rather than
> unified diff?



Yes, same problem:


[pascal@thalassa hp]$ diff -NacrtbB {zebu-3.5.5-original,zebu-3.5.5}/COMPILE-ZEBU.lisp>p
[pascal@thalassa hp]$ cp zebu-3.5.5-original/COMPILE-ZEBU.lisp .
[pascal@thalassa hp]$ patch -p1<p
patching file COMPILE-ZEBU.lisp
Hunk #1 FAILED at 174.
1 out of 1 hunk FAILED -- saving rejects to file COMPILE-ZEBU.lisp.rej
[pascal@thalassa hp]$ cat p
*** zebu-3.5.5-original/COMPILE-ZEBU.lisp 1997-10-03 00:57:58.000000000 +0200
--- zebu-3.5.5/COMPILE-ZEBU.lisp 2003-11-13 04:21:02.000000000 +0100
***************
*** 174,179 ****
--- 174,180 ----
(when (or (null odate) (> idate odate))
;; now do the postponed loads
(do-post-poned-load)
+ (ensure-directories-exist ofile)
(compile-file ifile :output-file ofile))))
(load ; postpone load
(push file-path load-before-compile))
[pascal@thalassa hp]$ cat COMPILE-ZEBU.lisp.rej
***************
*** 174,179 ****
(when (or (null odate) (> idate odate))
;; now do the postponed loads
(do-post-poned-load)
(compile-file ifile :output-file ofile))))
(load ; postpone load
(push file-path load-before-compile))
--- 174,180 ----
(when (or (null odate) (> idate odate))
;; now do the postponed loads
(do-post-poned-load)
+ (ensure-directories-exist ofile)
(compile-file ifile :output-file ofile))))
(load ; postpone load
(push file-path load-before-compile))

--
__Pascal_Bourguignon__
http://www.informatimago.com/
Stephane CHAZELAS

2004-01-23, 5:21 pm

2003/11/13, 03:58(+01), Pascal Bourguignon:
quote:

> Why does patch reject this patch?



Did you try it in a C or POSIX locale? Are there any '\0' or
other weird chars in the input files?

--
Stéphane ["Stephane.Chazelas" at "free.fr"]
Stephane CHAZELAS

2004-01-23, 5:21 pm

2003/11/13, 03:58(+01), Pascal Bourguignon:
[...]
quote:

> --- zebu-3.5.5-original/COMPILE-ZEBU.lisp 1997-10-03 00:57:58.000000000 +0200
> +++ zebu-3.5.5/COMPILE-ZEBU.lisp 2003-11-13 03:45:35.000000000 +0100


[...]
quote:

> % patch -p0 < zebu-clisp.patch
> patching file zebu-3.5.5/COMPILE-ZEBU.lisp


[...]

You're patching the wrong file!

zebu-3.5.5-original/COMPILE-ZEBU.lisp needs to be patched, not
zebu-3.5.5/COMPILE-ZEBU.lisp.

--
Stéphane ["Stephane.Chazelas" at "free.fr"]
Pascal Bourguignon

2004-01-23, 5:21 pm

Stephane CHAZELAS <this.address@is.invalid> writes:
quote:

> 2003/11/13, 03:58(+01), Pascal Bourguignon:
> [...]
> [...]
> [...]
>
> You're patching the wrong file!
>
> zebu-3.5.5-original/COMPILE-ZEBU.lisp needs to be patched, not
> zebu-3.5.5/COMPILE-ZEBU.lisp.



Not exactly.

The actual procedure is:

;;...
(EXT:SHELL (CONCATENATE 'STRING
"cd /usr/local/share/lisp/packages/com/hp ;"
"rm -rf zebu-3.5.5 zebu ;"
"tar zxf /data/mirrors/cmu-ai-repository/new/zebu-3.5.5.tgz ;"
"patch -p0 < zebu-clisp.patch ;"
"ln -s zebu-3.5.5 zebu ;"
"ln -s COMPILE-ZEBU.lisp zebu/compile-zebu.lisp ;"
"ln -s ZEBU-init.lisp zebu/zebu-init.lisp ;"
))
;;...

So I'm patching the right files.
I just cut too much from xterm to gnus...



--
__Pascal_Bourguignon__
http://www.informatimago.com/
Pascal Bourguignon

2004-01-23, 5:21 pm

Stephane CHAZELAS <this.address@is.invalid> writes:
quote:

> 2003/11/13, 03:58(+01), Pascal Bourguignon:
>
> Did you try it in a C or POSIX locale? Are there any '\0' or
> other weird chars in the input files?




No ASCII NUL and no strange character (emacs says it's a plain ASCII
file). I have the following locale, but even when removing it, I
still have the problem. I guess I'll have to run patch in gdb...

[pascal@thalassa hp]$ od -t x1 zebu-3.5.5-original/COMPILE-ZEBU.lisp | cut -c 8-80|grep 00
[pascal@thalassa hp]$ env | grep LC
LC_MONETARY=es_ES
LC_NUMERIC=en_US
LC_MESSAGES=en_US
LC_COLLATE=C
LC_CTYPE=fr_FR
LC_TIME=en_US
[pascal@thalassa hp]$ env|grep LC|awk -F= '{printf "unset %s\n",$1}'>u
[pascal@thalassa hp]$ cat u
unset LC_MONETARY
unset LC_NUMERIC
unset LC_MESSAGES
unset LC_COLLATE
unset LC_CTYPE
unset LC_TIME
[pascal@thalassa hp]$ . u
[pascal@thalassa hp]$ mv zebu-3.5.5/COMPILE-ZEBU.lisp zebu-3.5.5/COMPILE-ZEBU.lisp.good
[pascal@thalassa hp]$ cp zebu-3.5.5-original/COMPILE-ZEBU.lisp zebu-3.5.5/
[pascal@thalassa hp]$ patch -p0<p
patching file zebu-3.5.5/COMPILE-ZEBU.lisp
Hunk #1 FAILED at 41.
Hunk #2 FAILED at 174.
2 out of 2 hunks FAILED -- saving rejects to file zebu-3.5.5/COMPILE-ZEBU.lisp.rej

--
__Pascal_Bourguignon__
http://www.informatimago.com/
Stephane CHAZELAS

2004-01-23, 5:21 pm

2003/11/13, 03:58(+01), Pascal Bourguignon:
quote:

>
> Why does patch reject this patch?
>
> % diff -NaurtbB --exclude 'zmg-dom.lisp*' zebu-3.5.5-original/COMPILE-ZEBU.lisp zebu-3.5.5/COMPILE-ZEBU.lisp


[...]
quote:

> % patch -p0 < zebu-clisp.patch


[...]

You need the "-l" flag to patch if you use the "-b" flag to diff.

--
Stéphane ["Stephane.Chazelas" at "free.fr"]
Pascal Bourguignon

2004-01-23, 5:21 pm


Stephane CHAZELAS <this.address@is.invalid> writes:
quote:

> 2003/11/13, 03:58(+01), Pascal Bourguignon:
> [...]
> [...]
>
> You need the "-l" flag to patch if you use the "-b" flag to diff.



Indeed! Thank you very much!

--
__Pascal_Bourguignon__
http://www.informatimago.com/
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com