@matheusbsbs / matheus-bagliano / commits / 6bcf4b46c9
Fork 0

gitweb: Use @diff_opts, default ('M'), as git-diff and git-diff-tree paramete

Added new global configuration variable @diff_opts, which holds additional options (parameters) to git-diff and git-diff-tree, usually dealing rename/copying detection. Default value is '-M', taken from git_commit subroutine. Description of options and their approximate cost by Junio C Hamano. Changes: * git_commitdiff, git_blobdiff and git_blobdiff_plain now use '-M' instead of '-M', '-C' * git-diff now uses the same options as git-diff-tree * git_comittdiff_plain now uses '-M' instead of '-B' and is now rename-aware * git_rss uses now '-M' instead of () Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Aug 27, 2006 at 23:49 UTC 6bcf4b46c9a4ba7a6e5c78201c619fa41ac76a99
1 file changed +24 -9
gitweb/gitweb.perl
+24 -9
@@ -141,6 +141,16 @@ sub feature_snapshot {
141 return ($ctype, $suffix, $command);
142 }
143
144 +# rename detection options for git-diff and git-diff-tree
145 +# - default is '-M', with the cost proportional to
146 +# (number of removed files) * (number of new files).
147 +# - more costly is '-C' (or '-C', '-M'), with the cost proportional to
148 +# (number of changed files + number of removed files) * (number of new files)
149 +# - even more costly is '-C', '--find-copies-harder' with cost
150 +# (number of files in the original tree) * (number of new files)
151 +# - one might want to include '-B' option, e.g. '-B', '-M'
152 +our @diff_opts = ('-M'); # taken from git_commit
153 +
154 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
155 require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
156
@@ -2593,7 +2603,7 @@ sub git_commit {
2603 if (!defined $parent) {
2604 $parent = "--root";
2605 }
2596 - open my $fd, "-|", $GIT, "diff-tree", '-r', '-M', $parent, $hash
2606 + open my $fd, "-|", $GIT, "diff-tree", '-r', @diff_opts, $parent, $hash
2607 or die_error(undef, "Open git-diff-tree failed");
2608 my @difftree = map { chomp; $_ } <$fd>;
2609 close $fd or die_error(undef, "Reading git-diff-tree failed");
@@ -2700,7 +2710,7 @@ sub git_blobdiff {
2710 if (defined $hash_base && defined $hash_parent_base) {
2711 if (defined $file_name) {
2712 # read raw output
2703 - open $fd, "-|", $GIT, "diff-tree", '-r', '-M', '-C', $hash_parent_base, $hash_base,
2713 + open $fd, "-|", $GIT, "diff-tree", '-r', @diff_opts, $hash_parent_base, $hash_base,
2714 "--", $file_name
2715 or die_error(undef, "Open git-diff-tree failed");
2716 @difftree = map { chomp; $_ } <$fd>;
@@ -2718,7 +2728,7 @@ sub git_blobdiff {
2728 # try to find filename from $hash
2729
2730 # read filtered raw output
2721 - open $fd, "-|", $GIT, "diff-tree", '-r', '-M', '-C', $hash_parent_base, $hash_base
2731 + open $fd, "-|", $GIT, "diff-tree", '-r', @diff_opts, $hash_parent_base, $hash_base
2732 or die_error(undef, "Open git-diff-tree failed");
2733 @difftree =
2734 # ':100644 100644 03b21826... 3b93d5e7... M ls-files.c'
@@ -2752,7 +2762,8 @@ sub git_blobdiff {
2762 }
2763
2764 # open patch output
2755 - open $fd, "-|", $GIT, "diff-tree", '-r', '-p', '-M', '-C', $hash_parent_base, $hash_base,
2765 + open $fd, "-|", $GIT, "diff-tree", '-r', @diff_opts,
2766 + '-p', $hash_parent_base, $hash_base,
2767 "--", $file_name
2768 or die_error(undef, "Open git-diff-tree failed");
2769 }
@@ -2787,7 +2798,7 @@ sub git_blobdiff {
2798 }
2799
2800 # open patch output
2790 - open $fd, "-|", $GIT, "diff", '-p', $hash_parent, $hash
2801 + open $fd, "-|", $GIT, "diff", '-p', @diff_opts, $hash_parent, $hash
2802 or die_error(undef, "Open git-diff failed");
2803 } else {
2804 die_error('404 Not Found', "Missing one of the blob diff parameters")
@@ -2872,7 +2883,7 @@ sub git_commitdiff {
2883 my $fd;
2884 my @difftree;
2885 if ($format eq 'html') {
2875 - open $fd, "-|", $GIT, "diff-tree", '-r', '-M', '-C',
2886 + open $fd, "-|", $GIT, "diff-tree", '-r', @diff_opts,
2887 "--patch-with-raw", "--full-index", $hash_parent, $hash
2888 or die_error(undef, "Open git-diff-tree failed");
2889
@@ -2883,7 +2894,8 @@ sub git_commitdiff {
2894 }
2895
2896 } elsif ($format eq 'plain') {
2886 - open $fd, "-|", $GIT, "diff-tree", '-r', '-p', '-B', $hash_parent, $hash
2897 + open $fd, "-|", $GIT, "diff-tree", '-r', @diff_opts,
2898 + '-p', $hash_parent, $hash
2899 or die_error(undef, "Open git-diff-tree failed");
2900
2901 } else {
@@ -3192,9 +3204,12 @@ XML
3204 last;
3205 }
3206 my %cd = parse_date($co{'committer_epoch'});
3195 - open $fd, "-|", $GIT, "diff-tree", '-r', $co{'parent'}, $co{'id'} or next;
3207 + open $fd, "-|", $GIT, "diff-tree", '-r', @diff_opts,
3208 + $co{'parent'}, $co{'id'}
3209 + or next;
3210 my @difftree = map { chomp; $_ } <$fd>;
3197 - close $fd or next;
3211 + close $fd
3212 + or next;
3213 print "<item>\n" .
3214 "<title>" .
3215 sprintf("%d %s %02d:%02d", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . " - " . esc_html($co{'title'}) .