Merge branch 'lt/objlist' into next
authorJunio C Hamano <junkio@cox.net>
Tue, 20 Jun 2006 01:47:29 +0000 (18:47 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 20 Jun 2006 01:47:29 +0000 (18:47 -0700)
* lt/objlist:
Add "named object array" concept
xdiff: minor changes to match libxdiff-0.21
fix rfc2047 formatter.
Fix t8001-annotate and t8002-blame for ActiveState Perl
Add specialized object allocator

1  2 
Makefile
diff-lib.c
http-push.c
diff --combined Makefile
index 99c9ec2054a54fea5abc3a584d808b0944a5db58,0887945ffa6977e49214f89be93fff4da1cd6048..22bb47319ef85da330f88aa6896ab5402c193e66
+++ b/Makefile
@@@ -144,33 -144,34 +144,33 @@@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH
  
  # The ones that do not have to link with lcrypto, lz nor xdiff.
  SIMPLE_PROGRAMS = \
 -      git-mailsplit$X \
 -      git-stripspace$X git-daemon$X
 +      git-daemon$X
  
  # ... and all the rest that could be moved out of bindir to gitexecdir
  PROGRAMS = \
        git-checkout-index$X git-clone-pack$X \
        git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
        git-hash-object$X git-index-pack$X git-local-fetch$X \
 -      git-mailinfo$X git-merge-base$X \
 +      git-merge-base$X \
        git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
        git-peek-remote$X git-prune-packed$X git-receive-pack$X \
        git-send-pack$X git-shell$X \
        git-show-index$X git-ssh-fetch$X \
        git-ssh-upload$X git-unpack-file$X \
 -      git-unpack-objects$X git-update-index$X git-update-server-info$X \
 -      git-upload-pack$X git-verify-pack$X git-write-tree$X \
 -      git-update-ref$X git-symbolic-ref$X \
 +      git-unpack-objects$X git-update-server-info$X \
 +      git-upload-pack$X git-verify-pack$X \
 +      git-symbolic-ref$X \
        git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
        git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
  
 -BUILT_INS = git-log$X git-whatchanged$X git-show$X \
 -      git-count-objects$X git-diff$X git-push$X \
 -      git-grep$X git-add$X git-rm$X git-rev-list$X \
 -      git-check-ref-format$X git-rev-parse$X \
 +BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \
 +      git-count-objects$X git-diff$X git-push$X git-mailsplit$X \
 +      git-grep$X git-add$X git-rm$X git-rev-list$X git-stripspace$X \
 +      git-check-ref-format$X git-rev-parse$X git-mailinfo$X \
        git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
        git-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \
 -      git-read-tree$X git-commit-tree$X \
 -      git-apply$X git-show-branch$X git-diff-files$X \
 +      git-read-tree$X git-commit-tree$X git-write-tree$X \
 +      git-apply$X git-show-branch$X git-diff-files$X git-update-index$X \
        git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X
  
  # what 'all' will build and 'install' will install, in gitexecdir
@@@ -215,19 -216,18 +215,19 @@@ LIB_OBJS = 
        server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
        tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
        fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
-       $(DIFF_OBJS)
+       alloc.o $(DIFF_OBJS)
  
  BUILTIN_OBJS = \
        builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
        builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o \
        builtin-rm.o builtin-init-db.o builtin-rev-parse.o \
 -      builtin-tar-tree.o builtin-upload-tar.o \
 -      builtin-ls-files.o builtin-ls-tree.o \
 -      builtin-read-tree.o builtin-commit-tree.o \
 +      builtin-tar-tree.o builtin-upload-tar.o builtin-update-index.o \
 +      builtin-ls-files.o builtin-ls-tree.o builtin-write-tree.o \
 +      builtin-read-tree.o builtin-commit-tree.o builtin-mailinfo.o \
        builtin-apply.o builtin-show-branch.o builtin-diff-files.o \
        builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o \
 -      builtin-cat-file.o
 +      builtin-cat-file.o builtin-mailsplit.o builtin-stripspace.o \
 +      builtin-update-ref.o
  
  GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
  LIBS = $(GITLIBS) -lz
@@@ -380,7 -380,9 +380,7 @@@ ifdef NEEDS_LIBICON
        else
                ICONV_LINK =
        endif
 -      LIB_4_ICONV = $(ICONV_LINK) -liconv
 -else
 -      LIB_4_ICONV =
 +      LIBS += $(ICONV_LINK) -liconv
  endif
  ifdef NEEDS_SOCKET
        LIBS += -lsocket
@@@ -563,6 -565,10 +563,6 @@@ $(SIMPLE_PROGRAMS) : git-%$X : %.
        $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
                $(LIB_FILE) $(SIMPLE_LIB)
  
 -git-mailinfo$X: mailinfo.o $(LIB_FILE)
 -      $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 -              $(LIB_FILE) $(SIMPLE_LIB) $(LIB_4_ICONV)
 -
  git-local-fetch$X: fetch.o
  git-ssh-fetch$X: rsh.o fetch.o
  git-ssh-upload$X: rsh.o
diff --combined diff-lib.c
index fdc11732dfbe201119182ff701f7fd40d74d1017,d93cd55510d702ae6c5104ae9f896264ddc98f80..116b5a9d6834c9517ccc2202510b37a1e1d863a5
@@@ -34,23 -34,21 +34,23 @@@ int run_diff_files(struct rev_info *rev
                        continue;
  
                if (ce_stage(ce)) {
 -                      struct {
 -                              struct combine_diff_path p;
 -                              struct combine_diff_parent filler[5];
 -                      } combine;
 +                      struct combine_diff_path *dpath;
                        int num_compare_stages = 0;
 +                      size_t path_len;
  
 -                      combine.p.next = NULL;
 -                      combine.p.len = ce_namelen(ce);
 -                      combine.p.path = xmalloc(combine.p.len + 1);
 -                      memcpy(combine.p.path, ce->name, combine.p.len);
 -                      combine.p.path[combine.p.len] = 0;
 -                      combine.p.mode = 0;
 -                      memset(combine.p.sha1, 0, 20);
 -                      memset(&combine.p.parent[0], 0,
 -                             sizeof(combine.filler));
 +                      path_len = ce_namelen(ce);
 +
 +                      dpath = xmalloc (combine_diff_path_size (5, path_len));
 +                      dpath->path = (char *) &(dpath->parent[5]);
 +
 +                      dpath->next = NULL;
 +                      dpath->len = path_len;
 +                      memcpy(dpath->path, ce->name, path_len);
 +                      dpath->path[path_len] = '\0';
 +                      dpath->mode = 0;
 +                      memset(dpath->sha1, 0, 20);
 +                      memset(&(dpath->parent[0]), 0,
 +                                      sizeof(struct combine_diff_parent)*5);
  
                        while (i < entries) {
                                struct cache_entry *nce = active_cache[i];
                                if (2 <= stage) {
                                        int mode = ntohl(nce->ce_mode);
                                        num_compare_stages++;
 -                                      memcpy(combine.p.parent[stage-2].sha1,
 +                                      memcpy(dpath->parent[stage-2].sha1,
                                               nce->sha1, 20);
 -                                      combine.p.parent[stage-2].mode =
 +                                      dpath->parent[stage-2].mode =
                                                canon_mode(mode);
 -                                      combine.p.parent[stage-2].status =
 +                                      dpath->parent[stage-2].status =
                                                DIFF_STATUS_MODIFIED;
                                }
  
                        i--;
  
                        if (revs->combine_merges && num_compare_stages == 2) {
 -                              show_combined_diff(&combine.p, 2,
 +                              show_combined_diff(dpath, 2,
                                                   revs->dense_combined_merges,
                                                   revs);
 -                              free(combine.p.path);
 +                              free(dpath);
                                continue;
                        }
 -                      free(combine.p.path);
 +                      free(dpath);
 +                      dpath = NULL;
  
                        /*
                         * Show the diff for the 'ce' if we found the one
@@@ -332,8 -329,8 +332,8 @@@ int run_diff_index(struct rev_info *rev
        }
        mark_merge_entries();
  
-       ent = revs->pending_objects->item;
-       tree_name = revs->pending_objects->name;
+       ent = revs->pending.objects[0].item;
+       tree_name = revs->pending.objects[0].name;
        tree = parse_tree_indirect(ent->sha1);
        if (!tree)
                return error("bad tree object %s", tree_name);
diff --combined http-push.c
index aaf155c5bcb5b7587afa1a3063316d3183020984,0f02a55ddf15ad86f9e3e9e2629fe2d9ca1ff78c..2e7d02281919841c4f3af38ca49939039573c2b0
@@@ -1077,14 -1077,13 +1077,14 @@@ static int fetch_indices(void
  
  static inline int needs_quote(int ch)
  {
 -      switch (ch) {
 -      case '/': case '-': case '.':
 -      case 'A'...'Z': case 'a'...'z': case '0'...'9':
 +      if (((ch >= 'A') && (ch <= 'Z'))
 +                      || ((ch >= 'a') && (ch <= 'z'))
 +                      || ((ch >= '0') && (ch <= '9'))
 +                      || (ch == '/')
 +                      || (ch == '-')
 +                      || (ch == '.'))
                return 0;
 -      default:
 -              return 1;
 -      }
 +      return 1;
  }
  
  static inline int hex(int v)
@@@ -1172,7 -1171,7 +1172,7 @@@ static void one_remote_object(const cha
  
        obj->flags |= REMOTE;
        if (!object_list_contains(objects, obj))
-               add_object(obj, &objects, NULL, "");
+               object_list_insert(obj, &objects);
  }
  
  static void handle_lockprop_ctx(struct xml_ctx *ctx, int tag_closed)
@@@ -1700,6 -1699,15 +1700,15 @@@ static int locking_available(void
        return lock_flags;
  }
  
+ struct object_list **add_one_object(struct object *obj, struct object_list **p)
+ {
+       struct object_list *entry = xmalloc(sizeof(struct object_list));
+       entry->item = obj;
+       entry->next = *p;
+       *p = entry;
+       return &entry->next;
+ }
  static struct object_list **process_blob(struct blob *blob,
                                         struct object_list **p,
                                         struct name_path *path,
                return p;
  
        obj->flags |= SEEN;
-       name = strdup(name);
-       return add_object(obj, p, path, name);
+       return add_one_object(obj, p);
  }
  
  static struct object_list **process_tree(struct tree *tree,
  
        obj->flags |= SEEN;
        name = strdup(name);
-       p = add_object(obj, p, NULL, name);
+       p = add_one_object(obj, p);
        me.up = path;
        me.elem = name;
        me.elem_len = strlen(name);
  
  static int get_delta(struct rev_info *revs, struct remote_lock *lock)
  {
+       int i;
        struct commit *commit;
-       struct object_list **p = &objects, *pending;
+       struct object_list **p = &objects;
        int count = 0;
  
        while ((commit = get_revision(revs)) != NULL) {
                        count += add_send_request(&commit->object, lock);
        }
  
-       for (pending = revs->pending_objects; pending; pending = pending->next) {
-               struct object *obj = pending->item;
-               const char *name = pending->name;
+       for (i = 0; i < revs->pending.nr; i++) {
+               struct object_array_entry *entry = revs->pending.objects + i;
+               struct object *obj = entry->item;
+               const char *name = entry->name;
  
                if (obj->flags & (UNINTERESTING | SEEN))
                        continue;
                if (obj->type == TYPE_TAG) {
                        obj->flags |= SEEN;
-                       p = add_object(obj, p, NULL, name);
+                       p = add_one_object(obj, p);
                        continue;
                }
                if (obj->type == TYPE_TREE) {