Merge branch 'jc/upload-corrupt' into next
authorJunio C Hamano <junkio@cox.net>
Wed, 21 Jun 2006 09:50:59 +0000 (02:50 -0700)
committerJunio C Hamano <junkio@cox.net>
Wed, 21 Jun 2006 09:50:59 +0000 (02:50 -0700)
* jc/upload-corrupt:
upload-pack/fetch-pack: support side-band communication
Retire git-clone-pack
upload-pack: prepare for sideband message support.
upload-pack: avoid sending an incomplete pack upon failure
Fix possible out-of-bounds array access

1  2 
Makefile
builtin-grep.c
diff --combined Makefile
index 22bb47319ef85da330f88aa6896ab5402c193e66,ae5e8d790a8b148b95cfce03afab94e97315110a..de7614174215feaafb20bdaa350b916e76f7cc43
+++ 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-checkout-index$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
@@@ -221,13 -222,12 +221,13 @@@ 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 builtin-grep.c
index 6a240fb6e908d95a1981ea2437fcd4bea27a6ba9,f7767bb4eeacf4d4c06ef54e6bb3f4099e96d198..2e7986cecefc964f665b10d363569951c1f40293
@@@ -29,10 -29,11 +29,11 @@@ static int pathspec_matches(const char 
                int matchlen = strlen(match);
                const char *cp, *meta;
  
-               if ((matchlen <= namelen) &&
-                   !strncmp(name, match, matchlen) &&
-                   (match[matchlen-1] == '/' ||
-                    name[matchlen] == '\0' || name[matchlen] == '/'))
+               if (!matchlen ||
+                   ((matchlen <= namelen) &&
+                    !strncmp(name, match, matchlen) &&
+                    (match[matchlen-1] == '/' ||
+                     name[matchlen] == '\0' || name[matchlen] == '/')))
                        return 1;
                if (!fnmatch(match, name, 0))
                        return 1;
@@@ -657,7 -658,7 +658,7 @@@ int cmd_grep(int argc, const char **arg
        int cached = 0;
        int seen_dashdash = 0;
        struct grep_opt opt;
 -      struct object_list *list, **tail, *object_list = NULL;
 +      struct object_array list = { 0, 0, NULL };
        const char *prefix = setup_git_directory();
        const char **paths = NULL;
        int i;
         * that continues up to the -- (if exists), and then paths.
         */
  
 -      tail = &object_list;
        while (1 < argc) {
                const char *arg = argv[1];
                argc--; argv++;
                /* Is it a rev? */
                if (!get_sha1(arg, sha1)) {
                        struct object *object = parse_object(sha1);
 -                      struct object_list *elem;
                        if (!object)
                                die("bad object %s", arg);
 -                      elem = object_list_insert(object, tail);
 -                      elem->name = arg;
 -                      tail = &elem->next;
 +                      add_object_array(object, arg, &list);
                        continue;
                }
                if (!strcmp(arg, "--")) {
                paths[1] = NULL;
        }
  
 -      if (!object_list)
 +      if (!list.nr)
                return !grep_cache(&opt, paths, cached);
  
        if (cached)
                die("both --cached and trees are given.");
  
 -      for (list = object_list; list; list = list->next) {
 +      for (i = 0; i < list.nr; i++) {
                struct object *real_obj;
 -              real_obj = deref_tag(list->item, NULL, 0);
 -              if (grep_object(&opt, paths, real_obj, list->name))
 +              real_obj = deref_tag(list.objects[i].item, NULL, 0);
 +              if (grep_object(&opt, paths, real_obj, list.objects[i].name))
                        hit = 1;
        }
        return !hit;