Code

Merge branch 'maint'
authorShawn O. Pearce <spearce@spearce.org>
Wed, 17 Oct 2007 03:32:03 +0000 (23:32 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 17 Oct 2007 03:32:03 +0000 (23:32 -0400)
* maint:
  Document additional 1.5.3.5 fixes in release notes
  Avoid 'expr index' on Mac OS X as it isn't supported
  filter-branch: update current branch when rewritten
  fix filter-branch documentation
  helpful error message when send-pack finds no refs in common.
  Fix setup_git_directory_gently() with relative GIT_DIR & GIT_WORK_TREE
  Correct typos in release notes for 1.5.3.5

1  2 
git-instaweb.sh
send-pack.c

diff --combined git-instaweb.sh
index 2e4eeccaceb434696071be9a8a2f6af24000d976,41ff08f8e44b12bddcea257bc66f0b577e342ddd..95c3e5aa1f9bd5f0cec215ee2f81b2d4c36ea929
@@@ -30,16 -30,13 +30,15 @@@ test -z "$port" && port=123
  
  start_httpd () {
        httpd_only="`echo $httpd | cut -f1 -d' '`"
-       if test "`expr index $httpd_only /`" -eq '1' || \
-                               which $httpd_only >/dev/null
+       if case "$httpd_only" in /*) : ;; *) which $httpd_only >/dev/null;; esac
        then
                $httpd $fqgitdir/gitweb/httpd.conf
        else
                # many httpds are installed in /usr/sbin or /usr/local/sbin
                # these days and those are not in most users $PATHs
 -              for i in /usr/local/sbin /usr/sbin
 +              # in addition, we may have generated a server script
 +              # in $fqgitdir/gitweb.
 +              for i in /usr/local/sbin /usr/sbin "$fqgitdir/gitweb"
                do
                        if test -x "$i/$httpd_only"
                        then
@@@ -139,43 -136,6 +138,43 @@@ GIT_DIR="$fqgitdir
  export GIT_EXEC_PATH GIT_DIR
  
  
 +webrick_conf () {
 +      # generate a standalone server script in $fqgitdir/gitweb.
 +      cat >"$fqgitdir/gitweb/$httpd.rb" <<EOF
 +require 'webrick'
 +require 'yaml'
 +options = YAML::load_file(ARGV[0])
 +options[:StartCallback] = proc do
 +  File.open(options[:PidFile],"w") do |f|
 +    f.puts Process.pid
 +  end
 +end
 +options[:ServerType] = WEBrick::Daemon
 +server = WEBrick::HTTPServer.new(options)
 +['INT', 'TERM'].each do |signal|
 +  trap(signal) {server.shutdown}
 +end
 +server.start
 +EOF
 +      # generate a shell script to invoke the above ruby script,
 +      # which assumes _ruby_ is in the user's $PATH. that's _one_
 +      # portable way to run ruby, which could be installed anywhere,
 +      # really.
 +      cat >"$fqgitdir/gitweb/$httpd" <<EOF
 +#!/bin/sh
 +exec ruby "$fqgitdir/gitweb/$httpd.rb" \$*
 +EOF
 +      chmod +x "$fqgitdir/gitweb/$httpd"
 +
 +      cat >"$conf" <<EOF
 +:Port: $port
 +:DocumentRoot: "$fqgitdir/gitweb"
 +:DirectoryIndex: ["gitweb.cgi"]
 +:PidFile: "$fqgitdir/pid"
 +EOF
 +      test "$local" = true && echo ':BindAddress: "127.0.0.1"' >> "$conf"
 +}
 +
  lighttpd_conf () {
        cat > "$conf" <<EOF
  server.document-root = "$fqgitdir/gitweb"
@@@ -276,9 -236,6 +275,9 @@@ case "$httpd" i
  *apache2*)
        apache2_conf
        ;;
 +webrick)
 +      webrick_conf
 +      ;;
  *)
        echo "Unknown httpd specified: $httpd"
        exit 1
diff --combined send-pack.c
index 16ed51f6a012899e6e59eac6f4b657aa24f1c8df,fd985ed28d7f9ea1f8ba3d83313e2bce8d614d98..c1807f07946ca204bc1e8307eed04150e62c551d
@@@ -7,14 -7,13 +7,14 @@@
  #include "remote.h"
  
  static const char send_pack_usage[] =
 -"git-send-pack [--all] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
 +"git-send-pack [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
  "  --all and explicit <ref> specification are mutually exclusive.";
  static const char *receivepack = "git-receive-pack";
  static int verbose;
  static int send_all;
  static int force_update;
  static int use_thin_pack;
 +static int dry_run;
  
  /*
   * Make a pack stream and spit it out into file descriptor fd
@@@ -205,7 -204,8 +205,8 @@@ static int send_pack(int in, int out, s
                return -1;
  
        if (!remote_refs) {
-               fprintf(stderr, "No refs in common and none specified; doing nothing.\n");
+               fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
+                       "Perhaps you should specify a branch such as 'master'.\n");
                return 0;
        }
  
                strcpy(old_hex, sha1_to_hex(ref->old_sha1));
                new_hex = sha1_to_hex(ref->new_sha1);
  
 -              if (ask_for_status_report) {
 -                      packet_write(out, "%s %s %s%c%s",
 -                                   old_hex, new_hex, ref->name, 0,
 -                                   "report-status");
 -                      ask_for_status_report = 0;
 -                      expect_status_report = 1;
 +              if (!dry_run) {
 +                      if (ask_for_status_report) {
 +                              packet_write(out, "%s %s %s%c%s",
 +                                      old_hex, new_hex, ref->name, 0,
 +                                      "report-status");
 +                              ask_for_status_report = 0;
 +                              expect_status_report = 1;
 +                      }
 +                      else
 +                              packet_write(out, "%s %s %s",
 +                                      old_hex, new_hex, ref->name);
                }
 -              else
 -                      packet_write(out, "%s %s %s",
 -                                   old_hex, new_hex, ref->name);
                if (will_delete_ref)
                        fprintf(stderr, "deleting '%s'\n", ref->name);
                else {
                        fprintf(stderr, "\n  from %s\n  to   %s\n",
                                old_hex, new_hex);
                }
 -              if (remote) {
 +              if (remote && !dry_run) {
                        struct refspec rs;
                        rs.src = ref->name;
                        rs.dst = NULL;
                        if (!remote_find_tracking(remote, &rs)) {
 -                              struct ref_lock *lock;
                                fprintf(stderr, " Also local %s\n", rs.dst);
                                if (will_delete_ref) {
                                        if (delete_ref(rs.dst, NULL)) {
                                                error("Failed to delete");
                                        }
 -                              } else {
 -                                      lock = lock_any_ref_for_update(rs.dst, NULL, 0);
 -                                      if (!lock)
 -                                              error("Failed to lock");
 -                                      else
 -                                              write_ref_sha1(lock, ref->new_sha1,
 -                                                             "update by push");
 -                              }
 +                              } else
 +                                      update_ref("update by push", rs.dst,
 +                                              ref->new_sha1, NULL, 0, 0);
                                free(rs.dst);
                        }
                }
        }
  
        packet_flush(out);
 -      if (new_refs)
 +      if (new_refs && !dry_run)
                ret = pack_objects(out, remote_refs);
        close(out);
  
@@@ -393,10 -397,6 +394,10 @@@ int main(int argc, char **argv
                                send_all = 1;
                                continue;
                        }
 +                      if (!strcmp(arg, "--dry-run")) {
 +                              dry_run = 1;
 +                              continue;
 +                      }
                        if (!strcmp(arg, "--force")) {
                                force_update = 1;
                                continue;