When to use visual differences against unified diff patch files?

NOTE . This question was originally asked in the pre-GitHub era.


I took a code that had not been developed since 2002, and I looked at the fixes directed against it over time. All of these patches were in unified diff format , which seems to be the de facto standard for providing code improvements. Here's what one patch looked like:

@@ -365,7 +385,10 @@
     return () unless defined $op_sym;

     $a_or_b = $op->[OPCODE] ne "+" ? 0 : 1 unless defined $a_or_b;
-    return ( $op_sym, $seqs->[$a_or_b][$op->[$a_or_b]] );
+    my $line = $seqs->[$a_or_b][$op->[$a_or_b]];
+    my @ret = ( $op_sym, $line );
+    return @ret;
}

How exactly should I figure out what this change is doing in context? The patch does not tell me which subroutine it affects. I have to open the source file, go to line 365 and mentally replace the existing lines there that correspond to the lines “-” in the patch file with the “+” lines in the patch file. WTF?

, file file.orig, patch file, file.orig file, , .

: , ?

, , , ? , , ? , , , ?

, , , . , , .

, , ( GitHub Google Code). , " " . ? ? .

+3
4

, , , , , .

, . , 7 , , , , diff , . , , , ..

, , , .

+1

, . , . - , . , , . , patch , .

, , , , , . ?

, , , , , ", " . diff, , .

+7

, , - . , , , , , - , () . . , .

( ), , .

+1

, , . .

file.orig, , diff file.orig file to , .

, , , , .

0

Source: https://habr.com/ru/post/1707668/


All Articles