[Dev] Questions about patch?

Jon Carnes dev@trilug.org
01 May 2003 16:08:14 -0400


I don't know if this will help, but whenever I create patch files from
diffs I always grab a few reference lines around the changes.  Patch
seems to work much better then.  In fact if you read the "man diff" you
will see that it says:

     -lines Show  lines (an integer) lines of context.  This
            option does not specify an output format by itself;
            it has no effect  unless  it is combined with -c
            or -u.  This option is obsolete.  For proper
            operation, patch typically needs at least two lines
            of context.

Jon Carnes


On Thu, 2003-05-01 at 15:39, Xinghua Shi wrote:
> Hey,James
> 
>   I saw your posts about how to create a patch using cvs and then do
> patch. This is what I wanna do in my project(On Solaris), but I got some
> problem here and couldn't figure out how to deal with this.
>   Thanks for any hints. :-)
> 
> What I did is like:
> 1.create the patch using cvs
>   cvs diff -c orbit.c > original_diff
> 
> 2.original_diff looks like:
> 
> Index: orbit.c
> ===================================================================
> RCS file: /u1/shi/cvs/Orbit/orbit.c,v
> retrieving revision 1.7
> diff -c -r1.7 orbit.c
> *** orbit.c	28 Apr 2003 18:37:30 -0000	1.7
> --- orbit.c	30 Apr 2003 18:02:16 -0000
> ***************
> *** 1,5 ****
> 
> ! char cvsroot_orbit_c[] = "$Header: /u1/shi/cvs/Orbit/orbit.c,v 1.7
> 2003/04/28 18:37:30 shi Exp $";
> 
>   #include <stdio.h>
>   #include <stdlib.h>     /* for exit() prototype */
> --- 1,5 ----
> 
> ! char cvsroot_orbit_c[] = "$Header: /u1/shi/cvs/Orbit/orbit2.c,v 1.4
> 2003/04/22 18:44:30 shi Exp $";
> 
>   #include <stdio.h>
>   #include <stdlib.h>     /* for exit() prototype */
> ***************
> *** 194,199 ****
> --- 194,202 ----
>     /*
>       this is still a test.
>      */
> +
> +   printf("Blah,blah,this is my test!\n");
> +
> 
>     fp = fopen("sim.out","w");
>     printf("Running. Result in 'sim.out'\n");
> 
> 
> 3. do the patch
>    patch -c -i original_diff orbit.c
> 
> But it complains:
> 
> Looks like a new-style context diff.
> done
> 
> But nothing was done with the file orbit.c. Not any patching happened.
> 
> Actually, I don't know where to ask this question. So any suggestions are
> heartly appreciated. :-)
> 
> Good day!
> 
> 
> BR
> -Mindy
> 
> _______________________________________________
> Dev mailing list
> Dev@trilug.org
> http://www.trilug.org/mailman/listinfo/dev