Merge branch 'jc/blame' into jc/web-blame
authorJunio C Hamano <junkio@cox.net>
Fri, 6 Oct 2006 07:16:05 +0000 (00:16 -0700)
committerJunio C Hamano <junkio@cox.net>
Fri, 6 Oct 2006 07:16:05 +0000 (00:16 -0700)
* jc/blame:
git-blame --porcelain
blame.c: move code to output metainfo into a separate function.
git-blame: --show-number (and -n)
git-blame: --show-name (and -f)
blame.c: whitespace and formatting clean-up.
gitweb: Make the Git logo link target to point to the homepage
gitweb: blame: Minimize vertical table row padding
gitweb: Do not print "log" and "shortlog" redundantly in commit view
vc-git.el: Switch to using git-blame instead of git-annotate.
git.el: Fixed inverted "renamed from/to" message.
tar-tree deprecation: we eat our own dog food.
Add git-upload-archive to the main git man page
git-commit: cleanup unused function.
Fix usage string to match that given in the man page
Update the gitweb/README file to include setting the GITWEB_CONFIG environment

Conflicts:

gitweb/gitweb.perl

1  2 
Makefile
gitweb/gitweb.perl
diff --combined Makefile
index 09f60bb2c218576c342c2194262a460dda7160a9,2c7c33855e34a214d63a2745c3861c1e31743fbf..20bda7d7973fdfbf4a32209c22f58df16b0b33dd
+++ b/Makefile
@@@ -132,8 -132,6 +132,8 @@@ GITWEB_HOMETEXT = indextext.htm
  GITWEB_CSS = gitweb.css
  GITWEB_LOGO = git-logo.png
  GITWEB_FAVICON = git-favicon.png
 +GITWEB_SITE_HEADER =
 +GITWEB_SITE_FOOTER =
  
  export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
  
@@@ -677,8 -675,6 +677,8 @@@ gitweb/gitweb.cgi: gitweb/gitweb.per
            -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
            -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
            -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
 +          -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
 +          -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
            $< >$@+
        chmod +x $@+
        mv $@+ $@
@@@ -860,8 -856,9 +860,9 @@@ git.spec: git.spec.i
        mv $@+ $@
  
  GIT_TARNAME=git-$(GIT_VERSION)
- dist: git.spec git-tar-tree
-       ./git-tar-tree HEAD^{tree} $(GIT_TARNAME) > $(GIT_TARNAME).tar
+ dist: git.spec git-archive
+       ./git-archive --format=tar \
+               --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
        @mkdir -p $(GIT_TARNAME)
        @cp git.spec $(GIT_TARNAME)
        @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
diff --combined gitweb/gitweb.perl
index e4ebce6224f8f557c7a0eeb943a9c88390d93580,3320069171dbd8ed20b89f2d60a9e5ccdf1958f2..0ac05cc7184b7ecb4de849e3eef280a8698a5df0
@@@ -41,24 -41,19 +41,27 @@@ our $home_link_str = "++GITWEB_HOME_LIN
  # replace this with something more descriptive for clearer bookmarks
  our $site_name = "++GITWEB_SITENAME++" || $ENV{'SERVER_NAME'} || "Untitled";
  
 +# filename of html text to include at top of each page
 +our $site_header = "++GITWEB_SITE_HEADER++";
  # html text to include at home page
  our $home_text = "++GITWEB_HOMETEXT++";
 +# filename of html text to include at bottom of each page
 +our $site_footer = "++GITWEB_SITE_FOOTER++";
 +
 +# URI of stylesheets
 +our @stylesheets = ("++GITWEB_CSS++");
 +our $stylesheet;
 +# default is not to define style sheet, but it can be overwritten later
 +undef $stylesheet;
  
 -# URI of default stylesheet
 -our $stylesheet = "++GITWEB_CSS++";
  # URI of GIT logo
  our $logo = "++GITWEB_LOGO++";
  # URI of GIT favicon, assumed to be image/png type
  our $favicon = "++GITWEB_FAVICON++";
  
+ our $githelp_url = "http://git.or.cz/";
+ our $githelp_label = "git homepage";
  # source of projects list
  our $projects_list = "++GITWEB_LIST++";
  
@@@ -188,22 -183,6 +191,22 @@@ sub feature_pickaxe 
        return ($_[0]);
  }
  
 +# checking HEAD file with -e is fragile if the repository was
 +# initialized long time ago (i.e. symlink HEAD) and was pack-ref'ed
 +# and then pruned.
 +sub check_head_link {
 +      my ($dir) = @_;
 +      my $headfile = "$dir/HEAD";
 +      return ((-e $headfile) ||
 +              (-l $headfile && readlink($headfile) =~ /^refs\/heads\//));
 +}
 +
 +sub check_export_ok {
 +      my ($dir) = @_;
 +      return (check_head_link($dir) &&
 +              (!$export_ok || -e "$dir/$export_ok"));
 +}
 +
  # rename detection options for git-diff and git-diff-tree
  # - default is '-M', with the cost proportional to
  #   (number of removed files) * (number of new files).
@@@ -236,7 -215,7 +239,7 @@@ our $project = $cgi->param('p')
  if (defined $project) {
        if (!validate_pathname($project) ||
            !(-d "$projectroot/$project") ||
 -          !(-e "$projectroot/$project/HEAD") ||
 +          !check_head_link("$projectroot/$project") ||
            ($export_ok && !(-e "$projectroot/$project/$export_ok")) ||
            ($strict_export && !project_in_list($project))) {
                undef $project;
@@@ -313,7 -292,7 +316,7 @@@ sub evaluate_path_info 
        # find which part of PATH_INFO is project
        $project = $path_info;
        $project =~ s,/+$,,;
 -      while ($project && !-e "$projectroot/$project/HEAD") {
 +      while ($project && !check_head_link("$projectroot/$project")) {
                $project =~ s,/*[^/]*$,,;
        }
        # validate project
@@@ -840,7 -819,8 +843,7 @@@ sub git_get_projects_list 
  
                                my $subdir = substr($File::Find::name, $pfxlen + 1);
                                # we check related file in $projectroot
 -                              if (-e "$projectroot/$subdir/HEAD" && (!$export_ok ||
 -                                  -e "$projectroot/$subdir/$export_ok")) {
 +                              if (check_export_ok("$projectroot/$subdir")) {
                                        push @list, { path => $subdir };
                                        $File::Find::prune = 1;
                                }
                        if (!defined $path) {
                                next;
                        }
 -                      if (-e "$projectroot/$path/HEAD" && (!$export_ok ||
 -                          -e "$projectroot/$path/$export_ok")) {
 +                      if (check_export_ok("$projectroot/$path")) {
                                my $pr = {
                                        path => $path,
                                        owner => decode("utf8", $owner, Encode::FB_DEFAULT),
@@@ -1374,17 -1355,8 +1377,17 @@@ sub git_header_html 
  <meta name="generator" content="gitweb/$version git/$git_version"/>
  <meta name="robots" content="index, nofollow"/>
  <title>$title</title>
 -<link rel="stylesheet" type="text/css" href="$stylesheet"/>
  EOF
 +# print out each stylesheet that exist
 +      if (defined $stylesheet) {
 +#provides backwards capability for those people who define style sheet in a config file
 +              print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
 +      } else {
 +              foreach my $stylesheet (@stylesheets) {
 +                      next unless $stylesheet;
 +                      print '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'"/>'."\n";
 +              }
 +      }
        if (defined $project) {
                printf('<link rel="alternate" title="%s log" '.
                       'href="%s" type="application/rss+xml"/>'."\n",
        }
  
        print "</head>\n" .
 -            "<body>\n" .
 -            "<div class=\"page_header\">\n" .
 +            "<body>\n";
 +
 +      if (-f $site_header) {
 +              open (my $fd, $site_header);
 +              print <$fd>;
 +              close $fd;
 +      }
 +
 +      print "<div class=\"page_header\">\n" .
-             "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
+             "<a href=\"" . esc_html($githelp_url) .
+             "\" title=\"" . esc_html($githelp_label) .
+             "\">" .
              "<img src=\"$logo\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
              "</a>\n";
        print $cgi->a({-href => esc_url($home_link)}, $home_link_str) . " / ";
@@@ -1461,15 -1428,8 +1466,15 @@@ sub git_footer_html 
                print $cgi->a({-href => href(project=>undef, action=>"project_index"),
                              -class => "rss_logo"}, "TXT") . "\n";
        }
 -      print "</div>\n" .
 -            "</body>\n" .
 +      print "</div>\n" ;
 +
 +      if (-f $site_footer) {
 +              open (my $fd, $site_footer);
 +              print <$fd>;
 +              close $fd;
 +      }
 +
 +      print "</body>\n" .
              "</html>";
  }
  
@@@ -2521,30 -2481,22 +2526,30 @@@ sub git_blame2 
  <tr><th>Commit</th><th>Line</th><th>Data</th></tr>
  HTML
        while (<$fd>) {
 -              /^([0-9a-fA-F]{40}).*?(\d+)\)\s{1}(\s*.*)/;
 -              my $full_rev = $1;
 +              my ($full_rev, $author, $date, $lineno, $data) =
 +                      /^([0-9a-f]{40}).*?\s\((.*?)\s+([-\d]+ [:\d]+ [-+\d]+)\s+(\d+)\)\s(.*)/;
                my $rev = substr($full_rev, 0, 8);
 -              my $lineno = $2;
 -              my $data = $3;
 +              my $print_c8 = 0;
  
                if (!defined $last_rev) {
                        $last_rev = $full_rev;
 +                      $print_c8 = 1;
                } elsif ($last_rev ne $full_rev) {
                        $last_rev = $full_rev;
                        $current_color = ++$current_color % $num_colors;
 +                      $print_c8 = 1;
                }
                print "<tr class=\"$rev_color[$current_color]\">\n";
 -              print "<td class=\"sha1\">" .
 -                      $cgi->a({-href => href(action=>"commit", hash=>$full_rev, file_name=>$file_name)},
 -                              esc_html($rev)) . "</td>\n";
 +              print "<td class=\"sha1\"";
 +              if ($print_c8 == 1) {
 +                      print " title=\"$author, $date\"";
 +              }
 +              print ">";
 +              if ($print_c8 == 1) {
 +                      print $cgi->a({-href => href(action=>"commit", hash=>$full_rev, file_name=>$file_name)},
 +                                    esc_html($rev));
 +              }
 +              print "</td>\n";
                print "<td class=\"linenr\"><a id=\"l$lineno\" href=\"#l$lineno\" class=\"linenr\">" .
                      esc_html($lineno) . "</a></td>\n";
                print "<td class=\"pre\">" . esc_html($data) . "</td>\n";
@@@ -2891,9 -2843,12 +2896,12 @@@ sub git_snapshot 
                -content_disposition => 'inline; filename="' . "$filename" . '"',
                -status => '200 OK');
  
-       my $git_command = git_cmd_str();
-       open my $fd, "-|", "$git_command tar-tree $hash \'$project\' | $command" or
-               die_error(undef, "Execute git-tar-tree failed.");
+       my $git = git_cmd_str();
+       my $name = $project;
+       $name =~ s/\047/\047\\\047\047/g;
+       open my $fd, "-|",
+       "$git archive --format=tar --prefix=\'$name\'/ $hash | $command"
+               or die_error(undef, "Execute git-tar-tree failed.");
        binmode STDOUT, ':raw';
        print <$fd>;
        binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
@@@ -2990,11 -2945,6 +2998,6 @@@ sub git_commit 
                        $cgi->a({-href => href(action=>"blame", hash_parent=>$parent, file_name=>$file_name)},
                                "blame");
        }
-       if (defined $co{'parent'}) {
-               push @views_nav,
-                       $cgi->a({-href => href(action=>"shortlog", hash=>$hash)}, "shortlog"),
-                       $cgi->a({-href => href(action=>"log", hash=>$hash)}, "log");
-       }
        git_header_html(undef, $expires);
        git_print_page_nav('commit', defined $co{'parent'} ? '' : 'commitdiff',
                           $hash, $co{'tree'}, $hash,