From: Junio C Hamano Date: Mon, 5 Mar 2007 01:31:21 +0000 (-0800) Subject: Merge branch 'js/fetch-progress' (early part) X-Git-Tag: v1.5.1-rc1~96 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3ddad98b74924d76116d05e7601ab1e163d68500?ds=inline;hp=-c Merge branch 'js/fetch-progress' (early part) * '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 --- 3ddad98b74924d76116d05e7601ab1e163d68500 diff --combined fetch-pack.c index 41bdd27b8f,8428546271..06f4aeced4 --- a/fetch-pack.c +++ b/fetch-pack.c @@@ -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=] [--depth=] [-v] [:] [...]"; + "git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=] [--depth=] [--no-progress] [-v] [:] [...]"; 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)); @@@ -198,13 -200,13 +200,13 @@@ 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; } @@@ -712,12 -714,16 +714,16 @@@ 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 59bee5db0f,851ed6b646..5ae0d28cc0 --- a/git-fetch.sh +++ b/git-fetch.sh @@@ -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" ( + 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 "$remote" $rref || + git-fetch-pack --thin $exec $keep $shallow_depth $no_progress \ + "$remote" $rref || echo failed "$remote" + fi ) | ( trap ' diff --combined upload-pack.c index 804bbb6c9e,d9907cac95..498bf50eb8 --- a/upload-pack.c +++ b/upload-pack.c @@@ -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); @@@ -174,9 -177,16 +177,16 @@@ 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; @@@ -515,7 -525,7 +525,7 @@@ 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); @@@ -523,7 -533,7 +533,7 @@@ 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); @@@ -537,6 -547,8 +547,8 @@@ 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 @@@ -605,7 -617,7 +617,7 @@@ 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; }