{"thread":{"id":"6099","subject":"[PATCH 1/8] gitweb: Add parse_commits, used to bulk load commit objects.","startedAt":"2006-12-24T14:31:42Z","lastAt":"2006-12-27T14:22:21Z","messageCount":10,"participants":["Robert Fitzsimons","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"30242","messageId":"11669707092427-git-send-email-robfitz@273k.net","threadId":"6099","inReplyTo":null,"subject":"[PATCH 1/8] gitweb: Add parse_commits, used to bulk load commit objects.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-24T14:31:42Z","receivedAt":"2006-12-24T14:31:42Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"Add a new method parse_commits which is able to parse multiple commit\nobjects at once.  Reworked parse_commit to share the commit object\nparsing logic.\n\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n gitweb/gitweb.perl |   91 ++++++++++++++++++++++++++++++++++++++++++----------\n 1 files changed, 74 insertions(+), 17 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex d01d689..6bd57a4 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1270,25 +1270,13 @@ sub parse_tag {\n \treturn %tag\n }\n \n-sub parse_commit {\n-\tmy $commit_id = shift;\n-\tmy $commit_text = shift;\n-\n-\tmy @commit_lines;\n+sub parse_commit_text {\n+\tmy ($commit_text) = @_;\n+\tmy @commit_lines = split '\\n', $commit_text;\n \tmy %co;\n \n-\tif (defined $commit_text) {\n-\t\t@commit_lines = @$commit_text;\n-\t} else {\n-\t\tlocal $/ = \"\\0\";\n-\t\topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n-\t\t\t\"--header\", \"--parents\", \"--max-count=1\",\n-\t\t\t$commit_id, \"--\"\n-\t\t\tor return;\n-\t\t@commit_lines = split '\\n', <$fd>;\n-\t\tclose $fd or return;\n-\t\tpop @commit_lines;\n-\t}\n+\tpop @commit_lines; # Remove '\\0'\n+\n \tmy $header = shift @commit_lines;\n \tif (!($header =~ m/^[0-9a-fA-F]{40}/)) {\n \t\treturn;\n@@ -1375,6 +1363,75 @@ sub parse_commit {\n \treturn %co;\n }\n \n+sub parse_commit {\n+\tmy ($commit_id) = @_;\n+\tmy %co;\n+\n+\tlocal $/ = \"\\0\";\n+\n+\topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n+\t\t\"--header\",\n+\t\t\"--parents\",\n+\t\t\"--max-count=1\",\n+\t\t$commit_id,\n+\t\t\"--\",\n+\t\tor die_error(undef, \"Open git-rev-list failed\");\n+\t%co = parse_commit_text(<$fd>);\n+\tclose $fd;\n+\n+\treturn %co;\n+}\n+\n+sub parse_commits {\n+\tmy ($commit_id, $maxcount, $skip, $arg, $filename) = @_;\n+\tmy @cos;\n+\n+\t$maxcount ||= 1;\n+\t$skip ||= 0;\n+\n+\t# Delete once rev-list supports the --skip option\n+\tif ($skip > 0) {\n+\t\topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n+\t\t\t($arg ? ($arg) : ()),\n+\t\t\t(\"--max-count=\" . ($maxcount + $skip)),\n+\t\t\t$commit_id,\n+\t\t\t\"--\",\n+\t\t\t($filename ? ($filename) : ())\n+\t\t\tor die_error(undef, \"Open git-rev-list failed\");\n+\t\twhile (my $line = <$fd>) {\n+\t\t\tif ($skip-- <= 0) {\n+\t\t\t\tchomp $line;\n+\t\t\t\tmy %co = parse_commit($line);\n+\t\t\t\tpush @cos, \\%co;\n+\t\t\t}\n+\t\t}\n+\t\tclose $fd;\n+\n+\t\treturn wantarray ? @cos : \\@cos;\n+\t}\n+\n+\tlocal $/ = \"\\0\";\n+\n+\topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n+\t\t\"--header\",\n+\t\t\"--parents\",\n+\t\t($arg ? ($arg) : ()),\n+\t\t(\"--max-count=\" . $maxcount),\n+\t\t# Add once rev-list supports the --skip option\n+\t\t# (\"--skip=\" . $skip),\n+\t\t$commit_id,\n+\t\t\"--\",\n+\t\t($filename ? ($filename) : ())\n+\t\tor die_error(undef, \"Open git-rev-list failed\");\n+\twhile (my $line = <$fd>) {\n+\t\tmy %co = parse_commit_text($line);\n+\t\tpush @cos, \\%co;\n+\t}\n+\tclose $fd;\n+\n+\treturn wantarray ? @cos : \\@cos;\n+}\n+\n # parse ref from ref_file, given by ref_id, with given type\n sub parse_ref {\n \tmy $ref_file = shift;\n-- \n1.4.4.3.ge655-dirty\n"},{"id":"30243","messageId":"11669707094097-git-send-email-robfitz@273k.net","threadId":"6099","inReplyTo":"11669707092427-git-send-email-robfitz@273k.net","subject":"[PATCH 2/8] gitweb: We do longer need the --parents flag in rev-list.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-24T14:31:43Z","receivedAt":"2006-12-24T14:31:43Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"We only want to know the direct parents of a given commit object,\nthese parents are available in the --header output of rev-list.  If\n--parents is supplied with --full-history the output includes merge\ncommits that aren't relevant.\n\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n gitweb/gitweb.perl |   11 ++++++-----\n 1 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 6bd57a4..c645686 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1281,13 +1281,14 @@ sub parse_commit_text {\n \tif (!($header =~ m/^[0-9a-fA-F]{40}/)) {\n \t\treturn;\n \t}\n-\t($co{'id'}, my @parents) = split ' ', $header;\n-\t$co{'parents'} = \\@parents;\n-\t$co{'parent'} = $parents[0];\n+\t$co{'id'} = $header;\n+\tmy @parents;\n \twhile (my $line = shift @commit_lines) {\n \t\tlast if $line eq \"\\n\";\n \t\tif ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {\n \t\t\t$co{'tree'} = $1;\n+\t\t} elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) {\n+\t\t\tpush @parents, $1;\n \t\t} elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {\n \t\t\t$co{'author'} = $1;\n \t\t\t$co{'author_epoch'} = $2;\n@@ -1314,6 +1315,8 @@ sub parse_commit_text {\n \tif (!defined $co{'tree'}) {\n \t\treturn;\n \t};\n+\t$co{'parents'} = \\@parents;\n+\t$co{'parent'} = $parents[0];\n \n \tforeach my $title (@commit_lines) {\n \t\t$title =~ s/^    //;\n@@ -1371,7 +1374,6 @@ sub parse_commit {\n \n \topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n \t\t\"--header\",\n-\t\t\"--parents\",\n \t\t\"--max-count=1\",\n \t\t$commit_id,\n \t\t\"--\",\n@@ -1414,7 +1416,6 @@ sub parse_commits {\n \n \topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n \t\t\"--header\",\n-\t\t\"--parents\",\n \t\t($arg ? ($arg) : ()),\n \t\t(\"--max-count=\" . $maxcount),\n \t\t# Add once rev-list supports the --skip option\n-- \n1.4.4.3.ge655-dirty\n"},{"id":"30244","messageId":"11669707102678-git-send-email-robfitz@273k.net","threadId":"6099","inReplyTo":"11669707094097-git-send-email-robfitz@273k.net","subject":"[PATCH 3/8] gitweb: Change summary, shortlog actions to use parse_commits.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-24T14:31:44Z","receivedAt":"2006-12-24T14:31:44Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"Also added missing accesskey.\n\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n gitweb/gitweb.perl |   34 ++++++++++++----------------------\n 1 files changed, 12 insertions(+), 22 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex c645686..5f1ace9 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2704,20 +2704,19 @@ sub git_project_list_body {\n \n sub git_shortlog_body {\n \t# uses global variable $project\n-\tmy ($revlist, $from, $to, $refs, $extra) = @_;\n+\tmy ($commitlist, $from, $to, $refs, $extra) = @_;\n \n \tmy $have_snapshot = gitweb_have_snapshot();\n \n \t$from = 0 unless defined $from;\n-\t$to = $#{$revlist} if (!defined $to || $#{$revlist} < $to);\n+\t$to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);\n \n \tprint \"<table class=\\\"shortlog\\\" cellspacing=\\\"0\\\">\\n\";\n \tmy $alternate = 1;\n \tfor (my $i = $from; $i <= $to; $i++) {\n-\t\tmy $commit = $revlist->[$i];\n-\t\t#my $ref = defined $refs ? format_ref_marker($refs, $commit) : '';\n+\t\tmy %co = %{$commitlist->[$i]};\n+\t\tmy $commit = $co{'id'};\n \t\tmy $ref = format_ref_marker($refs, $commit);\n-\t\tmy %co = parse_commit($commit);\n \t\tif ($alternate) {\n \t\t\tprint \"<tr class=\\\"dark\\\">\\n\";\n \t\t} else {\n@@ -3081,14 +3080,10 @@ sub git_summary {\n \n \t# we need to request one more than 16 (0..15) to check if\n \t# those 16 are all\n-\topen my $fd, \"-|\", git_cmd(), \"rev-list\", \"--max-count=17\",\n-\t\t$head, \"--\"\n-\t\tor die_error(undef, \"Open git-rev-list failed\");\n-\tmy @revlist = map { chomp; $_ } <$fd>;\n-\tclose $fd;\n+\tmy @commitlist = parse_commits($head, 17);\n \tgit_print_header_div('shortlog');\n-\tgit_shortlog_body(\\@revlist, 0, 15, $refs,\n-\t                  $#revlist <=  15 ? undef :\n+\tgit_shortlog_body(\\@commitlist, 0, 15, $refs,\n+\t                  $#commitlist <=  15 ? undef :\n \t                  $cgi->a({-href => href(action=>\"shortlog\")}, \"...\"));\n \n \tif (@taglist) {\n@@ -4456,26 +4451,21 @@ sub git_shortlog {\n \t}\n \tmy $refs = git_get_references();\n \n-\tmy $limit = sprintf(\"--max-count=%i\", (100 * ($page+1)));\n-\topen my $fd, \"-|\", git_cmd(), \"rev-list\", $limit, $hash, \"--\"\n-\t\tor die_error(undef, \"Open git-rev-list failed\");\n-\tmy @revlist = map { chomp; $_ } <$fd>;\n-\tclose $fd;\n+\tmy @commitlist = parse_commits($head, 101, (100 * $page));\n \n-\tmy $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#revlist);\n+\tmy $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, (100 * ($page+1)));\n \tmy $next_link = '';\n-\tif ($#revlist >= (100 * ($page+1)-1)) {\n+\tif ($#commitlist >= 100) {\n \t\t$next_link =\n \t\t\t$cgi->a({-href => href(action=>\"shortlog\", hash=>$hash, page=>$page+1),\n-\t\t\t         -title => \"Alt-n\"}, \"next\");\n+\t\t\t         -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n \t}\n \n-\n \tgit_header_html();\n \tgit_print_page_nav('shortlog','', $hash,$hash,$hash, $paging_nav);\n \tgit_print_header_div('summary', $project);\n \n-\tgit_shortlog_body(\\@revlist, ($page * 100), $#revlist, $refs, $next_link);\n+\tgit_shortlog_body(\\@commitlist, 0, 99, $refs, $next_link);\n \n \tgit_footer_html();\n }\n-- \n1.4.4.3.ge655-dirty\n"},{"id":"30247","messageId":"11669707101872-git-send-email-robfitz@273k.net","threadId":"6099","inReplyTo":"11669707102678-git-send-email-robfitz@273k.net","subject":"[PATCH 4/8] gitweb: Change log action to use parse_commits.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-24T14:31:45Z","receivedAt":"2006-12-24T14:31:45Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"Also add missing next link to bottom of page.\n\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n gitweb/gitweb.perl |   25 ++++++++++++++-----------\n 1 files changed, 14 insertions(+), 11 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 5f1ace9..42b7449 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3645,28 +3645,25 @@ sub git_log {\n \t}\n \tmy $refs = git_get_references();\n \n-\tmy $limit = sprintf(\"--max-count=%i\", (100 * ($page+1)));\n-\topen my $fd, \"-|\", git_cmd(), \"rev-list\", $limit, $hash, \"--\"\n-\t\tor die_error(undef, \"Open git-rev-list failed\");\n-\tmy @revlist = map { chomp; $_ } <$fd>;\n-\tclose $fd;\n+\tmy @commitlist = parse_commits($hash, 101, (100 * $page));\n \n-\tmy $paging_nav = format_paging_nav('log', $hash, $head, $page, $#revlist);\n+\tmy $paging_nav = format_paging_nav('log', $hash, $head, $page, (100 * ($page+1)));\n \n \tgit_header_html();\n \tgit_print_page_nav('log','', $hash,undef,undef, $paging_nav);\n \n-\tif (!@revlist) {\n+\tif (!@commitlist) {\n \t\tmy %co = parse_commit($hash);\n \n \t\tgit_print_header_div('summary', $project);\n \t\tprint \"<div class=\\\"page_body\\\"> Last change $co{'age_string'}.<br/><br/></div>\\n\";\n \t}\n-\tfor (my $i = ($page * 100); $i <= $#revlist; $i++) {\n-\t\tmy $commit = $revlist[$i];\n-\t\tmy $ref = format_ref_marker($refs, $commit);\n-\t\tmy %co = parse_commit($commit);\n+\tmy $to = ($#commitlist >= 99) ? (99) : ($#commitlist);\n+\tfor (my $i = 0; $i <= $to; $i++) {\n+\t\tmy %co = %{$commitlist[$i]};\n \t\tnext if !%co;\n+\t\tmy $commit = $co{'id'};\n+\t\tmy $ref = format_ref_marker($refs, $commit);\n \t\tmy %ad = parse_date($co{'author_epoch'});\n \t\tgit_print_header_div('commit',\n \t\t               \"<span class=\\\"age\\\">$co{'age_string'}</span>\" .\n@@ -3688,6 +3685,12 @@ sub git_log {\n \t\tgit_print_log($co{'comment'}, -final_empty_line=> 1);\n \t\tprint \"</div>\\n\";\n \t}\n+\tif ($#commitlist >= 100) {\n+\t\tprint \"<div class=\\\"page_nav\\\">\\n\";\n+\t\tprint $cgi->a({-href => href(action=>\"log\", hash=>$hash, page=>$page+1),\n+\t\t\t       -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n+\t\tprint \"</div>\\n\";\n+\t}\n \tgit_footer_html();\n }\n \n-- \n1.4.4.3.ge655-dirty\n"},{"id":"30248","messageId":"116697071140-git-send-email-robfitz@273k.net","threadId":"6099","inReplyTo":"11669707101872-git-send-email-robfitz@273k.net","subject":"[PATCH 5/8] gitweb: Change header search action to use parse_commits.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-24T14:31:46Z","receivedAt":"2006-12-24T14:31:46Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n gitweb/gitweb.perl |   23 +++++++++--------------\n 1 files changed, 9 insertions(+), 14 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 42b7449..53dd225 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2910,18 +2910,18 @@ sub git_heads_body {\n }\n \n sub git_search_grep_body {\n-\tmy ($greplist, $from, $to, $extra) = @_;\n+\tmy ($commitlist, $from, $to, $extra) = @_;\n \t$from = 0 unless defined $from;\n-\t$to = $#{$greplist} if (!defined $to || $#{$greplist} < $to);\n+\t$to = $#{$commitlist} if (!defined $to || $#{$commitlist} < $to);\n \n \tprint \"<table class=\\\"grep\\\" cellspacing=\\\"0\\\">\\n\";\n \tmy $alternate = 1;\n \tfor (my $i = $from; $i <= $to; $i++) {\n-\t\tmy $commit = $greplist->[$i];\n-\t\tmy %co = parse_commit($commit);\n+\t\tmy %co = %{$commitlist->[$i]};\n \t\tif (!%co) {\n \t\t\tnext;\n \t\t}\n+\t\tmy $commit = $co{'id'};\n \t\tif ($alternate) {\n \t\t\tprint \"<tr class=\\\"dark\\\">\\n\";\n \t\t} else {\n@@ -4307,13 +4307,8 @@ sub git_search {\n \t\t} elsif ($searchtype eq 'committer') {\n \t\t\t$greptype = \"--committer=\";\n \t\t}\n-\t\topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n-\t\t\t(\"--max-count=\" . (100 * ($page+1))),\n-\t\t\t($greptype . $searchtext),\n-\t\t\t$hash, \"--\"\n-\t\t\tor next;\n-\t\tmy @revlist = map { chomp; $_ } <$fd>;\n-\t\tclose $fd;\n+\t\t$greptype .= $searchtext;\n+\t\tmy @commitlist = parse_commits($hash, 101, (100 * $page), $greptype);\n \n \t\tmy $paging_nav = '';\n \t\tif ($page > 0) {\n@@ -4330,7 +4325,7 @@ sub git_search {\n \t\t\t$paging_nav .= \"first\";\n \t\t\t$paging_nav .= \" &sdot; prev\";\n \t\t}\n-\t\tif ($#revlist >= (100 * ($page+1)-1)) {\n+\t\tif ($#commitlist >= 100) {\n \t\t\t$paging_nav .= \" &sdot; \" .\n \t\t\t\t$cgi->a({-href => href(action=>\"search\", hash=>$hash,\n \t\t\t\t\t\t       searchtext=>$searchtext, searchtype=>$searchtype,\n@@ -4340,7 +4335,7 @@ sub git_search {\n \t\t\t$paging_nav .= \" &sdot; next\";\n \t\t}\n \t\tmy $next_link = '';\n-\t\tif ($#revlist >= (100 * ($page+1)-1)) {\n+\t\tif ($#commitlist >= 100) {\n \t\t\t$next_link =\n \t\t\t\t$cgi->a({-href => href(action=>\"search\", hash=>$hash,\n \t\t\t\t\t\t       searchtext=>$searchtext, searchtype=>$searchtype,\n@@ -4350,7 +4345,7 @@ sub git_search {\n \n \t\tgit_print_page_nav('','', $hash,$co{'tree'},$hash, $paging_nav);\n \t\tgit_print_header_div('commit', esc_html($co{'title'}), $hash);\n-\t\tgit_search_grep_body(\\@revlist, ($page * 100), $#revlist, $next_link);\n+\t\tgit_search_grep_body(\\@commitlist, 0, 99, $next_link);\n \t}\n \n \tif ($searchtype eq 'pickaxe') {\n-- \n1.4.4.3.ge655-dirty\n"},{"id":"30246","messageId":"1166970711394-git-send-email-robfitz@273k.net","threadId":"6099","inReplyTo":"116697071140-git-send-email-robfitz@273k.net","subject":"[PATCH 6/8] gitweb: Change atom, rss actions to use parse_commits.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-24T14:31:47Z","receivedAt":"2006-12-24T14:31:47Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n gitweb/gitweb.perl |   18 +++++++-----------\n 1 files changed, 7 insertions(+), 11 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 53dd225..f752a6f 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4483,11 +4483,7 @@ sub git_feed {\n \n \t# log/feed of current (HEAD) branch, log of given branch, history of file/directory\n \tmy $head = $hash || 'HEAD';\n-\topen my $fd, \"-|\", git_cmd(), \"rev-list\", \"--max-count=150\",\n-\t\t$head, \"--\", (defined $file_name ? $file_name : ())\n-\t\tor die_error(undef, \"Open git-rev-list failed\");\n-\tmy @revlist = map { chomp; $_ } <$fd>;\n-\tclose $fd or die_error(undef, \"Reading git-rev-list failed\");\n+\tmy @commitlist = parse_commits($head, 150);\n \n \tmy %latest_commit;\n \tmy %latest_date;\n@@ -4497,8 +4493,8 @@ sub git_feed {\n \t\t# browser (feed reader) prefers text/xml\n \t\t$content_type = 'text/xml';\n \t}\n-\tif (defined($revlist[0])) {\n-\t\t%latest_commit = parse_commit($revlist[0]);\n+\tif (defined($commitlist[0])) {\n+\t\t%latest_commit = %{$commitlist[0]};\n \t\t%latest_date   = parse_date($latest_commit{'author_epoch'});\n \t\tprint $cgi->header(\n \t\t\t-type => $content_type,\n@@ -4588,9 +4584,9 @@ XML\n \t}\n \n \t# contents\n-\tfor (my $i = 0; $i <= $#revlist; $i++) {\n-\t\tmy $commit = $revlist[$i];\n-\t\tmy %co = parse_commit($commit);\n+\tfor (my $i = 0; $i <= $#commitlist; $i++) {\n+\t\tmy %co = %{$commitlist[$i]};\n+\t\tmy $commit = $co{'id'};\n \t\t# we read 150, we always show 30 and the ones more recent than 48 hours\n \t\tif (($i >= 20) && ((time - $co{'author_epoch'}) > 48*60*60)) {\n \t\t\tlast;\n@@ -4598,7 +4594,7 @@ XML\n \t\tmy %cd = parse_date($co{'author_epoch'});\n \n \t\t# get list of changed files\n-\t\topen $fd, \"-|\", git_cmd(), \"diff-tree\", '-r', @diff_opts,\n+\t\topen my $fd, \"-|\", git_cmd(), \"diff-tree\", '-r', @diff_opts,\n \t\t\t$co{'parent'}, $co{'id'}, \"--\", (defined $file_name ? $file_name : ())\n \t\t\tor next;\n \t\tmy @difftree = map { chomp; $_ } <$fd>;\n-- \n1.4.4.3.ge655-dirty\n"},{"id":"30249","messageId":"11669707111273-git-send-email-robfitz@273k.net","threadId":"6099","inReplyTo":"1166970711394-git-send-email-robfitz@273k.net","subject":"[PATCH 7/8] gitweb: Change history action to use parse_commits.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-24T14:31:48Z","receivedAt":"2006-12-24T14:31:48Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"Also added missing accesskey.\n\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n gitweb/gitweb.perl |   27 +++++++++------------------\n 1 files changed, 9 insertions(+), 18 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f752a6f..f9994d9 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2750,23 +2750,19 @@ sub git_shortlog_body {\n \n sub git_history_body {\n \t# Warning: assumes constant type (blob or tree) during history\n-\tmy ($revlist, $from, $to, $refs, $hash_base, $ftype, $extra) = @_;\n+\tmy ($commitlist, $from, $to, $refs, $hash_base, $ftype, $extra) = @_;\n \n \t$from = 0 unless defined $from;\n-\t$to = $#{$revlist} unless (defined $to && $to <= $#{$revlist});\n+\t$to = $#{$commitlist} unless (defined $to && $to <= $#{$commitlist});\n \n \tprint \"<table class=\\\"history\\\" cellspacing=\\\"0\\\">\\n\";\n \tmy $alternate = 1;\n \tfor (my $i = $from; $i <= $to; $i++) {\n-\t\tif ($revlist->[$i] !~ m/^([0-9a-fA-F]{40})/) {\n-\t\t\tnext;\n-\t\t}\n-\n-\t\tmy $commit = $1;\n-\t\tmy %co = parse_commit($commit);\n+\t\tmy %co = %{$commitlist->[$i]};\n \t\tif (!%co) {\n \t\t\tnext;\n \t\t}\n+\t\tmy $commit = $co{'id'};\n \n \t\tmy $ref = format_ref_marker($refs, $commit);\n \n@@ -4219,12 +4215,7 @@ sub git_history {\n \t\t$ftype = git_get_type($hash);\n \t}\n \n-\topen my $fd, \"-|\",\n-\t\tgit_cmd(), \"rev-list\", $limit, \"--full-history\", $hash_base, \"--\", $file_name\n-\t\t\tor die_error(undef, \"Open git-rev-list-failed\");\n-\tmy @revlist = map { chomp; $_ } <$fd>;\n-\tclose $fd\n-\t\tor die_error(undef, \"Reading git-rev-list failed\");\n+\tmy @commitlist = parse_commits($hash_base, 101, (100 * $page), \"--full-history\", $file_name);\n \n \tmy $paging_nav = '';\n \tif ($page > 0) {\n@@ -4240,7 +4231,7 @@ sub git_history {\n \t\t$paging_nav .= \"first\";\n \t\t$paging_nav .= \" &sdot; prev\";\n \t}\n-\tif ($#revlist >= (100 * ($page+1)-1)) {\n+\tif ($#commitlist >= 100) {\n \t\t$paging_nav .= \" &sdot; \" .\n \t\t\t$cgi->a({-href => href(action=>\"history\", hash=>$hash, hash_base=>$hash_base,\n \t\t\t                       file_name=>$file_name, page=>$page+1),\n@@ -4249,11 +4240,11 @@ sub git_history {\n \t\t$paging_nav .= \" &sdot; next\";\n \t}\n \tmy $next_link = '';\n-\tif ($#revlist >= (100 * ($page+1)-1)) {\n+\tif ($#commitlist >= 100) {\n \t\t$next_link =\n \t\t\t$cgi->a({-href => href(action=>\"history\", hash=>$hash, hash_base=>$hash_base,\n \t\t\t                       file_name=>$file_name, page=>$page+1),\n-\t\t\t         -title => \"Alt-n\"}, \"next\");\n+\t\t\t         -accesskey => \"n\", -title => \"Alt-n\"}, \"next\");\n \t}\n \n \tgit_header_html();\n@@ -4261,7 +4252,7 @@ sub git_history {\n \tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n \tgit_print_page_path($file_name, $ftype, $hash_base);\n \n-\tgit_history_body(\\@revlist, ($page * 100), $#revlist,\n+\tgit_history_body(\\@commitlist, 0, 99,\n \t                 $refs, $hash_base, $ftype, $next_link);\n \n \tgit_footer_html();\n-- \n1.4.4.3.ge655-dirty\n"},{"id":"30245","messageId":"11669707123843-git-send-email-robfitz@273k.net","threadId":"6099","inReplyTo":"11669707111273-git-send-email-robfitz@273k.net","subject":"[PATCH 8/8] gitweb: Use rev-list --skip option.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-24T14:31:49Z","receivedAt":"2006-12-24T14:31:49Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n gitweb/gitweb.perl |   24 +-----------------------\n 1 files changed, 1 insertions(+), 23 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f9994d9..65fcdb0 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1391,35 +1391,13 @@ sub parse_commits {\n \t$maxcount ||= 1;\n \t$skip ||= 0;\n \n-\t# Delete once rev-list supports the --skip option\n-\tif ($skip > 0) {\n-\t\topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n-\t\t\t($arg ? ($arg) : ()),\n-\t\t\t(\"--max-count=\" . ($maxcount + $skip)),\n-\t\t\t$commit_id,\n-\t\t\t\"--\",\n-\t\t\t($filename ? ($filename) : ())\n-\t\t\tor die_error(undef, \"Open git-rev-list failed\");\n-\t\twhile (my $line = <$fd>) {\n-\t\t\tif ($skip-- <= 0) {\n-\t\t\t\tchomp $line;\n-\t\t\t\tmy %co = parse_commit($line);\n-\t\t\t\tpush @cos, \\%co;\n-\t\t\t}\n-\t\t}\n-\t\tclose $fd;\n-\n-\t\treturn wantarray ? @cos : \\@cos;\n-\t}\n-\n \tlocal $/ = \"\\0\";\n \n \topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n \t\t\"--header\",\n \t\t($arg ? ($arg) : ()),\n \t\t(\"--max-count=\" . $maxcount),\n-\t\t# Add once rev-list supports the --skip option\n-\t\t# (\"--skip=\" . $skip),\n+\t\t(\"--skip=\" . $skip),\n \t\t$commit_id,\n \t\t\"--\",\n \t\t($filename ? ($filename) : ())\n-- \n1.4.4.3.ge655-dirty\n"},{"id":"30280","messageId":"empkcf$qp$1@sea.gmane.org","threadId":"6099","inReplyTo":"11669707094097-git-send-email-robfitz@273k.net","subject":"Re: [PATCH 2/8] gitweb: We do longer need the --parents flag in rev-list.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-25T22:49:27Z","receivedAt":"2006-12-25T22:49:27Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Robert Fitzsimons wrote:\n\n> We only want to know the direct parents of a given commit object,\n> these parents are available in the --header output of rev-list.  If\n> --parents is supplied with --full-history the output includes merge\n> commits that aren't relevant.\n\nActually --header output gives us original parents. Rewritten parents\n(available with --parents) include also grafts and shallow clone grafts.\nFor parse_commit we want --parents, for parse_commits we don't want it\nbecause --parents affects --full-history.\n\nThe problem is that we cannot detect if git-rev-list was called with\n--parents and commit is root commit (parentless), or we didn't use\n--parents option.\n\nIn few other places we pass options specifying subroutine behavior\nas hash after all other requred parameters, e.g. \n  esc_html($line, -nbsp=>1),\n  parse_ls_tree_line($line, -z=>1), \n  git_print_log($co{'comment'}, -final_empty_line=> 1, -remove_title => 1);\nIn this case it wouldn't work (unless we pass reference to array,\nvia parse_commit_text( [ <$fd> ], -parents=>1);\n\nPerhaps it would be better to use reference to hash of options as _first_\nparameter, e.g. parse_commit_text({-parents=>1}, <$fd>);, and use something\nlike if (ref($[0]) == 'HASH') { $opts = shift @_; } to get options.\n\nSo for now gitweb might not show what we want in very rare cases of\nrepositories with grafts or shallow clones.\n\n\nBut apart from this small matter, this series is excellent work. Thanks! \n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"30354","messageId":"20061227142221.GC6558@localhost","threadId":"6099","inReplyTo":"empkcf$qp$1@sea.gmane.org","subject":"[PATCH] gitweb: Re-enable rev-list --parents for parse_commit.","fromName":"Robert Fitzsimons","fromEmail":"robfitz@273k.net","sentAt":"2006-12-27T14:22:21Z","receivedAt":"2006-12-27T14:22:21Z","isPatch":true,"sender":{"key":"robfitz@273k.net","avatar":null},"body":"Re-enable rev-list --parents for parse_commit which was removed in\n(208b2dff95bb48682c351099023a1cbb0e1edf26).  rev-list --parents is not\njust used to return the parent headers in the commit object, it\nincludes any grafts which are vaild for the commit.\n\nSigned-off-by: Robert Fitzsimons <robfitz@273k.net>\n---\n\n\n> Actually --header output gives us original parents. Rewritten parents\n> (available with --parents) include also grafts and shallow clone grafts.\n> For parse_commit we want --parents, for parse_commits we don't want it\n> because --parents affects --full-history.\n\nHeres a patch the re-enables --parents for parse_commit.\n\nRobert\n\n\n gitweb/gitweb.perl |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 65fcdb0..da12be7 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1271,7 +1271,7 @@ sub parse_tag {\n }\n \n sub parse_commit_text {\n-\tmy ($commit_text) = @_;\n+\tmy ($commit_text, $withparents) = @_;\n \tmy @commit_lines = split '\\n', $commit_text;\n \tmy %co;\n \n@@ -1281,13 +1281,12 @@ sub parse_commit_text {\n \tif (!($header =~ m/^[0-9a-fA-F]{40}/)) {\n \t\treturn;\n \t}\n-\t$co{'id'} = $header;\n-\tmy @parents;\n+\t($co{'id'}, my @parents) = split ' ', $header;\n \twhile (my $line = shift @commit_lines) {\n \t\tlast if $line eq \"\\n\";\n \t\tif ($line =~ m/^tree ([0-9a-fA-F]{40})$/) {\n \t\t\t$co{'tree'} = $1;\n-\t\t} elsif ($line =~ m/^parent ([0-9a-fA-F]{40})$/) {\n+\t\t} elsif ((!defined $withparents) && ($line =~ m/^parent ([0-9a-fA-F]{40})$/)) {\n \t\t\tpush @parents, $1;\n \t\t} elsif ($line =~ m/^author (.*) ([0-9]+) (.*)$/) {\n \t\t\t$co{'author'} = $1;\n@@ -1373,12 +1372,13 @@ sub parse_commit {\n \tlocal $/ = \"\\0\";\n \n \topen my $fd, \"-|\", git_cmd(), \"rev-list\",\n+\t\t\"--parents\",\n \t\t\"--header\",\n \t\t\"--max-count=1\",\n \t\t$commit_id,\n \t\t\"--\",\n \t\tor die_error(undef, \"Open git-rev-list failed\");\n-\t%co = parse_commit_text(<$fd>);\n+\t%co = parse_commit_text(<$fd>, 1);\n \tclose $fd;\n \n \treturn %co;\n-- \n1.4.4.3.g6934\n"}]}