Code

Merge branch 'gs/pretty-hexval'
[git.git] / builtin-fetch.c
index 26c3d74b76de701a8e1a5e0c7031751599c1487f..5841b3e51a5c908a32761398d6237968ddac4d46 100644 (file)
@@ -40,6 +40,8 @@ static struct option builtin_fetch_options[] = {
                    "force overwrite of local branch"),
        OPT_SET_INT('t', "tags", &tags,
                    "fetch all tags and associated objects", TAGS_SET),
+       OPT_SET_INT('n', NULL, &tags,
+                   "do not fetch all tags (--no-tags)", TAGS_UNSET),
        OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
        OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
                    "allow updating of HEAD ref"),
@@ -555,6 +557,8 @@ static int do_fetch(struct transport *transport,
                        read_ref(rm->peer_ref->name, rm->peer_ref->old_sha1);
        }
 
+       if (tags == TAGS_DEFAULT && autotags)
+               transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
        if (fetch_refs(transport, ref_map)) {
                free_refs(ref_map);
                return 1;
@@ -568,6 +572,7 @@ static int do_fetch(struct transport *transport,
                ref_map = NULL;
                find_non_local_tags(transport, &ref_map, &tail);
                if (ref_map) {
+                       transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
                        transport_set_option(transport, TRANS_OPT_DEPTH, "0");
                        fetch_refs(transport, ref_map);
                }
@@ -632,6 +637,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                        if (!strcmp(argv[i], "tag")) {
                                char *ref;
                                i++;
+                               if (i >= argc)
+                                       die("You need to specify a tag name.");
                                ref = xmalloc(strlen(argv[i]) * 2 + 22);
                                strcpy(ref, "refs/tags/");
                                strcat(ref, argv[i]);
@@ -647,5 +654,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 
        signal(SIGINT, unlock_pack_on_signal);
        atexit(unlock_pack);
-       return do_fetch(transport, parse_ref_spec(ref_nr, refs), ref_nr);
+       return do_fetch(transport,
+                       parse_fetch_refspec(ref_nr, refs), ref_nr);
 }