Skip to contentSkip to conversation

Diff impromements: keep block whole

DISCUSSION KES 2 participants 2 messages Sep 12, 2016

lore
Share & tools
lore

KES

author
#0 lore raw

Does it be more meaning full which change was done when diff will be displayed as:
@@ -1278,6 +1311,16 @@ sub process {
if( ref $result eq 'HASH' ) {
$code = $result->{ code };
@args = DB::eval( $result->{ expr } );

 			redo PROCESS;
		}

+ elsif( ref $result eq 'ARRAY' ) {
+ $code = shift @$result;
+ @args = ();
+ for my $expr ( @$result ) {
+ push @args, [ DB::eval( $expr ) ];
+ }
+
+ redo PROCESS;
+ }

instead of:

@@ -1278,6 +1311,16 @@ sub process {
if( ref $result eq 'HASH' ) {
$code = $result->{ code }; @args = DB::eval( $result->{ expr } );
+
+ redo PROCESS;
+ }
+ elsif( ref $result eq 'ARRAY' ) {
+ $code = shift @$result;
+ @args = ();
+ for my $expr ( @$result ) {
+ push @args, [ DB::eval( $expr ) ];
+ }
+
redo PROCESS;
}

#1 lore raw
Quoted 28 lines · KES

Does it be more meaning full which change was done when diff will be displayed as:

(quoted diff) +9 -0
@@ -1278,6 +1311,16 @@ sub process {
 		if( ref $result eq 'HASH' ) {
 			$code =  $result->{ code };
 			@args =  DB::eval( $result->{ expr } );
 
 			redo PROCESS;
 		}
+		elsif( ref $result eq 'ARRAY' ) {
+			$code =  shift @$result;
+			@args =  ();
+			for my $expr ( @$result ) {
+				push @args, [ DB::eval( $expr ) ];
+			}
+
+ 			redo PROCESS;
+ 		}

instead of:

(quoted diff) +3 -0
@@ -1278,6 +1311,16 @@ sub process {
 		if( ref $result eq 'HASH' ) {
 			$code =  $result->{ code };
 			@args =  DB::eval( $result->{ expr } );
+
+			redo PROCESS;
+		}

Review sub process { · line 1326

Quoted 10 lines
(quoted diff) +7 -0
+		elsif( ref $result eq 'ARRAY' ) {
+			$code =  shift @$result;
+			@args =  ();
+			for my $expr ( @$result ) {
+				push @args, [ DB::eval( $expr ) ];
+			}
+
 			redo PROCESS;
 		}
 

Yes, it would definately be more meaningfull, but for an algorithm it's not that clear cut. Michael Hagerty is currently working on a patch series[1] to give git some heuristics to get better diffs, but is hard to get right.

You can already enable this by adding --compaction-heuristic to the diff command, but this can also give odd results in other cases, so it's not enabled by default.

Kevin.

[1]:https://public-inbox.org/git/[email protected]/