{"thread":{"id":"5412","subject":"[PATCH] gitweb: Use @diff_opts, default ('M'), as git-diff and git-diff-tree paramete","startedAt":"2006-08-27T21:49:36Z","lastAt":"2006-08-27T21:49:36Z","messageCount":1,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"26005","messageId":"200608272349.36887.jnareb@gmail.com","threadId":"5412","inReplyTo":null,"subject":"[PATCH] gitweb: Use @diff_opts, default ('M'), as git-diff and git-diff-tree paramete","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-27T21:49:36Z","receivedAt":"2006-08-27T21:49:36Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Added new global configuration variable @diff_opts, which holds\nadditional options (parameters) to git-diff and git-diff-tree, usually\ndealing rename/copying detection.  Default value is '-M', taken from\ngit_commit subroutine.  Description of options and their approximate\ncost by Junio C Hamano.\n\nChanges:\n* git_commitdiff, git_blobdiff and git_blobdiff_plain now use '-M'\n  instead of '-M', '-C'\n* git-diff now uses the same options as git-diff-tree\n* git_comittdiff_plain now uses '-M' instead of '-B' \n  and is now rename-aware\n* git_rss uses now '-M' instead of ()\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\nAs requested, gitweb now uses '-M' without '-C' as option \nto git-diff-tree thorough the script.\n\nI'm not that sure about last chunk, changing git_rss. I didn't review\nthat function, and I'm not sure if we should add '-M' there...\n\nI've added Junio to sob, because the comments are his.\n\n\n gitweb/gitweb.perl |   33 ++++++++++++++++++++++++---------\n 1 files changed, 24 insertions(+), 9 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 6918947..99c74f1 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -141,6 +141,16 @@ sub feature_snapshot {\n \treturn ($ctype, $suffix, $command);\n }\n \n+# rename detection options for git-diff and git-diff-tree\n+# - default is '-M', with the cost proportional to\n+#   (number of removed files) * (number of new files).\n+# - more costly is '-C' (or '-C', '-M'), with the cost proportional to\n+#   (number of changed files + number of removed files) * (number of new files)\n+# - even more costly is '-C', '--find-copies-harder' with cost\n+#   (number of files in the original tree) * (number of new files)\n+# - one might want to include '-B' option, e.g. '-B', '-M'\n+our @diff_opts = ('-M'); # taken from git_commit\n+\n our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || \"++GITWEB_CONFIG++\";\n require $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n \n@@ -2613,7 +2623,7 @@ sub git_commit {\n \tif (!defined $parent) {\n \t\t$parent = \"--root\";\n \t}\n-\topen my $fd, \"-|\", $GIT, \"diff-tree\", '-r', '-M', $parent, $hash\n+\topen my $fd, \"-|\", $GIT, \"diff-tree\", '-r', @diff_opts, $parent, $hash\n \t\tor die_error(undef, \"Open git-diff-tree failed\");\n \tmy @difftree = map { chomp; $_ } <$fd>;\n \tclose $fd or die_error(undef, \"Reading git-diff-tree failed\");\n@@ -2720,7 +2730,7 @@ sub git_blobdiff {\n \tif (defined $hash_base && defined $hash_parent_base) {\n \t\tif (defined $file_name) {\n \t\t\t# read raw output\n-\t\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', '-M', '-C', $hash_parent_base, $hash_base,\n+\t\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', @diff_opts, $hash_parent_base, $hash_base,\n \t\t\t\t\"--\", $file_name\n \t\t\t\tor die_error(undef, \"Open git-diff-tree failed\");\n \t\t\t@difftree = map { chomp; $_ } <$fd>;\n@@ -2735,7 +2745,7 @@ sub git_blobdiff {\n \t\t\t}\n \n \t\t\t# read filtered raw output\n-\t\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', '-M', '-C', $hash_parent_base, $hash_base\n+\t\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', @diff_opts, $hash_parent_base, $hash_base\n \t\t\t\tor die_error(undef, \"Open git-diff-tree failed\");\n \t\t\t@difftree =\n \t\t\t\t# ':100644 100644 03b21826... 3b93d5e7... M\tls-files.c'\n@@ -2769,7 +2779,8 @@ sub git_blobdiff {\n \t\t}\n \n \t\t# open patch output\n-\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', '-p', '-M', '-C', $hash_parent_base, $hash_base,\n+\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', @diff_opts,\n+\t\t\t'-p', $hash_parent_base, $hash_base,\n \t\t\t\"--\", $file_name\n \t\t\tor die_error(undef, \"Open git-diff-tree failed\");\n \t}\n@@ -2804,7 +2815,7 @@ sub git_blobdiff {\n \t\t}\n \n \t\t# open patch output\n-\t\topen $fd, \"-|\", $GIT, \"diff\", '-p', $hash_parent, $hash\n+\t\topen $fd, \"-|\", $GIT, \"diff\", '-p', @diff_opts, $hash_parent, $hash\n \t\t\tor die_error(undef, \"Open git-diff failed\");\n \t} else  {\n \t\tdie_error('404 Not Found', \"Missing one of the blob diff parameters\")\n@@ -2889,7 +2900,7 @@ sub git_commitdiff {\n \tmy $fd;\n \tmy @difftree;\n \tif ($format eq 'html') {\n-\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', '-M', '-C',\n+\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', @diff_opts,\n \t\t\t\"--patch-with-raw\", \"--full-index\", $hash_parent, $hash\n \t\t\tor die_error(undef, \"Open git-diff-tree failed\");\n \n@@ -2900,7 +2911,8 @@ sub git_commitdiff {\n \t\t}\n \n \t} elsif ($format eq 'plain') {\n-\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', '-p', '-B', $hash_parent, $hash\n+\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', @diff_opts,\n+\t\t\t'-p', $hash_parent, $hash\n \t\t\tor die_error(undef, \"Open git-diff-tree failed\");\n \n \t} else {\n@@ -3209,9 +3221,12 @@ XML\n \t\t\tlast;\n \t\t}\n \t\tmy %cd = parse_date($co{'committer_epoch'});\n-\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', $co{'parent'}, $co{'id'} or next;\n+\t\topen $fd, \"-|\", $GIT, \"diff-tree\", '-r', @diff_opts,\n+\t\t\t$co{'parent'}, $co{'id'}\n+\t\t\tor next;\n \t\tmy @difftree = map { chomp; $_ } <$fd>;\n-\t\tclose $fd or next;\n+\t\tclose $fd\n+\t\t\tor next;\n \t\tprint \"<item>\\n\" .\n \t\t      \"<title>\" .\n \t\t      sprintf(\"%d %s %02d:%02d\", $cd{'mday'}, $cd{'month'}, $cd{'hour'}, $cd{'minute'}) . \" - \" . esc_html($co{'title'}) .\n-- \n1.4.1.1\n"}]}