@matheusbsbs / matheus-bagliano / commits / 847e01fb00
Fork 0

gitweb: Great subroutines renaming

Rename some of subroutines to better reflect what they do. Some renames were not performed because subroutine name reflects hash key. Subroutines name guideline: * git_ prefix for subroutines related to git commands, git repository, or to gitweb actions * git_get_ prefix for inner subroutines calling git command or reading some file in the repository and returning some output * parse_ prefix for subroutines parsing some text (or reading and parsing some text) into hash or list * format_ prefix for subroutines formatting, post-processing or generating some HTML/text fragment * _get_ infix for subroutines which return result * _print_ infix for subroutines which print fragment of output * _body suffix for subroutines which outputs main part (body) of related action (usually table) * _nav suffix for subroutines related to navigation bars * _div suffix for subroutines returning or printing div element * subroutine names should not be based on how the result is obtained, as this might change easily Renames performed: - git_get_referencing => format_ref_marker - git_get_paging_nav => format_paging_nav - git_read_head => git_get_head_hash - git_read_hash => git_get_hash_by_ref - git_read_description => git_get_project_description - git_read_projects => git_get_projects_list - read_info_ref => git_get_references - git_read_refs => git_get_refs_list - date_str => parse_date - git_read_tag => parse_tag - git_read_commit => parse_commit - git_blob_plain_mimetype => blob_mimetype - git_page_nav => git_print_page_nav - git_header_div => git_print_header_div Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Aug 14, 2006 at 02:05 UTC 847e01fb00872401c093957c2d6dd908aa8af30d
1 file changed +125 -125
gitweb/gitweb.perl
+125 -125
@@ -362,7 +362,7 @@ sub format_log_line_html {
362 }
363
364 # format marker of refs pointing to given object
365 -sub git_get_referencing {
365 +sub format_ref_marker {
366 my ($refs, $id) = @_;
367
368 if (defined $refs->{$id}) {
@@ -376,7 +376,7 @@ sub git_get_referencing {
376 ## git utility subroutines, invoking git commands
377
378 # get HEAD ref of given project as hash
379 -sub git_read_head {
379 +sub git_get_head_hash {
380 my $project = shift;
381 my $oENV = $ENV{'GIT_DIR'};
382 my $retval = undef;
@@ -445,7 +445,7 @@ sub git_get_hash_by_path {
445 ## git utility functions, directly accessing git repository
446
447 # assumes that PATH is not symref
448 -sub git_read_hash {
448 +sub git_get_hash_by_ref {
449 my $path = shift;
450
451 open my $fd, "$projectroot/$path" or return undef;
@@ -457,7 +457,7 @@ sub git_read_hash {
457 }
458 }
459
460 -sub git_read_description {
460 +sub git_get_project_description {
461 my $path = shift;
462
463 open my $fd, "$projectroot/$path/description" or return undef;
@@ -467,7 +467,7 @@ sub git_read_description {
467 return $descr;
468 }
469
470 -sub git_read_projects {
470 +sub git_get_projects_list {
471 my @list;
472
473 if (-d $projects_list) {
@@ -511,7 +511,7 @@ sub git_read_projects {
511 return @list;
512 }
513
514 -sub read_info_ref {
514 +sub git_get_references {
515 my $type = shift || "";
516 my %refs;
517 # 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c refs/tags/v2.6.11
@@ -536,7 +536,7 @@ sub read_info_ref {
536 ## ----------------------------------------------------------------------
537 ## parse to hash functions
538
539 -sub date_str {
539 +sub parse_date {
540 my $epoch = shift;
541 my $tz = shift || "-0000";
542
@@ -561,7 +561,7 @@ sub date_str {
561 return %date;
562 }
563
564 -sub git_read_tag {
564 +sub parse_tag {
565 my $tag_id = shift;
566 my %tag;
567 my @comment;
@@ -596,7 +596,7 @@ sub git_read_tag {
596 return %tag
597 }
598
599 -sub git_read_commit {
599 +sub parse_commit {
600 my $commit_id = shift;
601 my $commit_text = shift;
602
@@ -693,7 +693,7 @@ sub git_read_commit {
693 ## ......................................................................
694 ## parse to array of hashes functions
695
696 -sub git_read_refs {
696 +sub git_get_refs_list {
697 my $ref_dir = shift;
698 my @reflist;
699
@@ -707,7 +707,7 @@ sub git_read_refs {
707 }, "$projectroot/$project/$ref_dir");
708
709 foreach my $ref_file (@refs) {
710 - my $ref_id = git_read_hash("$project/$ref_dir/$ref_file");
710 + my $ref_id = git_get_hash_by_ref("$project/$ref_dir/$ref_file");
711 my $type = git_get_type($ref_id) || next;
712 my %ref_item;
713 my %co;
@@ -716,10 +716,10 @@ sub git_read_refs {
716 $ref_item{'epoch'} = 0;
717 $ref_item{'age'} = "unknown";
718 if ($type eq "tag") {
719 - my %tag = git_read_tag($ref_id);
719 + my %tag = parse_tag($ref_id);
720 $ref_item{'comment'} = $tag{'comment'};
721 if ($tag{'type'} eq "commit") {
722 - %co = git_read_commit($tag{'object'});
722 + %co = parse_commit($tag{'object'});
723 $ref_item{'epoch'} = $co{'committer_epoch'};
724 $ref_item{'age'} = $co{'age_string'};
725 } elsif (defined($tag{'epoch'})) {
@@ -731,7 +731,7 @@ sub git_read_refs {
731 $ref_item{'name'} = $tag{'name'};
732 $ref_item{'refid'} = $tag{'object'};
733 } elsif ($type eq "commit"){
734 - %co = git_read_commit($ref_id);
734 + %co = parse_commit($ref_id);
735 $ref_item{'reftype'} = "commit";
736 $ref_item{'name'} = $ref_file;
737 $ref_item{'title'} = $co{'title'};
@@ -806,7 +806,7 @@ sub mimetype_guess {
806 return $mime;
807 }
808
809 -sub git_blob_plain_mimetype {
809 +sub blob_mimetype {
810 my $fd = shift;
811 my $filename = shift;
812
@@ -925,7 +925,7 @@ EOF
925 sub git_footer_html {
926 print "<div class=\"page_footer\">\n";
927 if (defined $project) {
928 - my $descr = git_read_description($project);
928 + my $descr = git_get_project_description($project);
929 if (defined $descr) {
930 print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
931 }
@@ -955,7 +955,7 @@ sub die_error {
955 ## ----------------------------------------------------------------------
956 ## functions printing or outputting HTML: navigation
957
958 -sub git_page_nav {
958 +sub git_print_page_nav {
959 my ($current, $suppress, $head, $treehead, $treebase, $extra) = @_;
960 $extra = '' if !defined $extra; # pager or formats
961
@@ -989,7 +989,7 @@ sub git_page_nav {
989 "</div>\n";
990 }
991
992 -sub git_get_paging_nav {
992 +sub format_paging_nav {
993 my ($action, $hash, $head, $page, $nrevs) = @_;
994 my $paging_nav;
995
@@ -1022,7 +1022,7 @@ sub git_get_paging_nav {
1022 ## ......................................................................
1023 ## functions printing or outputting HTML: div
1024
1025 -sub git_header_div {
1025 +sub git_print_header_div {
1026 my ($action, $title, $hash, $hash_base) = @_;
1027 my $rest = '';
1028
@@ -1062,9 +1062,9 @@ sub git_shortlog_body {
1062 my $alternate = 0;
1063 for (my $i = $from; $i <= $to; $i++) {
1064 my $commit = $revlist->[$i];
1065 - #my $ref = defined $refs ? git_get_referencing($refs, $commit) : '';
1066 - my $ref = git_get_referencing($refs, $commit);
1067 - my %co = git_read_commit($commit);
1065 + #my $ref = defined $refs ? format_ref_marker($refs, $commit) : '';
1066 + my $ref = format_ref_marker($refs, $commit);
1067 + my %co = parse_commit($commit);
1068 if ($alternate) {
1069 print "<tr class=\"dark\">\n";
1070 } else {
@@ -1282,24 +1282,24 @@ sub git_project_list {
1282 die_error(undef, "Unknown order parameter");
1283 }
1284
1285 - my @list = git_read_projects();
1285 + my @list = git_get_projects_list();
1286 my @projects;
1287 if (!@list) {
1288 die_error(undef, "No projects found");
1289 }
1290 foreach my $pr (@list) {
1291 - my $head = git_read_head($pr->{'path'});
1291 + my $head = git_get_head_hash($pr->{'path'});
1292 if (!defined $head) {
1293 next;
1294 }
1295 $ENV{'GIT_DIR'} = "$projectroot/$pr->{'path'}";
1296 - my %co = git_read_commit($head);
1296 + my %co = parse_commit($head);
1297 if (!%co) {
1298 next;
1299 }
1300 $pr->{'commit'} = \%co;
1301 if (!defined $pr->{'descr'}) {
1302 - my $descr = git_read_description($pr->{'path'}) || "";
1302 + my $descr = git_get_project_description($pr->{'path'}) || "";
1303 $pr->{'descr'} = chop_str($descr, 25, 5);
1304 }
1305 if (!defined $pr->{'owner'}) {
@@ -1383,10 +1383,10 @@ sub git_project_list {
1383 }
1384
1385 sub git_summary {
1386 - my $descr = git_read_description($project) || "none";
1387 - my $head = git_read_head($project);
1388 - my %co = git_read_commit($head);
1389 - my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
1386 + my $descr = git_get_project_description($project) || "none";
1387 + my $head = git_get_head_hash($project);
1388 + my %co = parse_commit($head);
1389 + my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});
1390
1391 my $owner;
1392 if (-f $projects_list) {
@@ -1407,9 +1407,9 @@ sub git_summary {
1407 $owner = get_file_owner("$projectroot/$project");
1408 }
1409
1410 - my $refs = read_info_ref();
1410 + my $refs = git_get_references();
1411 git_header_html();
1412 - git_page_nav('summary','', $head);
1412 + git_print_page_nav('summary','', $head);
1413
1414 print "<div class=\"title\">&nbsp;</div>\n";
1415 print "<table cellspacing=\"0\">\n" .
@@ -1418,24 +1418,24 @@ sub git_summary {
1418 "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n" .
1419 "</table>\n";
1420
1421 - open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_read_head($project)
1421 + open my $fd, "-|", $GIT, "rev-list", "--max-count=17", git_get_head_hash($project)
1422 or die_error(undef, "Open git-rev-list failed");
1423 my @revlist = map { chomp; $_ } <$fd>;
1424 close $fd;
1425 - git_header_div('shortlog');
1425 + git_print_header_div('shortlog');
1426 git_shortlog_body(\@revlist, 0, 15, $refs,
1427 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "..."));
1428
1429 - my $taglist = git_read_refs("refs/tags");
1429 + my $taglist = git_get_refs_list("refs/tags");
1430 if (defined @$taglist) {
1431 - git_header_div('tags');
1431 + git_print_header_div('tags');
1432 git_tags_body($taglist, 0, 15,
1433 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tags")}, "..."));
1434 }
1435
1436 - my $headlist = git_read_refs("refs/heads");
1436 + my $headlist = git_get_refs_list("refs/heads");
1437 if (defined @$headlist) {
1438 - git_header_div('heads');
1438 + git_print_header_div('heads');
1439 git_heads_body($headlist, $head, 0, 15,
1440 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=heads")}, "..."));
1441 }
@@ -1444,11 +1444,11 @@ sub git_summary {
1444 }
1445
1446 sub git_tag {
1447 - my $head = git_read_head($project);
1447 + my $head = git_get_head_hash($project);
1448 git_header_html();
1449 - git_page_nav('','', $head,undef,$head);
1450 - my %tag = git_read_tag($hash);
1451 - git_header_div('commit', esc_html($tag{'name'}), $hash);
1449 + git_print_page_nav('','', $head,undef,$head);
1450 + my %tag = parse_tag($hash);
1451 + git_print_header_div('commit', esc_html($tag{'name'}), $hash);
1452 print "<div class=\"title_text\">\n" .
1453 "<table cellspacing=\"0\">\n" .
1454 "<tr>\n" .
@@ -1457,7 +1457,7 @@ sub git_tag {
1457 "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" .
1458 "</tr>\n";
1459 if (defined($tag{'author'})) {
1460 - my %ad = date_str($tag{'epoch'}, $tag{'tz'});
1460 + my %ad = parse_date($tag{'epoch'}, $tag{'tz'});
1461 print "<tr><td>author</td><td>" . esc_html($tag{'author'}) . "</td></tr>\n";
1462 print "<tr><td></td><td>" . $ad{'rfc2822'} . sprintf(" (%02d:%02d %s)", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) . "</td></tr>\n";
1463 }
@@ -1477,9 +1477,9 @@ sub git_blame2 {
1477 my $ftype;
1478 die_error(undef, "Permission denied") if (!git_get_project_config_bool ('blame'));
1479 die_error('404 Not Found', "File name not defined") if (!$file_name);
1480 - $hash_base ||= git_read_head($project);
1480 + $hash_base ||= git_get_head_hash($project);
1481 die_error(undef, "Couldn't find base commit") unless ($hash_base);
1482 - my %co = git_read_commit($hash_base)
1482 + my %co = parse_commit($hash_base)
1483 or die_error(undef, "Reading commit failed");
1484 if (!defined $hash) {
1485 $hash = git_get_hash_by_path($hash_base, $file_name, "blob")
@@ -1495,8 +1495,8 @@ sub git_blame2 {
1495 my $formats_nav =
1496 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, "blob") .
1497 " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;f=$file_name")}, "head");
1498 - git_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1499 - git_header_div('commit', esc_html($co{'title'}), $hash_base);
1498 + git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1499 + git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
1500 git_print_page_path($file_name, $ftype);
1501 my @rev_color = (qw(light2 dark2));
1502 my $num_colors = scalar(@rev_color);
@@ -1535,9 +1535,9 @@ sub git_blame {
1535 my $fd;
1536 die_error('403 Permission denied', "Permission denied") if (!git_get_project_config_bool ('blame'));
1537 die_error('404 Not Found', "File name not defined") if (!$file_name);
1538 - $hash_base ||= git_read_head($project);
1538 + $hash_base ||= git_get_head_hash($project);
1539 die_error(undef, "Couldn't find base commit") unless ($hash_base);
1540 - my %co = git_read_commit($hash_base)
1540 + my %co = parse_commit($hash_base)
1541 or die_error(undef, "Reading commit failed");
1542 if (!defined $hash) {
1543 $hash = git_get_hash_by_path($hash_base, $file_name, "blob")
@@ -1549,8 +1549,8 @@ sub git_blame {
1549 my $formats_nav =
1550 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, "blob") .
1551 " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;f=$file_name")}, "head");
1552 - git_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1553 - git_header_div('commit', esc_html($co{'title'}), $hash_base);
1552 + git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1553 + git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
1554 git_print_page_path($file_name, 'blob');
1555 print "<div class=\"page_body\">\n";
1556 print <<HTML;
@@ -1618,12 +1618,12 @@ HTML
1618 }
1619
1620 sub git_tags {
1621 - my $head = git_read_head($project);
1621 + my $head = git_get_head_hash($project);
1622 git_header_html();
1623 - git_page_nav('','', $head,undef,$head);
1624 - git_header_div('summary', $project);
1623 + git_print_page_nav('','', $head,undef,$head);
1624 + git_print_header_div('summary', $project);
1625
1626 - my $taglist = git_read_refs("refs/tags");
1626 + my $taglist = git_get_refs_list("refs/tags");
1627 if (defined @$taglist) {
1628 git_tags_body($taglist);
1629 }
@@ -1631,12 +1631,12 @@ sub git_tags {
1631 }
1632
1633 sub git_heads {
1634 - my $head = git_read_head($project);
1634 + my $head = git_get_head_hash($project);
1635 git_header_html();
1636 - git_page_nav('','', $head,undef,$head);
1637 - git_header_div('summary', $project);
1636 + git_print_page_nav('','', $head,undef,$head);
1637 + git_print_header_div('summary', $project);
1638
1639 - my $taglist = git_read_refs("refs/heads");
1639 + my $taglist = git_get_refs_list("refs/heads");
1640 if (defined @$taglist) {
1641 git_heads_body($taglist, $head);
1642 }
@@ -1646,7 +1646,7 @@ sub git_heads {
1646 sub git_blob_plain {
1647 if (!defined $hash) {
1648 if (defined $file_name) {
1649 - my $base = $hash_base || git_read_head($project);
1649 + my $base = $hash_base || git_get_head_hash($project);
1650 $hash = git_get_hash_by_path($base, $file_name, "blob")
1651 or die_error(undef, "Error lookup file");
1652 } else {
@@ -1657,7 +1657,7 @@ sub git_blob_plain {
1657 open my $fd, "-|", $GIT, "cat-file", "blob", $hash
1658 or die_error(undef, "Couldn't cat $file_name, $hash");
1659
1660 - $type ||= git_blob_plain_mimetype($fd, $file_name);
1660 + $type ||= blob_mimetype($fd, $file_name);
1661
1662 # save as filename, even when no $file_name is given
1663 my $save_as = "$hash";
@@ -1679,7 +1679,7 @@ sub git_blob_plain {
1679 sub git_blob {
1680 if (!defined $hash) {
1681 if (defined $file_name) {
1682 - my $base = $hash_base || git_read_head($project);
1682 + my $base = $hash_base || git_get_head_hash($project);
1683 $hash = git_get_hash_by_path($base, $file_name, "blob")
1684 or die_error(undef, "Error lookup file");
1685 } else {
@@ -1689,14 +1689,14 @@ sub git_blob {
1689 my $have_blame = git_get_project_config_bool ('blame');
1690 open my $fd, "-|", $GIT, "cat-file", "blob", $hash
1691 or die_error(undef, "Couldn't cat $file_name, $hash");
1692 - my $mimetype = git_blob_plain_mimetype($fd, $file_name);
1692 + my $mimetype = blob_mimetype($fd, $file_name);
1693 if ($mimetype !~ m/^text\//) {
1694 close $fd;
1695 return git_blob_plain($mimetype);
1696 }
1697 git_header_html();
1698 my $formats_nav = '';
1699 - if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1699 + if (defined $hash_base && (my %co = parse_commit($hash_base))) {
1700 if (defined $file_name) {
1701 if ($have_blame) {
1702 $formats_nav .= $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;h=$hash;hb=$hash_base;f=$file_name")}, "blame") . " | ";
@@ -1707,8 +1707,8 @@ sub git_blob {
1707 } else {
1708 $formats_nav .= $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash")}, "plain");
1709 }
1710 - git_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1711 - git_header_div('commit', esc_html($co{'title'}), $hash_base);
1710 + git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
1711 + git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
1712 } else {
1713 print "<div class=\"page_nav\">\n" .
1714 "<br/><br/></div>\n" .
@@ -1730,7 +1730,7 @@ sub git_blob {
1730
1731 sub git_tree {
1732 if (!defined $hash) {
1733 - $hash = git_read_head($project);
1733 + $hash = git_get_head_hash($project);
1734 if (defined $file_name) {
1735 my $base = $hash_base || $hash;
1736 $hash = git_get_hash_by_path($base, $file_name, "tree");
@@ -1746,16 +1746,16 @@ sub git_tree {
1746 close $fd or die_error(undef, "Reading tree failed");
1747 $/ = "\n";
1748
1749 - my $refs = read_info_ref();
1750 - my $ref = git_get_referencing($refs, $hash_base);
1749 + my $refs = git_get_references();
1750 + my $ref = format_ref_marker($refs, $hash_base);
1751 git_header_html();
1752 my $base_key = "";
1753 my $base = "";
1754 my $have_blame = git_get_project_config_bool ('blame');
1755 - if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1755 + if (defined $hash_base && (my %co = parse_commit($hash_base))) {
1756 $base_key = ";hb=$hash_base";
1757 - git_page_nav('tree','', $hash_base);
1758 - git_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);
1757 + git_print_page_nav('tree','', $hash_base);
1758 + git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);
1759 } else {
1760 print "<div class=\"page_nav\">\n";
1761 print "<br/><br/></div>\n";
@@ -1811,14 +1811,14 @@ sub git_tree {
1811 }
1812
1813 sub git_log {
1814 - my $head = git_read_head($project);
1814 + my $head = git_get_head_hash($project);
1815 if (!defined $hash) {
1816 $hash = $head;
1817 }
1818 if (!defined $page) {
1819 $page = 0;
1820 }
1821 - my $refs = read_info_ref();
1821 + my $refs = git_get_references();
1822
1823 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
1824 open my $fd, "-|", $GIT, "rev-list", $limit, $hash
@@ -1826,24 +1826,24 @@ sub git_log {
1826 my @revlist = map { chomp; $_ } <$fd>;
1827 close $fd;
1828
1829 - my $paging_nav = git_get_paging_nav('log', $hash, $head, $page, $#revlist);
1829 + my $paging_nav = format_paging_nav('log', $hash, $head, $page, $#revlist);
1830
1831 git_header_html();
1832 - git_page_nav('log','', $hash,undef,undef, $paging_nav);
1832 + git_print_page_nav('log','', $hash,undef,undef, $paging_nav);
1833
1834 if (!@revlist) {
1835 - my %co = git_read_commit($hash);
1835 + my %co = parse_commit($hash);
1836
1837 - git_header_div('summary', $project);
1837 + git_print_header_div('summary', $project);
1838 print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
1839 }
1840 for (my $i = ($page * 100); $i <= $#revlist; $i++) {
1841 my $commit = $revlist[$i];
1842 - my $ref = git_get_referencing($refs, $commit);
1843 - my %co = git_read_commit($commit);
1842 + my $ref = format_ref_marker($refs, $commit);
1843 + my %co = parse_commit($commit);
1844 next if !%co;
1845 - my %ad = date_str($co{'author_epoch'});
1846 - git_header_div('commit',
1845 + my %ad = parse_date($co{'author_epoch'});
1846 + git_print_header_div('commit',
1847 "<span class=\"age\">$co{'age_string'}</span>" .
1848 esc_html($co{'title'}) . $ref,
1849 $commit);
@@ -1881,12 +1881,12 @@ sub git_log {
1881 }
1882
1883 sub git_commit {
1884 - my %co = git_read_commit($hash);
1884 + my %co = parse_commit($hash);
1885 if (!%co) {
1886 die_error(undef, "Unknown commit object");
1887 }
1888 - my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
1889 - my %cd = date_str($co{'committer_epoch'}, $co{'committer_tz'});
1888 + my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
1889 + my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});
1890
1891 my $parent = $co{'parent'};
1892 if (!defined $parent) {
@@ -1902,22 +1902,22 @@ sub git_commit {
1902 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
1903 $expires = "+1d";
1904 }
1905 - my $refs = read_info_ref();
1906 - my $ref = git_get_referencing($refs, $co{'id'});
1905 + my $refs = git_get_references();
1906 + my $ref = format_ref_marker($refs, $co{'id'});
1907 my $formats_nav = '';
1908 if (defined $file_name && defined $co{'parent'}) {
1909 my $parent = $co{'parent'};
1910 $formats_nav .= $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blame;hb=$parent;f=$file_name")}, "blame");
1911 }
1912 git_header_html(undef, $expires);
1913 - git_page_nav('commit', defined $co{'parent'} ? '' : 'commitdiff',
1913 + git_print_page_nav('commit', defined $co{'parent'} ? '' : 'commitdiff',
1914 $hash, $co{'tree'}, $hash,
1915 $formats_nav);
1916
1917 if (defined $co{'parent'}) {
1918 - git_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);
1918 + git_print_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);
1919 } else {
1920 - git_header_div('tree', esc_html($co{'title'}) . $ref, $co{'tree'}, $hash);
1920 + git_print_header_div('tree', esc_html($co{'title'}) . $ref, $co{'tree'}, $hash);
1921 }
1922 print "<div class=\"title_text\">\n" .
1923 "<table cellspacing=\"0\">\n";
@@ -2079,11 +2079,11 @@ sub git_commit {
2079 sub git_blobdiff {
2080 mkdir($git_temp, 0700);
2081 git_header_html();
2082 - if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
2082 + if (defined $hash_base && (my %co = parse_commit($hash_base))) {
2083 my $formats_nav =
2084 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain");
2085 - git_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2086 - git_header_div('commit', esc_html($co{'title'}), $hash_base);
2085 + git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
2086 + git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
2087 } else {
2088 print "<div class=\"page_nav\">\n" .
2089 "<br/><br/></div>\n" .
@@ -2109,7 +2109,7 @@ sub git_blobdiff_plain {
2109
2110 sub git_commitdiff {
2111 mkdir($git_temp, 0700);
2112 - my %co = git_read_commit($hash);
2112 + my %co = parse_commit($hash);
2113 if (!%co) {
2114 die_error(undef, "Unknown commit object");
2115 }
@@ -2126,13 +2126,13 @@ sub git_commitdiff {
2126 if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
2127 $expires = "+1d";
2128 }
2129 - my $refs = read_info_ref();
2130 - my $ref = git_get_referencing($refs, $co{'id'});
2129 + my $refs = git_get_references();
2130 + my $ref = format_ref_marker($refs, $co{'id'});
2131 my $formats_nav =
2132 $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain");
2133 git_header_html(undef, $expires);
2134 - git_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
2135 - git_header_div('commit', esc_html($co{'title'}) . $ref, $hash);
2134 + git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);
2135 + git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash);
2136 print "<div class=\"page_body\">\n";
2137 my $comment = $co{'comment'};
2138 my $empty = 0;
@@ -2200,7 +2200,7 @@ sub git_commitdiff {
2200
2201 sub git_commitdiff_plain {
2202 mkdir($git_temp, 0700);
2203 - my %co = git_read_commit($hash);
2203 + my %co = parse_commit($hash);
2204 if (!%co) {
2205 die_error(undef, "Unknown commit object");
2206 }
@@ -2214,7 +2214,7 @@ sub git_commitdiff_plain {
2214
2215 # try to figure out the next tag after this commit
2216 my $tagname;
2217 - my $refs = read_info_ref("tags");
2217 + my $refs = git_get_references("tags");
2218 open $fd, "-|", $GIT, "rev-list", "HEAD";
2219 my @commits = map { chomp; $_ } <$fd>;
2220 close $fd;
@@ -2228,7 +2228,7 @@ sub git_commitdiff_plain {
2228 }
2229
2230 print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
2231 - my %ad = date_str($co{'author_epoch'}, $co{'author_tz'});
2231 + my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
2232 my $comment = $co{'comment'};
2233 print "From: $co{'author'}\n" .
2234 "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n".
@@ -2264,17 +2264,17 @@ sub git_commitdiff_plain {
2264
2265 sub git_history {
2266 if (!defined $hash_base) {
2267 - $hash_base = git_read_head($project);
2267 + $hash_base = git_get_head_hash($project);
2268 }
2269 my $ftype;
2270 - my %co = git_read_commit($hash_base);
2270 + my %co = parse_commit($hash_base);
2271 if (!%co) {
2272 die_error(undef, "Unknown commit object");
2273 }
2274 - my $refs = read_info_ref();
2274 + my $refs = git_get_references();
2275 git_header_html();
2276 - git_page_nav('','', $hash_base,$co{'tree'},$hash_base);
2277 - git_header_div('commit', esc_html($co{'title'}), $hash_base);
2276 + git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base);
2277 + git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
2278 if (!defined $hash && defined $file_name) {
2279 $hash = git_get_hash_by_path($hash_base, $file_name);
2280 }
@@ -2290,11 +2290,11 @@ sub git_history {
2290 while (my $line = <$fd>) {
2291 if ($line =~ m/^([0-9a-fA-F]{40})/){
2292 my $commit = $1;
2293 - my %co = git_read_commit($commit);
2293 + my %co = parse_commit($commit);
2294 if (!%co) {
2295 next;
2296 }
2297 - my $ref = git_get_referencing($refs, $commit);
2297 + my $ref = format_ref_marker($refs, $commit);
2298 if ($alternate) {
2299 print "<tr class=\"dark\">\n";
2300 } else {
@@ -2330,9 +2330,9 @@ sub git_search {
2330 die_error(undef, "Text field empty");
2331 }
2332 if (!defined $hash) {
2333 - $hash = git_read_head($project);
2333 + $hash = git_get_head_hash($project);
2334 }
2335 - my %co = git_read_commit($hash);
2335 + my %co = parse_commit($hash);
2336 if (!%co) {
2337 die_error(undef, "Unknown commit object");
2338 }
@@ -2351,8 +2351,8 @@ sub git_search {
2351 $pickaxe_search = 1;
2352 }
2353 git_header_html();
2354 - git_page_nav('','', $hash,$co{'tree'},$hash);
2355 - git_header_div('commit', esc_html($co{'title'}), $hash);
2354 + git_print_page_nav('','', $hash,$co{'tree'},$hash);
2355 + git_print_header_div('commit', esc_html($co{'title'}), $hash);
2356
2357 print "<table cellspacing=\"0\">\n";
2358 my $alternate = 0;
@@ -2370,7 +2370,7 @@ sub git_search {
2370 next;
2371 }
2372 my @commit_lines = split "\n", $commit_text;
2373 - my %co = git_read_commit(undef, \@commit_lines);
2373 + my %co = parse_commit(undef, \@commit_lines);
2374 if (!%co) {
2375 next;
2376 }
@@ -2451,7 +2451,7 @@ sub git_search {
2451 print "</td>\n" .
2452 "</tr>\n";
2453 }
2454 - %co = git_read_commit($1);
2454 + %co = parse_commit($1);
2455 }
2456 }
2457 close $fd;
@@ -2461,14 +2461,14 @@ sub git_search {
2461 }
2462
2463 sub git_shortlog {
2464 - my $head = git_read_head($project);
2464 + my $head = git_get_head_hash($project);
2465 if (!defined $hash) {
2466 $hash = $head;
2467 }
2468 if (!defined $page) {
2469 $page = 0;
2470 }
2471 - my $refs = read_info_ref();
2471 + my $refs = git_get_references();
2472
2473 my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2474 open my $fd, "-|", $GIT, "rev-list", $limit, $hash
@@ -2476,7 +2476,7 @@ sub git_shortlog {
2476 my @revlist = map { chomp; $_ } <$fd>;
2477 close $fd;
2478
2479 - my $paging_nav = git_get_paging_nav('shortlog', $hash, $head, $page, $#revlist);
2479 + my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#revlist);
2480 my $next_link = '';
2481 if ($#revlist >= (100 * ($page+1)-1)) {
2482 $next_link =
@@ -2486,8 +2486,8 @@ sub git_shortlog {
2486
2487
2488 git_header_html();
2489 - git_page_nav('shortlog','', $hash,$hash,$hash, $paging_nav);
2490 - git_header_div('summary', $project);
2489 + git_print_page_nav('shortlog','', $hash,$hash,$hash, $paging_nav);
2490 + git_print_header_div('summary', $project);
2491
2492 git_shortlog_body(\@revlist, ($page * 100), $#revlist, $refs, $next_link);
2493
@@ -2499,7 +2499,7 @@ sub git_shortlog {
2499
2500 sub git_rss {
2501 # http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
2502 - open my $fd, "-|", $GIT, "rev-list", "--max-count=150", git_read_head($project)
2502 + open my $fd, "-|", $GIT, "rev-list", "--max-count=150", git_get_head_hash($project)
2503 or die_error(undef, "Open git-rev-list failed");
2504 my @revlist = map { chomp; $_ } <$fd>;
2505 close $fd or die_error(undef, "Reading git-rev-list failed");
@@ -2514,12 +2514,12 @@ sub git_rss {
2514
2515 for (my $i = 0; $i <= $#revlist; $i++) {
2516 my $commit = $revlist[$i];
2517 - my %co = git_read_commit($commit);
2517 + my %co = parse_commit($commit);
2518 # we read 150, we always show 30 and the ones more recent than 48 hours
2519 if (($i >= 20) && ((time - $co{'committer_epoch'}) > 48*60*60)) {
2520 last;
2521 }
2522 - my %cd = date_str($co{'committer_epoch'});
2522 + my %cd = parse_date($co{'committer_epoch'});
2523 open $fd, "-|", $GIT, "diff-tree", '-r', $co{'parent'}, $co{'id'} or next;
2524 my @difftree = map { chomp; $_ } <$fd>;
2525 close $fd or next;
@@ -2556,7 +2556,7 @@ sub git_rss {
2556 }
2557
2558 sub git_opml {
2559 - my @list = git_read_projects();
2559 + my @list = git_get_projects_list();
2560
2561 print $cgi->header(-type => 'text/xml', -charset => 'utf-8');
2562 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
@@ -2569,12 +2569,12 @@ sub git_opml {
2569
2570 foreach my $pr (@list) {
2571 my %proj = %$pr;
2572 - my $head = git_read_head($proj{'path'});
2572 + my $head = git_get_head_hash($proj{'path'});
2573 if (!defined $head) {
2574 next;
2575 }
2576 $ENV{'GIT_DIR'} = "$projectroot/$proj{'path'}";
2577 - my %co = git_read_commit($head);
2577 + my %co = parse_commit($head);
2578 if (!%co) {
2579 next;
2580 }