Merge branch 'rs/get-tagged-oid'
authorJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2019 04:19:29 +0000 (13:19 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2019 04:19:29 +0000 (13:19 +0900)
Code cleanup.

* rs/get-tagged-oid:
  use get_tagged_oid()
  tag: factor out get_tagged_oid()

1  2 
packfile.c
ref-filter.c
revision.c

diff --combined packfile.c
@@@ -17,7 -17,6 +17,7 @@@
  #include "object-store.h"
  #include "midx.h"
  #include "commit-graph.h"
 +#include "promisor-remote.h"
  
  char *odb_pack_name(struct strbuf *buf,
                    const unsigned char *sha1,
@@@ -288,6 -287,13 +288,6 @@@ static int unuse_one_window(struct pack
        return 0;
  }
  
 -void release_pack_memory(size_t need)
 -{
 -      size_t cur = pack_mapped;
 -      while (need >= (cur - pack_mapped) && unuse_one_window(NULL))
 -              ; /* nothing */
 -}
 -
  void close_pack_windows(struct packed_git *p)
  {
        while (p->windows) {
@@@ -704,12 -710,23 +704,12 @@@ void unuse_pack(struct pack_window **w_
        }
  }
  
 -static void try_to_free_pack_memory(size_t size)
 -{
 -      release_pack_memory(size);
 -}
 -
  struct packed_git *add_packed_git(const char *path, size_t path_len, int local)
  {
 -      static int have_set_try_to_free_routine;
        struct stat st;
        size_t alloc;
        struct packed_git *p;
  
 -      if (!have_set_try_to_free_routine) {
 -              have_set_try_to_free_routine = 1;
 -              set_try_to_free_routine(try_to_free_pack_memory);
 -      }
 -
        /*
         * Make sure a corresponding .pack file exists and that
         * the index looks sane.
@@@ -2122,7 -2139,7 +2122,7 @@@ static int add_promisor_object(const st
                        oidset_insert(set, &parents->item->object.oid);
        } else if (obj->type == OBJ_TAG) {
                struct tag *tag = (struct tag *) obj;
-               oidset_insert(set, &tag->tagged->oid);
+               oidset_insert(set, get_tagged_oid(tag));
        }
        return 0;
  }
@@@ -2133,7 -2150,7 +2133,7 @@@ int is_promisor_object(const struct obj
        static int promisor_objects_prepared;
  
        if (!promisor_objects_prepared) {
 -              if (repository_format_partial_clone) {
 +              if (has_promisor_remote()) {
                        for_each_packed_object(add_promisor_object,
                                               &promisor_objects,
                                               FOR_EACH_OBJECT_PROMISOR_ONLY);
diff --combined ref-filter.c
@@@ -1028,7 -1028,7 +1028,7 @@@ static const char *copy_name(const cha
                if (!strncmp(cp, " <", 2))
                        return xmemdupz(buf, cp - buf);
        }
 -      return "";
 +      return xstrdup("");
  }
  
  static const char *copy_email(const char *buf)
        const char *email = strchr(buf, '<');
        const char *eoemail;
        if (!email)
 -              return "";
 +              return xstrdup("");
        eoemail = strchr(email, '>');
        if (!eoemail)
 -              return "";
 +              return xstrdup("");
        return xmemdupz(email, eoemail + 1 - email);
  }
  
@@@ -1766,7 -1766,7 +1766,7 @@@ static int populate_value(struct ref_ar
         * If it is a tag object, see if we use a value that derefs
         * the object, and if we do grab the object it refers to.
         */
-       oi_deref.oid = ((struct tag *)obj)->tagged->oid;
+       oi_deref.oid = *get_tagged_oid((struct tag *)obj);
  
        /*
         * NEEDSWORK: This derefs tag only once, which
@@@ -1997,7 -1997,7 +1997,7 @@@ static const struct object_id *match_po
        if (!obj)
                die(_("malformed object at '%s'"), refname);
        if (obj->type == OBJ_TAG)
-               tagged_oid = &((struct tag *)obj)->tagged->oid;
+               tagged_oid = get_tagged_oid((struct tag *)obj);
        if (tagged_oid && oid_array_lookup(points_at, tagged_oid) >= 0)
                return tagged_oid;
        return NULL;
diff --combined revision.c
@@@ -404,9 -404,7 +404,7 @@@ static struct commit *handle_commit(str
                struct tag *tag = (struct tag *) object;
                if (revs->tag_objects && !(flags & UNINTERESTING))
                        add_pending_object(revs, object, tag->tag);
-               if (!tag->tagged)
-                       die("bad tag");
-               object = parse_object(revs->repo, &tag->tagged->oid);
+               object = parse_object(revs->repo, get_tagged_oid(tag));
                if (!object) {
                        if (revs->ignore_missing_links || (flags & UNINTERESTING))
                                return NULL;
@@@ -2523,7 -2521,6 +2521,7 @@@ int setup_revisions(int argc, const cha
        int i, flags, left, seen_dashdash, got_rev_arg = 0, revarg_opt;
        struct argv_array prune_data = ARGV_ARRAY_INIT;
        const char *submodule = NULL;
 +      int seen_end_of_options = 0;
  
        if (opt)
                submodule = opt->submodule;
                revarg_opt |= REVARG_CANNOT_BE_FILENAME;
        for (left = i = 1; i < argc; i++) {
                const char *arg = argv[i];
 -              if (*arg == '-') {
 +              if (!seen_end_of_options && *arg == '-') {
                        int opts;
  
                        opts = handle_revision_pseudo_opt(submodule,
                                continue;
                        }
  
 +                      if (!strcmp(arg, "--end-of-options")) {
 +                              seen_end_of_options = 1;
 +                              continue;
 +                      }
 +
                        opts = handle_revision_opt(revs, argc - i, argv + i,
                                                   &left, argv, opt);
                        if (opts > 0) {