Merge branch 'js/fetch-progress' (early part)
authorJunio C Hamano <junkio@cox.net>
Mon, 5 Mar 2007 01:31:21 +0000 (17:31 -0800)
committerJunio C Hamano <junkio@cox.net>
Mon, 5 Mar 2007 01:31:21 +0000 (17:31 -0800)
* 'js/fetch-progress' (early part):
Fixup no-progress for fetch & clone
fetch & clone: do not output progress when not on a tty

Conflicts:

git-fetch.sh

1  2 
fetch-pack.c
git-fetch.sh
upload-pack.c
diff --combined fetch-pack.c
index 41bdd27b8fce5dd0656b9dcc71e6768f0b4796c6,84285462714a3eee62915dd677fc06a468526bbb..06f4aeced439312c43f2736a1684f9e22218899b
@@@ -15,8 -15,9 +15,9 @@@ static int quiet
  static int verbose;
  static int fetch_all;
  static int depth;
+ static int no_progress;
  static const char fetch_pack_usage[] =
- "git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]";
+ "git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
  static const char *uploadpack = "git-upload-pack";
  
  #define COMPLETE      (1U << 0)
@@@ -173,12 -174,13 +174,13 @@@ static int find_common(int fd[2], unsig
                }
  
                if (!fetching)
-                       packet_write(fd[1], "want %s%s%s%s%s%s\n",
+                       packet_write(fd[1], "want %s%s%s%s%s%s%s\n",
                                     sha1_to_hex(remote),
                                     (multi_ack ? " multi_ack" : ""),
                                     (use_sideband == 2 ? " side-band-64k" : ""),
                                     (use_sideband == 1 ? " side-band" : ""),
                                     (use_thin_pack ? " thin-pack" : ""),
+                                    (no_progress ? " no-progress" : ""),
                                     " ofs-delta");
                else
                        packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
                int len;
  
                while ((len = packet_read_line(fd[0], line, sizeof(line)))) {
 -                      if (!strncmp("shallow ", line, 8)) {
 +                      if (!prefixcmp(line, "shallow ")) {
                                if (get_sha1_hex(line + 8, sha1))
                                        die("invalid shallow line: %s", line);
                                register_shallow(sha1);
                                continue;
                        }
 -                      if (!strncmp("unshallow ", line, 10)) {
 +                      if (!prefixcmp(line, "unshallow ")) {
                                if (get_sha1_hex(line + 10, sha1))
                                        die("invalid unshallow line: %s", line);
                                if (!lookup_object(sha1))
@@@ -346,7 -348,7 +348,7 @@@ static void filter_refs(struct ref **re
                    check_ref_format(ref->name + 5))
                        ; /* trash */
                else if (fetch_all &&
 -                       (!depth || strncmp(ref->name, "refs/tags/", 10) )) {
 +                       (!depth || prefixcmp(ref->name, "refs/tags/") )) {
                        *newtail = ref;
                        ref->next = NULL;
                        newtail = &ref->next;
@@@ -521,7 -523,7 +523,7 @@@ static int get_pack(int xd[2]
        if (do_keep) {
                *av++ = "index-pack";
                *av++ = "--stdin";
-               if (!quiet)
+               if (!quiet && !no_progress)
                        *av++ = "-v";
                if (use_thin_pack)
                        *av++ = "--fix-thin";
@@@ -683,11 -685,11 +685,11 @@@ int main(int argc, char **argv
                char *arg = argv[i];
  
                if (*arg == '-') {
 -                      if (!strncmp("--upload-pack=", arg, 14)) {
 +                      if (!prefixcmp(arg, "--upload-pack=")) {
                                uploadpack = arg + 14;
                                continue;
                        }
 -                      if (!strncmp("--exec=", arg, 7)) {
 +                      if (!prefixcmp(arg, "--exec=")) {
                                uploadpack = arg + 7;
                                continue;
                        }
                                verbose = 1;
                                continue;
                        }
 -                      if (!strncmp("--depth=", arg, 8)) {
 +                      if (!prefixcmp(arg, "--depth=")) {
                                depth = strtol(arg + 8, NULL, 0);
                                if (stat(git_path("shallow"), &st))
                                        st.st_mtime = 0;
                                continue;
                        }
+                       if (!strcmp("--no-progress", arg)) {
+                               no_progress = 1;
+                               continue;
+                       }
                        usage(fetch_pack_usage);
                }
                dest = arg;
diff --combined git-fetch.sh
index 59bee5db0f0738cd6d43772e7279edf726a0b7d1,851ed6b6466995ef36c02e88a3b1b161f4008471..5ae0d28cc09a0b3935262a542c9811b66eb5b85e
@@@ -24,6 -24,8 +24,8 @@@ update_head_ok
  exec=
  keep=
  shallow_depth=
+ no_progress=
+ test -t 1 || no_progress=--no-progress
  while case "$#" in 0) break ;; esac
  do
        case "$1" in
@@@ -243,15 -245,6 +245,15 @@@ the
        orig_head=$(git-rev-parse --verify HEAD 2>/dev/null)
  fi
  
 +# Allow --notags from remote.$1.tagopt
 +case "$tags$no_tags" in
 +'')
 +      case "$(git-config --get "remote.$1.tagopt")" in
 +      --no-tags)
 +              no_tags=t ;;
 +      esac
 +esac
 +
  # If --tags (and later --heads or --all) is specified, then we are
  # not talking about defaults stored in Pull: line of remotes or
  # branches file, and just fetch those and refspecs explicitly given.
@@@ -386,15 -379,9 +388,16 @@@ fetch_main () 
      ( : subshell because we muck with IFS
        IFS="   $LF"
        (
-         git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref ||
 +      if test -f "$remote" ; then
 +          test -n "$shallow_depth" &&
 +              die "shallow clone with bundle is not supported"
 +          git-bundle unbundle "$remote" $rref ||
 +          echo failed "$remote"
 +      else
+         git-fetch-pack --thin $exec $keep $shallow_depth $no_progress \
+               "$remote" $rref ||
          echo failed "$remote"
 +      fi
        ) |
        (
        trap '
diff --combined upload-pack.c
index 804bbb6c9eb788714afb493e331341206cebaaf3,d9907cac9596beda62ecbf7d1d997d76e96def9a..498bf50eb86f9e437dae89fc631499b73a8ec116
@@@ -26,7 -26,7 +26,7 @@@ static const char upload_pack_usage[] 
  static unsigned long oldest_have;
  
  static int multi_ack, nr_our_refs;
- static int use_thin_pack, use_ofs_delta;
+ static int use_thin_pack, use_ofs_delta, no_progress;
  static struct object_array have_obj;
  static struct object_array want_obj;
  static unsigned int timeout;
@@@ -164,6 -164,9 +164,9 @@@ static void create_pack_file(void
                die("git-upload-pack: unable to fork git-pack-objects");
        }
        if (!pid_pack_objects) {
+               const char *argv[10];
+               int i = 0;
                dup2(lp_pipe[0], 0);
                dup2(pu_pipe[1], 1);
                dup2(pe_pipe[1], 2);
                close(pu_pipe[1]);
                close(pe_pipe[0]);
                close(pe_pipe[1]);
-               execl_git_cmd("pack-objects", "--stdout", "--progress",
-                             use_ofs_delta ? "--delta-base-offset" : NULL,
-                             NULL);
+               argv[i++] = "pack-objects";
+               argv[i++] = "--stdout";
+               if (!no_progress)
+                       argv[i++] = "--progress";
+               if (use_ofs_delta)
+                       argv[i++] = "--delta-base-offset";
+               argv[i++] = NULL;
+               execv_git_cmd(argv);
                kill(pid_rev_list, SIGKILL);
                die("git-upload-pack: unable to exec git-pack-objects");
        }
@@@ -455,7 -465,7 +465,7 @@@ static int get_common_commits(void
                        continue;
                }
                len = strip(line, len);
 -              if (!strncmp(line, "have ", 5)) {
 +              if (!prefixcmp(line, "have ")) {
                        switch (got_sha1(line+5, sha1)) {
                        case -1: /* they have what we do not */
                                if (multi_ack && ok_to_give_up())
@@@ -502,7 -512,7 +512,7 @@@ static void receive_needs(void
                if (!len)
                        break;
  
 -              if (!strncmp("shallow ", line, 8)) {
 +              if (!prefixcmp(line, "shallow ")) {
                        unsigned char sha1[20];
                        struct object *object;
                        use_thin_pack = 0;
                        add_object_array(object, NULL, &shallows);
                        continue;
                }
 -              if (!strncmp("deepen ", line, 7)) {
 +              if (!prefixcmp(line, "deepen ")) {
                        char *end;
                        use_thin_pack = 0;
                        depth = strtol(line + 7, &end, 0);
                                die("Invalid deepen: %s", line);
                        continue;
                }
 -              if (strncmp("want ", line, 5) ||
 +              if (prefixcmp(line, "want ") ||
                    get_sha1_hex(line+5, sha1_buf))
                        die("git-upload-pack: protocol error, "
                            "expected to get sha, not '%s'", line);
                        use_sideband = LARGE_PACKET_MAX;
                else if (strstr(line+45, "side-band"))
                        use_sideband = DEFAULT_PACKET_MAX;
+               if (strstr(line+45, "no-progress"))
+                       no_progress = 1;
  
                /* We have sent all our refs already, and the other end
                 * should have chosen out of them; otherwise they are
  static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
  {
        static const char *capabilities = "multi_ack thin-pack side-band"
-               " side-band-64k ofs-delta shallow";
+               " side-band-64k ofs-delta shallow no-progress";
        struct object *o = parse_object(sha1);
  
        if (!o)
@@@ -656,7 -668,7 +668,7 @@@ int main(int argc, char **argv
                        strict = 1;
                        continue;
                }
 -              if (!strncmp(arg, "--timeout=", 10)) {
 +              if (!prefixcmp(arg, "--timeout=")) {
                        timeout = atoi(arg+10);
                        continue;
                }