Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Tue, 24 Nov 2009 05:54:39 +0000 (21:54 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 Nov 2009 05:54:39 +0000 (21:54 -0800)
* maint:
pack-objects: split implications of --all-progress from progress activation
instaweb: restart server if already running
prune-packed: only show progress when stderr is a tty

Conflicts:
builtin-pack-objects.c

1  2 
builtin-pack-objects.c
builtin-send-pack.c
git-instaweb.sh
diff --combined builtin-pack-objects.c
index 4c91e944c21df3d5e02535115cdd6098ee49d86d,7938202170c1d6110a798da8d58f64ba0c4b4f70..4429d53a1e82b81f0a82e34bf2d6ae463aeeadee
@@@ -24,6 -24,7 +24,7 @@@
  
  static const char pack_usage[] =
    "git pack-objects [{ -q | --progress | --all-progress }]\n"
+   "        [--all-progress-implied]\n"
    "        [--max-pack-size=N] [--local] [--incremental]\n"
    "        [--window=N] [--window-memory=N] [--depth=N]\n"
    "        [--no-reuse-delta] [--no-reuse-object] [--delta-base-offset]\n"
@@@ -1629,8 -1630,6 +1630,8 @@@ static void ll_find_deltas(struct objec
        struct thread_params *p;
        int i, ret, active_threads = 0;
  
 +      if (!delta_search_threads)      /* --threads=0 means autodetect */
 +              delta_search_threads = online_cpus();
        if (delta_search_threads <= 1) {
                find_deltas(list, &list_size, window, depth, processed);
                return;
@@@ -2124,6 -2123,7 +2125,7 @@@ int cmd_pack_objects(int argc, const ch
  {
        int use_internal_rev_list = 0;
        int thin = 0;
+       int all_progress_implied = 0;
        uint32_t i;
        const char **rp_av;
        int rp_ac_alloc = 64;
                        progress = 2;
                        continue;
                }
+               if (!strcmp("--all-progress-implied", arg)) {
+                       all_progress_implied = 1;
+                       continue;
+               }
                if (!strcmp("-q", arg)) {
                        progress = 0;
                        continue;
        if (keep_unreachable && unpack_unreachable)
                die("--keep-unreachable and --unpack-unreachable are incompatible.");
  
 -#ifdef THREADED_DELTA_SEARCH
 -      if (!delta_search_threads)      /* --threads=0 means autodetect */
 -              delta_search_threads = online_cpus();
 -#endif
 -
+       if (progress && all_progress_implied)
+               progress = 2;
        prepare_packed_git();
  
        if (progress)
diff --combined builtin-send-pack.c
index d26997bcfe28f113e3de63b43ecadb812dbd027e,2c4eaae684065df70a435c212ebe3848aa0d9444..8fffdbf20058e9970af4b5e4a14349ecb4ff455c
@@@ -2,11 -2,9 +2,11 @@@
  #include "commit.h"
  #include "refs.h"
  #include "pkt-line.h"
 +#include "sideband.h"
  #include "run-command.h"
  #include "remote.h"
  #include "send-pack.h"
 +#include "quote.h"
  
  static const char send_pack_usage[] =
  "git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
@@@ -40,7 -38,7 +40,7 @@@ static int pack_objects(int fd, struct 
         */
        const char *argv[] = {
                "pack-objects",
-               "--all-progress",
+               "--all-progress-implied",
                "--revs",
                "--stdout",
                NULL,
@@@ -61,7 -59,7 +61,7 @@@
        memset(&po, 0, sizeof(po));
        po.argv = argv;
        po.in = -1;
 -      po.out = fd;
 +      po.out = args->stateless_rpc ? -1 : fd;
        po.git_cmd = 1;
        if (start_command(&po))
                die_errno("git pack-objects failed");
        }
  
        close(po.in);
 +
 +      if (args->stateless_rpc) {
 +              char *buf = xmalloc(LARGE_PACKET_MAX);
 +              while (1) {
 +                      ssize_t n = xread(po.out, buf, LARGE_PACKET_MAX);
 +                      if (n <= 0)
 +                              break;
 +                      send_sideband(fd, -1, buf, n, LARGE_PACKET_MAX);
 +              }
 +              free(buf);
 +              close(po.out);
 +              po.out = -1;
 +      }
 +
        if (finish_command(&po))
                return error("pack-objects died with strange error");
        return 0;
@@@ -262,7 -246,7 +262,7 @@@ static int print_one_push_status(struc
                break;
        case REF_STATUS_REJECT_NONFASTFORWARD:
                print_ref_status('!', "[rejected]", ref, ref->peer_ref,
 -                              "non-fast forward");
 +                              "non-fast-forward");
                break;
        case REF_STATUS_REMOTE_REJECT:
                print_ref_status('!', "[remote rejected]", ref,
@@@ -319,59 -303,6 +319,59 @@@ static int refs_pushed(struct ref *ref
        return 0;
  }
  
 +static void print_helper_status(struct ref *ref)
 +{
 +      struct strbuf buf = STRBUF_INIT;
 +
 +      for (; ref; ref = ref->next) {
 +              const char *msg = NULL;
 +              const char *res;
 +
 +              switch(ref->status) {
 +              case REF_STATUS_NONE:
 +                      res = "error";
 +                      msg = "no match";
 +                      break;
 +
 +              case REF_STATUS_OK:
 +                      res = "ok";
 +                      break;
 +
 +              case REF_STATUS_UPTODATE:
 +                      res = "ok";
 +                      msg = "up to date";
 +                      break;
 +
 +              case REF_STATUS_REJECT_NONFASTFORWARD:
 +                      res = "error";
 +                      msg = "non-fast forward";
 +                      break;
 +
 +              case REF_STATUS_REJECT_NODELETE:
 +              case REF_STATUS_REMOTE_REJECT:
 +                      res = "error";
 +                      break;
 +
 +              case REF_STATUS_EXPECTING_REPORT:
 +              default:
 +                      continue;
 +              }
 +
 +              strbuf_reset(&buf);
 +              strbuf_addf(&buf, "%s %s", res, ref->name);
 +              if (ref->remote_status)
 +                      msg = ref->remote_status;
 +              if (msg) {
 +                      strbuf_addch(&buf, ' ');
 +                      quote_two_c_style(&buf, "", msg, 0);
 +              }
 +              strbuf_addch(&buf, '\n');
 +
 +              safe_write(1, buf.buf, buf.len);
 +      }
 +      strbuf_release(&buf);
 +}
 +
  int send_pack(struct send_pack_args *args,
              int fd[], struct child_process *conn,
              struct ref *remote_refs,
  {
        int in = fd[0];
        int out = fd[1];
 +      struct strbuf req_buf = STRBUF_INIT;
        struct ref *ref;
        int new_refs;
        int ask_for_status_report = 0;
                        char *new_hex = sha1_to_hex(ref->new_sha1);
  
                        if (ask_for_status_report) {
 -                              packet_write(out, "%s %s %s%c%s",
 +                              packet_buf_write(&req_buf, "%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",
 +                              packet_buf_write(&req_buf, "%s %s %s",
                                        old_hex, new_hex, ref->name);
                }
                ref->status = expect_status_report ?
                        REF_STATUS_OK;
        }
  
 -      packet_flush(out);
 +      if (args->stateless_rpc) {
 +              if (!args->dry_run) {
 +                      packet_buf_flush(&req_buf);
 +                      send_sideband(out, -1, req_buf.buf, req_buf.len, LARGE_PACKET_MAX);
 +              }
 +      } else {
 +              safe_write(out, req_buf.buf, req_buf.len);
 +              packet_flush(out);
 +      }
 +      strbuf_release(&req_buf);
 +
        if (new_refs && !args->dry_run) {
                if (pack_objects(out, remote_refs, extra_have, args) < 0) {
                        for (ref = remote_refs; ref; ref = ref->next)
                        return -1;
                }
        }
 +      if (args->stateless_rpc && !args->dry_run)
 +              packet_flush(out);
  
        if (expect_status_report)
                ret = receive_status(in, remote_refs);
        else
                ret = 0;
 +      if (args->stateless_rpc)
 +              packet_flush(out);
  
        if (ret < 0)
                return ret;
@@@ -562,7 -478,6 +562,7 @@@ int cmd_send_pack(int argc, const char 
        struct extra_have_objects extra_have;
        struct ref *remote_refs, *local_refs;
        int ret;
 +      int helper_status = 0;
        int send_all = 0;
        const char *receivepack = "git-receive-pack";
        int flags;
                                args.use_thin_pack = 1;
                                continue;
                        }
 +                      if (!strcmp(arg, "--stateless-rpc")) {
 +                              args.stateless_rpc = 1;
 +                              continue;
 +                      }
 +                      if (!strcmp(arg, "--helper-status")) {
 +                              helper_status = 1;
 +                              continue;
 +                      }
                        usage(send_pack_usage);
                }
                if (!dest) {
                }
        }
  
 -      conn = git_connect(fd, dest, receivepack, args.verbose ? CONNECT_VERBOSE : 0);
 +      if (args.stateless_rpc) {
 +              conn = NULL;
 +              fd[0] = 0;
 +              fd[1] = 1;
 +      } else {
 +              conn = git_connect(fd, dest, receivepack,
 +                      args.verbose ? CONNECT_VERBOSE : 0);
 +      }
  
        memset(&extra_have, 0, sizeof(extra_have));
  
  
        ret = send_pack(&args, fd, conn, remote_refs, &extra_have);
  
 +      if (helper_status)
 +              print_helper_status(remote_refs);
 +
        close(fd[1]);
        close(fd[0]);
  
        ret |= finish_connect(conn);
  
 -      print_push_status(dest, remote_refs);
 +      if (!helper_status)
 +              print_push_status(dest, remote_refs);
  
        if (!args.dry_run && remote) {
                struct ref *ref;
diff --combined git-instaweb.sh
index 622a5f0eb25e3420c085d51fd85944ab1286147e,80a7f74feabf7e8c7a72e1e2e6c2f233e7ba5d7c..ffc2ab62bca8a93b42d74f6b276b1daa8a846f6f
@@@ -73,6 -73,11 +73,11 @@@ resolve_full_httpd () 
  }
  
  start_httpd () {
+       if test -f "$fqgitdir/pid"; then
+               say "Instance already running. Restarting..."
+               stop_httpd
+       fi
        # here $httpd should have a meaningful value
        resolve_full_httpd
  
@@@ -317,21 -322,7 +322,21 @@@ EO
                resolve_full_httpd
                list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/")
                $list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
 -              echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
 +              if test -f "$module_path/mod_cgi.so"
 +              then
 +                      echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
 +              else
 +                      $list_mods | grep 'mod_cgid\.c' >/dev/null 2>&1 || \
 +                      if test -f "$module_path/mod_cgid.so"
 +                      then
 +                              echo "LoadModule cgid_module $module_path/mod_cgid.so" \
 +                                      >> "$conf"
 +                      else
 +                              echo "You have no CGI support!"
 +                              exit 2
 +                      fi
 +                      echo "ScriptSock logs/gitweb.sock" >> "$conf"
 +              fi
                cat >> "$conf" <<EOF
  AddHandler cgi-script .cgi
  <Location /gitweb.cgi>