Merge branch 'lf/bundle-exclusion' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 19 Sep 2014 21:05:11 +0000 (14:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Sep 2014 21:05:11 +0000 (14:05 -0700)
* lf/bundle-exclusion:
bundle: fix exclusion of annotated tags

1  2 
bundle.c
diff --combined bundle.c
index 71a21a67fa6bc5ce718dfc6593035f577b2dbc15,8b3b80eddf01fb413a0267a686caae657dc1b89f..b708906cdbd2a14d0e5bcd1e1288c78777cf6a5e
+++ b/bundle.c
@@@ -7,15 -7,18 +7,15 @@@
  #include "list-objects.h"
  #include "run-command.h"
  #include "refs.h"
 +#include "argv-array.h"
  
  static const char bundle_signature[] = "# v2 git bundle\n";
  
  static void add_to_ref_list(const unsigned char *sha1, const char *name,
                struct ref_list *list)
  {
 -      if (list->nr + 1 >= list->alloc) {
 -              list->alloc = alloc_nr(list->nr + 1);
 -              list->list = xrealloc(list->list,
 -                              list->alloc * sizeof(list->list[0]));
 -      }
 -      memcpy(list->list[list->nr].sha1, sha1, 20);
 +      ALLOC_GROW(list->list, list->nr + 1, list->alloc);
 +      hashcpy(list->list[list->nr].sha1, sha1);
        list->list[list->nr].name = xstrdup(name);
        list->nr++;
  }
@@@ -120,7 -123,6 +120,7 @@@ static int list_refs(struct ref_list *r
        return 0;
  }
  
 +/* Remember to update object flag allocation in object.h */
  #define PREREQ_MARK (1u<<16)
  
  int verify_bundle(struct bundle_header *header, int verbose)
@@@ -221,8 -223,8 +221,8 @@@ static int is_tag_in_date_range(struct 
        line = memmem(buf, size, "\ntagger ", 8);
        if (!line++)
                return 1;
-       lineend = memchr(line, buf + size - line, '\n');
-       line = memchr(line, lineend ? lineend - line : buf + size - line, '>');
+       lineend = memchr(line, '\n', buf + size - line);
+       line = memchr(line, '>', lineend ? lineend - line : buf + size - line);
        if (!line++)
                return 1;
        date = strtoul(line, NULL, 10);
  }
  
  int create_bundle(struct bundle_header *header, const char *path,
 -              int argc, const char **argv)
 +                int argc, const char **argv)
  {
        static struct lock_file lock;
        int bundle_fd = -1;
        int bundle_to_stdout;
 -      const char **argv_boundary = xmalloc((argc + 4) * sizeof(const char *));
 -      const char **argv_pack = xmalloc(6 * sizeof(const char *));
        int i, ref_count = 0;
        struct strbuf buf = STRBUF_INIT;
        struct rev_info revs;
        init_revisions(&revs, NULL);
  
        /* write prerequisites */
 -      memcpy(argv_boundary + 3, argv + 1, argc * sizeof(const char *));
 -      argv_boundary[0] = "rev-list";
 -      argv_boundary[1] = "--boundary";
 -      argv_boundary[2] = "--pretty=oneline";
 -      argv_boundary[argc + 2] = NULL;
        memset(&rls, 0, sizeof(rls));
 -      rls.argv = argv_boundary;
 +      argv_array_pushl(&rls.args,
 +                       "rev-list", "--boundary", "--pretty=oneline",
 +                       NULL);
 +      for (i = 1; i < argc; i++)
 +              argv_array_push(&rls.args, argv[i]);
        rls.out = -1;
        rls.git_cmd = 1;
        if (start_command(&rls))
        write_or_die(bundle_fd, "\n", 1);
  
        /* write pack */
 -      argv_pack[0] = "pack-objects";
 -      argv_pack[1] = "--all-progress-implied";
 -      argv_pack[2] = "--stdout";
 -      argv_pack[3] = "--thin";
 -      argv_pack[4] = "--delta-base-offset";
 -      argv_pack[5] = NULL;
        memset(&rls, 0, sizeof(rls));
 -      rls.argv = argv_pack;
 +      argv_array_pushl(&rls.args,
 +                       "pack-objects", "--all-progress-implied",
 +                       "--stdout", "--thin", "--delta-base-offset",
 +                       NULL);
        rls.in = -1;
        rls.out = bundle_fd;
        rls.git_cmd = 1;