Merge branch 'tr/commit-slab-cleanup'
[gitweb.git] / builtin / fetch.c
index 887fa3e5810356824e3b16d6bd48b67c051b1eff..3d978eb58ec5cc1e2629db10562319c666bc031e 100644 (file)
@@ -360,9 +360,7 @@ static struct ref *get_ref_map(struct transport *transport,
                tail = &rm->next;
        }
 
-       ref_remove_duplicates(ref_map);
-
-       return ref_map;
+       return ref_remove_duplicates(ref_map);
 }
 
 #define STORE_REF_ERROR_OTHER 1
@@ -850,38 +848,17 @@ static int do_fetch(struct transport *transport,
                goto cleanup;
        }
        if (prune) {
-               struct refspec *prune_refspecs;
-               int prune_refspec_count;
-
+               /*
+                * We only prune based on refspecs specified
+                * explicitly (via command line or configuration); we
+                * don't care whether --tags was specified.
+                */
                if (ref_count) {
-                       prune_refspecs = refs;
-                       prune_refspec_count = ref_count;
-               } else {
-                       prune_refspecs = transport->remote->fetch;
-                       prune_refspec_count = transport->remote->fetch_refspec_nr;
-               }
-
-               if (tags == TAGS_SET) {
-                       /*
-                        * --tags was specified.  Pretend that the user also
-                        * gave us the canonical tags refspec
-                        */
-                       const char *tags_str = "refs/tags/*:refs/tags/*";
-                       struct refspec *tags_refspec, *refspec;
-
-                       /* Copy the refspec and add the tags to it */
-                       refspec = xcalloc(prune_refspec_count + 1, sizeof(*refspec));
-                       tags_refspec = parse_fetch_refspec(1, &tags_str);
-                       memcpy(refspec, prune_refspecs, prune_refspec_count * sizeof(*refspec));
-                       memcpy(&refspec[prune_refspec_count], tags_refspec, sizeof(*refspec));
-
-                       prune_refs(refspec, prune_refspec_count + 1, ref_map);
-
-                       /* The rest of the strings belong to fetch_one */
-                       free_refspec(1, tags_refspec);
-                       free(refspec);
+                       prune_refs(refs, ref_count, ref_map);
                } else {
-                       prune_refs(prune_refspecs, prune_refspec_count, ref_map);
+                       prune_refs(transport->remote->fetch,
+                                  transport->remote->fetch_refspec_nr,
+                                  ref_map);
                }
        }
        free_refs(ref_map);
@@ -957,8 +934,8 @@ static void add_options_to_argv(struct argv_array *argv)
 {
        if (dry_run)
                argv_array_push(argv, "--dry-run");
-       if (prune > 0)
-               argv_array_push(argv, "--prune");
+       if (prune != -1)
+               argv_array_push(argv, prune ? "--prune" : "--no-prune");
        if (update_head_ok)
                argv_array_push(argv, "--update-head-ok");
        if (force)