Understanding a patch file [OT?]
Leonidas Tsampros
ltsampros at upnet.gr
Fri Nov 11 20:53:06 GMT 2005
On Fri, Nov 11, 2005 at 01:16:15PM -0500, Steve Bertrand wrote:
> Hi everyone...
>
> This may be off-topic, but I know someone may be able to help. I am
> trying to better understand how to use diff, and moreso, understand it's
> output.
>
> In particular, I can't quite grasp exactly what the identifiers in
> between @@ and @@ represent exactly. Here is a patch file I created. The
> first change looks like it will replace lines 1 through 5, but then I
> look at the second change, and it completely confuses me (-11,6 +11,8).
> Can someone please clarify why 11 and 8?
>
I think this kind of diff output is called "unified". It displays
"hunks" of differences while each hunk shows one aera where the file
differs.
> --- randbak.pl Wed Oct 12 17:27:10 2005
> +++ randbak2.pl Fri Nov 11 13:06:51 2005
According to "info diff", the file displayed here is the file
modification time.
> @@ -1,5 +1,5 @@
> #!/usr/bin/perl
> -
> +#
> use warnings;
> use strict;
> use Storable;
This is the first hunk of changes between the files. The number -1,5
is the line range in the first file while +1,5 is the file range on
the second file . But 1,5 doesn't mean all lines between line 1 and
line 5. It means in line 1 , + 5 lines afterward. (consider 5 as the
length of the compared regions)
In this hunk you can see clearly that you removed a whiteline and you
add a comment line, so the total numbers of line in both files are
exactly the same. Thus you've got -1,5 +1,5. The length of the
compared region in boths files did not change.
If the second number is different, like in the following hunk, then
the data displayed are lines 11-16 on the first file (-11,6) and
because you added two lines (the ones starting with +) the file range
of the compared region in the second file is 11-18 (+11,8)
I hope this helps and i'm terribly sorry for my english. Alternatively
you can check `info diff' for more information on diff different kinds
of output.
> @@ -11,6 +11,8 @@
> my $num;
> my $sum = "sum";
> my $total = 0;
> +
> +# Test
>
> if (-e "randomcount"){
> $href = retrieve ("randomcount");
>
>
> Thank you for any advice!
> Steve
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions
mailing list