Merge branch 'maint'
authorJunio C Hamano <junkio@cox.net>
Tue, 24 Oct 2006 02:29:05 +0000 (19:29 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 24 Oct 2006 02:29:05 +0000 (19:29 -0700)
* maint:
gitweb: Fix setting $/ in parse_commit()
daemon: do not die on older clients.
xdiff/xemit.c (xdl_find_func): Elide trailing white space in a context header.
git-clone: honor --quiet
Documentation for the [remote] config
prune-packed: Fix uninitialized variable.

1  2 
Documentation/config.txt
git-clone.sh
gitweb/gitweb.perl
diff --combined Documentation/config.txt
index 05d657444fc31768f9bf9909324b708ac6fcfd46,ee51fe3b9fcb551d8dbd6374103898229d4b77ea..026d4cf9ade90cd108d351e372ed862378cde100
@@@ -230,10 -230,18 +230,22 @@@ pull.octopus:
  pull.twohead::
        The default merge strategy to use when pulling a single branch.
  
+ remote.<name>.url::
+       The URL of a remote repository.  See gitlink:git-fetch[1] or
+       gitlink:git-push[1].
+ remote.<name>.fetch::
+       The default set of "refspec" for gitlink:git-fetch[1]. See
+       gitlink:git-fetch[1].
+ remote.<name>.push::
+       The default set of "refspec" for gitlink:git-push[1]. See
+       gitlink:git-push[1].
 +repack.usedeltabaseoffset::
 +      Allow gitlink:git-repack[1] to create packs that uses
 +      delta-base offset.  Defaults to false.
 +
  show.difftree::
        The default gitlink:git-diff-tree[1] arguments to be used
        for gitlink:git-show[1].
diff --combined git-clone.sh
index 786d65a8591235fde0cb8e34a497a4be18bf8410,24b119537bf5ed926235aabfceb8e4526af6f77a..3f006d1a778636e5906ad9e8671adb6561fa0d98
@@@ -8,15 -8,11 +8,15 @@@
  # See git-sh-setup why.
  unset CDPATH
  
 -usage() {
 -      echo >&2 "Usage: $0 [--template=<template_directory>] [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
 +die() {
 +      echo >&2 "$@"
        exit 1
  }
  
 +usage() {
 +      die "Usage: $0 [--template=<template_directory>] [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
 +}
 +
  get_repo_base() {
        (cd "$1" && (cd .git ; pwd)) 2> /dev/null
  }
@@@ -39,9 -35,11 +39,9 @@@ clone_dumb_http () 
                "`git-repo-config --bool http.noEPSV`" = true ]; then
                curl_extra_args="${curl_extra_args} --disable-epsv"
        fi
 -      http_fetch "$1/info/refs" "$clone_tmp/refs" || {
 -              echo >&2 "Cannot get remote repository information.
 +      http_fetch "$1/info/refs" "$clone_tmp/refs" ||
 +              die "Cannot get remote repository information.
  Perhaps git-update-server-info needs to be run there?"
 -              exit 1;
 -      }
        while read sha1 refname
        do
                name=`expr "z$refname" : 'zrefs/\(.*\)'` &&
@@@ -145,12 -143,17 +145,12 @@@ whil
                '')
                    usage ;;
                */*)
 -                  echo >&2 "'$2' is not suitable for an origin name"
 -                  exit 1
 +                  die "'$2' is not suitable for an origin name"
                esac
 -              git-check-ref-format "heads/$2" || {
 -                  echo >&2 "'$2' is not suitable for a branch name"
 -                  exit 1
 -              }
 -              test -z "$origin_override" || {
 -                  echo >&2 "Do not give more than one --origin options."
 -                  exit 1
 -              }
 +              git-check-ref-format "heads/$2" ||
 +                  die "'$2' is not suitable for a branch name"
 +              test -z "$origin_override" ||
 +                  die "Do not give more than one --origin options."
                origin_override=yes
                origin="$2"; shift
                ;;
  done
  
  repo="$1"
 -if test -z "$repo"
 -then
 -    echo >&2 'you must specify a repository to clone.'
 -    exit 1
 -fi
 +test -n "$repo" ||
 +    die 'you must specify a repository to clone.'
  
  # --bare implies --no-checkout
  if test yes = "$bare"
  then
        if test yes = "$origin_override"
        then
 -              echo >&2 '--bare and --origin $origin options are incompatible.'
 -              exit 1
 +              die '--bare and --origin $origin options are incompatible.'
        fi
        if test t = "$use_separate_remote"
        then
 -              echo >&2 '--bare and --use-separate-remote options are incompatible.'
 -              exit 1
 +              die '--bare and --use-separate-remote options are incompatible.'
        fi
        no_checkout=yes
  fi
@@@ -198,7 -206,7 +198,7 @@@ f
  dir="$2"
  # Try using "humanish" part of source repo if user didn't specify one
  [ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
 -[ -e "$dir" ] && echo "$dir already exists." && usage
 +[ -e "$dir" ] && die "destination directory '$dir' already exists."
  mkdir -p "$dir" &&
  D=$(cd "$dir" && pwd) &&
  trap 'err=$?; cd ..; rm -rf "$D"; exit $err' 0
@@@ -225,7 -233,7 +225,7 @@@ the
                 cd reference-tmp &&
                 tar xf -)
        else
 -              echo >&2 "$reference: not a local directory." && usage
 +              die "reference repository '$reference' is not a local directory."
        fi
  fi
  
@@@ -234,8 -242,10 +234,8 @@@ rm -f "$GIT_DIR/CLONE_HEAD
  # We do local magic only when the user tells us to.
  case "$local,$use_local" in
  yes,yes)
 -      ( cd "$repo/objects" ) || {
 -              echo >&2 "-l flag seen but $repo is not local."
 -              exit 1
 -      }
 +      ( cd "$repo/objects" ) ||
 +              die "-l flag seen but repository '$repo' is not local."
  
        case "$local_shared" in
        no)
                then
                        clone_dumb_http "$repo" "$D"
                else
 -                      echo >&2 "http transport not supported, rebuild Git with curl support"
 -                      exit 1
 +                      die "http transport not supported, rebuild Git with curl support"
                fi
                ;;
        *)
                case "$upload_pack" in
                '') git-fetch-pack --all -k $quiet "$repo" ;;
                *) git-fetch-pack --all -k $quiet "$upload_pack" "$repo" ;;
 -              esac >"$GIT_DIR/CLONE_HEAD" || {
 -                      echo >&2 "fetch-pack from '$repo' failed."
 -                      exit 1
 -              }
 +              esac >"$GIT_DIR/CLONE_HEAD" ||
 +                      die "fetch-pack from '$repo' failed."
                ;;
        esac
        ;;
@@@ -401,7 -414,8 +401,8 @@@ Pull: refs/heads/$head_points_at:$origi
  
        case "$no_checkout" in
        '')
-               git-read-tree -m -u -v HEAD HEAD
+               test "z$quiet" = z && v=-v || v=
+               git-read-tree -m -u $v HEAD HEAD
        esac
  fi
  rm -f "$GIT_DIR/CLONE_HEAD" "$GIT_DIR/REMOTE_HEAD"
diff --combined gitweb/gitweb.perl
index c9e57f05160df44d790126ce1c11b54ec622be47,2390603e97a970f47a6f54466e92483ea2649da3..bc8d8eb238c41a682924c6121e494bd7a1b5153e
@@@ -93,66 -93,21 +93,66 @@@ our %feature = 
        #
        # use gitweb_check_feature(<feature>) to check if <feature> is enabled
  
 +      # Enable the 'blame' blob view, showing the last commit that modified
 +      # each line in the file. This can be very CPU-intensive.
 +
 +      # To enable system wide have in $GITWEB_CONFIG
 +      # $feature{'blame'}{'default'} = [1];
 +      # To have project specific config enable override in $GITWEB_CONFIG
 +      # $feature{'blame'}{'override'} = 1;
 +      # and in project config gitweb.blame = 0|1;
        'blame' => {
                'sub' => \&feature_blame,
                'override' => 0,
                'default' => [0]},
  
 +      # Enable the 'snapshot' link, providing a compressed tarball of any
 +      # tree. This can potentially generate high traffic if you have large
 +      # project.
 +
 +      # To disable system wide have in $GITWEB_CONFIG
 +      # $feature{'snapshot'}{'default'} = [undef];
 +      # To have project specific config enable override in $GITWEB_CONFIG
 +      # $feature{'blame'}{'override'} = 1;
 +      # and in project config gitweb.snapshot = none|gzip|bzip2;
        'snapshot' => {
                'sub' => \&feature_snapshot,
                'override' => 0,
                #         => [content-encoding, suffix, program]
                'default' => ['x-gzip', 'gz', 'gzip']},
  
 +      # Enable the pickaxe search, which will list the commits that modified
 +      # a given string in a file. This can be practical and quite faster
 +      # alternative to 'blame', but still potentially CPU-intensive.
 +
 +      # To enable system wide have in $GITWEB_CONFIG
 +      # $feature{'pickaxe'}{'default'} = [1];
 +      # To have project specific config enable override in $GITWEB_CONFIG
 +      # $feature{'pickaxe'}{'override'} = 1;
 +      # and in project config gitweb.pickaxe = 0|1;
        'pickaxe' => {
                'sub' => \&feature_pickaxe,
                'override' => 0,
                'default' => [1]},
 +
 +      # Make gitweb use an alternative format of the URLs which can be
 +      # more readable and natural-looking: project name is embedded
 +      # directly in the path and the query string contains other
 +      # auxiliary information. All gitweb installations recognize
 +      # URL in either format; this configures in which formats gitweb
 +      # generates links.
 +
 +      # To enable system wide have in $GITWEB_CONFIG
 +      # $feature{'pathinfo'}{'default'} = [1];
 +      # Project specific override is not supported.
 +
 +      # Note that you will need to change the default location of CSS,
 +      # favicon, logo and possibly other files to an absolute URL. Also,
 +      # if gitweb.cgi serves as your indexfile, you will need to force
 +      # $my_uri to contain the script name in your $GITWEB_CONFIG.
 +      'pathinfo' => {
 +              'override' => 0,
 +              'default' => [0]},
  );
  
  sub gitweb_check_feature {
                $feature{$name}{'override'},
                @{$feature{$name}{'default'}});
        if (!$override) { return @defaults; }
 +      if (!defined $sub) {
 +              warn "feature $name is not overrideable";
 +              return @defaults;
 +      }
        return $sub->(@defaults);
  }
  
 -# To enable system wide have in $GITWEB_CONFIG
 -# $feature{'blame'}{'default'} = [1];
 -# To have project specific config enable override in $GITWEB_CONFIG
 -# $feature{'blame'}{'override'} = 1;
 -# and in project config gitweb.blame = 0|1;
 -
  sub feature_blame {
        my ($val) = git_get_project_config('blame', '--bool');
  
        return $_[0];
  }
  
 -# To disable system wide have in $GITWEB_CONFIG
 -# $feature{'snapshot'}{'default'} = [undef];
 -# To have project specific config enable override in $GITWEB_CONFIG
 -# $feature{'blame'}{'override'} = 1;
 -# and in project config  gitweb.snapshot = none|gzip|bzip2
 -
  sub feature_snapshot {
        my ($ctype, $suffix, $command) = @_;
  
@@@ -205,6 -168,12 +205,6 @@@ sub gitweb_have_snapshot 
        return $have_snapshot;
  }
  
 -# To enable system wide have in $GITWEB_CONFIG
 -# $feature{'pickaxe'}{'default'} = [1];
 -# To have project specific config enable override in $GITWEB_CONFIG
 -# $feature{'pickaxe'}{'override'} = 1;
 -# and in project config gitweb.pickaxe = 0|1;
 -
  sub feature_pickaxe {
        my ($val) = git_get_project_config('pickaxe', '--bool');
  
@@@ -412,10 -381,6 +412,10 @@@ exit
  
  sub href(%) {
        my %params = @_;
 +      my $href = $my_uri;
 +
 +      # XXX: Warning: If you touch this, check the search form for updating,
 +      # too.
  
        my @mapping = (
                project => "p",
  
        $params{'project'} = $project unless exists $params{'project'};
  
 +      my ($use_pathinfo) = gitweb_check_feature('pathinfo');
 +      if ($use_pathinfo) {
 +              # use PATH_INFO for project name
 +              $href .= "/$params{'project'}" if defined $params{'project'};
 +              delete $params{'project'};
 +
 +              # Summary just uses the project path URL
 +              if (defined $params{'action'} && $params{'action'} eq 'summary') {
 +                      delete $params{'action'};
 +              }
 +      }
 +
 +      # now encode the parameters explicitly
        my @result = ();
        for (my $i = 0; $i < @mapping; $i += 2) {
                my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
                        push @result, $symbol . "=" . esc_param($params{$name});
                }
        }
 -      return "$my_uri?" . join(';', @result);
 +      $href .= "?" . join(';', @result) if scalar @result;
 +
 +      return $href;
  }
  
  
@@@ -1059,12 -1009,11 +1059,11 @@@ sub parse_commit 
        if (defined $commit_text) {
                @commit_lines = @$commit_text;
        } else {
-               $/ = "\0";
+               local $/ = "\0";
                open my $fd, "-|", git_cmd(), "rev-list", "--header", "--parents", "--max-count=1", $commit_id
                        or return;
                @commit_lines = split '\n', <$fd>;
                close $fd or return;
-               $/ = "\n";
                pop @commit_lines;
        }
        my $header = shift @commit_lines;
@@@ -1461,7 -1410,6 +1460,7 @@@ EO
                }
                $cgi->param("a", "search");
                $cgi->param("h", $search_hash);
 +              $cgi->param("p", $project);
                print $cgi->startform(-method => "get", -action => $my_uri) .
                      "<div class=\"search\">\n" .
                      $cgi->hidden(-name => "p") . "\n" .
@@@ -1615,16 -1563,17 +1614,16 @@@ sub git_print_page_path 
        my $type = shift;
        my $hb = shift;
  
 -      if (!defined $name) {
 -              print "<div class=\"page_path\">/</div>\n";
 -      } else {
 +
 +      print "<div class=\"page_path\">";
 +      print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
 +                    -title => 'tree root'}, "[$project]");
 +      print " / ";
 +      if (defined $name) {
                my @dirname = split '/', $name;
                my $basename = pop @dirname;
                my $fullname = '';
  
 -              print "<div class=\"page_path\">";
 -              print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
 -                            -title => 'tree root'}, "[$project]");
 -              print " / ";
                foreach my $dir (@dirname) {
                        $fullname .= ($fullname ? '/' : '') . $dir;
                        print $cgi->a({-href => href(action=>"tree", file_name=>$fullname,
                        print $cgi->a({-href => href(action=>"tree", file_name=>$file_name,
                                                     hash_base=>$hb),
                                      -title => $name}, esc_html($basename));
 +                      print " / ";
                } else {
                        print esc_html($basename);
                }
 -              print "<br/></div>\n";
        }
 +      print "<br/></div>\n";
  }
  
  # sub git_print_log (\@;%) {
@@@ -2871,30 -2819,6 +2870,30 @@@ sub git_tree 
        print "<div class=\"page_body\">\n";
        print "<table cellspacing=\"0\">\n";
        my $alternate = 1;
 +      # '..' (top directory) link if possible
 +      if (defined $hash_base &&
 +          defined $file_name && $file_name =~ m![^/]+$!) {
 +              if ($alternate) {
 +                      print "<tr class=\"dark\">\n";
 +              } else {
 +                      print "<tr class=\"light\">\n";
 +              }
 +              $alternate ^= 1;
 +
 +              my $up = $file_name;
 +              $up =~ s!/?[^/]+$!!;
 +              undef $up unless $up;
 +              # based on git_print_tree_entry
 +              print '<td class="mode">' . mode_str('040000') . "</td>\n";
 +              print '<td class="list">';
 +              print $cgi->a({-href => href(action=>"tree", hash_base=>$hash_base,
 +                                           file_name=>$up)},
 +                            "..");
 +              print "</td>\n";
 +              print "<td class=\"link\"></td>\n";
 +
 +              print "</tr>\n";
 +      }
        foreach my $line (@entries) {
                my %t = parse_ls_tree_line($line, -z => 1);