Merge branch 'jc/pack'
authorJunio C Hamano <junkio@cox.net>
Mon, 18 Sep 2006 01:32:03 +0000 (18:32 -0700)
committerJunio C Hamano <junkio@cox.net>
Mon, 18 Sep 2006 01:32:03 +0000 (18:32 -0700)
* jc/pack:
pack-objects: document --revs, --unpacked and --all.
pack-objects --unpacked=<existing pack> option.
pack-objects: further work on internal rev-list logic.
pack-objects: run rev-list equivalent internally.
Separate object listing routines out of rev-list

1  2 
Makefile
cache.h
sha1_file.c
diff --combined Makefile
index 69915d865168817f72c084f15930e41bf5b9ad45,18cd79e7c065df505d412e9490585ef4f769309b..8467447da90f04cc55d1403ea102c6335331aa52
+++ b/Makefile
@@@ -126,8 -126,6 +126,8 @@@ GITWEB_CONFIG = gitweb_config.per
  GITWEB_HOME_LINK_STR = projects
  GITWEB_SITENAME =
  GITWEB_PROJECTROOT = /pub/git
 +GITWEB_EXPORT_OK =
 +GITWEB_STRICT_EXPORT =
  GITWEB_BASE_URL =
  GITWEB_LIST =
  GITWEB_HOMETEXT = indextext.html
@@@ -234,8 -232,8 +234,8 @@@ LIB_FILE=libgit.
  XDIFF_LIB=xdiff/lib.a
  
  LIB_H = \
 -      blob.h cache.h commit.h csum-file.h delta.h \
 -      diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h \
 +      archive.h blob.h cache.h commit.h csum-file.h delta.h \
-       diff.h object.h pack.h pkt-line.h quote.h refs.h sideband.h \
++      diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
        run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
        tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h
  
@@@ -247,19 -245,17 +247,19 @@@ DIFF_OBJS = 
  LIB_OBJS = \
        blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
        date.o diff-delta.o entry.o exec_cmd.o ident.o lockfile.o \
 -      object.o pack-check.o patch-delta.o path.o pkt-line.o \
 +      object.o pack-check.o patch-delta.o path.o pkt-line.o sideband.o \
        quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
        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 \
-       write_or_die.o trace.o \
+       write_or_die.o trace.o list-objects.o \
 -      alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS)
 +      alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
 +      color.o wt-status.o
  
  BUILTIN_OBJS = \
        builtin-add.o \
        builtin-apply.o \
 +      builtin-archive.o \
        builtin-cat-file.o \
        builtin-checkout-index.o \
        builtin-check-ref-format.o \
        builtin-rev-list.o \
        builtin-rev-parse.o \
        builtin-rm.o \
 +      builtin-runstatus.o \
        builtin-show-branch.o \
        builtin-stripspace.o \
        builtin-symbolic-ref.o \
        builtin-unpack-objects.o \
        builtin-update-index.o \
        builtin-update-ref.o \
 +      builtin-upload-archive.o \
        builtin-upload-tar.o \
        builtin-verify-pack.o \
        builtin-write-tree.o \
@@@ -637,8 -631,6 +637,8 @@@ gitweb/gitweb.cgi: gitweb/gitweb.per
            -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
            -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
            -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
 +          -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
 +          -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
            -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
            -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
            -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
diff --combined cache.h
index 8d099979d9a04231d73307c786d25bf412a3f22c,ac51ed1d28f2808d9c2315b566d8bd525ff22189..57db7c9b20aad5d14ab4e77fd0e338b98c446bcc
+++ b/cache.h
@@@ -259,7 -259,7 +259,7 @@@ extern int write_sha1_from_fd(const uns
  extern int write_sha1_to_fd(int fd, const unsigned char *sha1);
  extern int move_temp_to_file(const char *tmpfile, const char *filename);
  
- extern int has_sha1_pack(const unsigned char *sha1);
+ extern int has_sha1_pack(const unsigned char *sha1, const char **ignore);
  extern int has_sha1_file(const unsigned char *sha1);
  extern void *map_sha1_file(const unsigned char *sha1, unsigned long *);
  extern int legacy_loose_object(unsigned char *);
@@@ -359,7 -359,7 +359,7 @@@ struct ref 
  #define REF_HEADS     (1u << 1)
  #define REF_TAGS      (1u << 2)
  
 -extern int git_connect(int fd[2], char *url, const char *prog);
 +extern pid_t git_connect(int fd[2], char *url, const char *prog);
  extern int finish_connect(pid_t pid);
  extern int path_match(const char *path, int nr, char **match);
  extern int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
diff --combined sha1_file.c
index b64b92de4e7a6c59edfb3e60ff1440a98cacdeea,d5d048af677b67e550388bd599b78dc840ab91b6..b89edb9515aa38c2c404367aa28ec5531fcc7de1
@@@ -26,43 -26,15 +26,43 @@@ const unsigned char null_sha1[20]
  
  static unsigned int sha1_file_open_flag = O_NOATIME;
  
 -static unsigned hexval(char c)
 +static inline unsigned int hexval(unsigned int c)
  {
 -      if (c >= '0' && c <= '9')
 -              return c - '0';
 -      if (c >= 'a' && c <= 'f')
 -              return c - 'a' + 10;
 -      if (c >= 'A' && c <= 'F')
 -              return c - 'A' + 10;
 -      return ~0;
 +      static signed char val[256] = {
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 00-07 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 08-0f */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 10-17 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 18-1f */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 20-27 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 28-2f */
 +                0,  1,  2,  3,  4,  5,  6,  7,                /* 30-37 */
 +                8,  9, -1, -1, -1, -1, -1, -1,                /* 38-3f */
 +               -1, 10, 11, 12, 13, 14, 15, -1,                /* 40-47 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 48-4f */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 50-57 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 58-5f */
 +               -1, 10, 11, 12, 13, 14, 15, -1,                /* 60-67 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 68-67 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 70-77 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 78-7f */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 80-87 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 88-8f */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 90-97 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* 98-9f */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* a0-a7 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* a8-af */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* b0-b7 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* b8-bf */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* c0-c7 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* c8-cf */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* d0-d7 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* d8-df */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* e0-e7 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* e8-ef */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* f0-f7 */
 +               -1, -1, -1, -1, -1, -1, -1, -1,                /* f8-ff */
 +      };
 +      return val[c];
  }
  
  int get_sha1_hex(const char *hex, unsigned char *sha1)
@@@ -1217,12 -1189,20 +1217,20 @@@ int find_pack_entry_one(const unsigned 
        return 0;
  }
  
- static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
+ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)
  {
        struct packed_git *p;
        prepare_packed_git();
  
        for (p = packed_git; p; p = p->next) {
+               if (ignore_packed) {
+                       const char **ig;
+                       for (ig = ignore_packed; *ig; ig++)
+                               if (!strcmp(p->pack_name, *ig))
+                                       break;
+                       if (*ig)
+                               continue;
+               }
                if (find_pack_entry_one(sha1, e, p))
                        return 1;
        }
@@@ -1255,10 -1235,10 +1263,10 @@@ int sha1_object_info(const unsigned cha
        if (!map) {
                struct pack_entry e;
  
-               if (find_pack_entry(sha1, &e))
+               if (find_pack_entry(sha1, &e, NULL))
                        return packed_object_info(&e, type, sizep);
                reprepare_packed_git();
-               if (find_pack_entry(sha1, &e))
+               if (find_pack_entry(sha1, &e, NULL))
                        return packed_object_info(&e, type, sizep);
                return error("unable to find %s", sha1_to_hex(sha1));
        }
@@@ -1281,7 -1261,7 +1289,7 @@@ static void *read_packed_sha1(const uns
  {
        struct pack_entry e;
  
-       if (!find_pack_entry(sha1, &e)) {
+       if (!find_pack_entry(sha1, &e, NULL)) {
                error("cannot read sha1_file for %s", sha1_to_hex(sha1));
                return NULL;
        }
@@@ -1294,7 -1274,7 +1302,7 @@@ void * read_sha1_file(const unsigned ch
        void *map, *buf;
        struct pack_entry e;
  
-       if (find_pack_entry(sha1, &e))
+       if (find_pack_entry(sha1, &e, NULL))
                return read_packed_sha1(sha1, type, size);
        map = map_sha1_file(sha1, &mapsize);
        if (map) {
                return buf;
        }
        reprepare_packed_git();
-       if (find_pack_entry(sha1, &e))
+       if (find_pack_entry(sha1, &e, NULL))
                return read_packed_sha1(sha1, type, size);
        return NULL;
  }
@@@ -1735,10 -1715,10 +1743,10 @@@ int has_pack_file(const unsigned char *
        return 1;
  }
  
- int has_sha1_pack(const unsigned char *sha1)
+ int has_sha1_pack(const unsigned char *sha1, const char **ignore_packed)
  {
        struct pack_entry e;
-       return find_pack_entry(sha1, &e);
+       return find_pack_entry(sha1, &e, ignore_packed);
  }
  
  int has_sha1_file(const unsigned char *sha1)
        struct stat st;
        struct pack_entry e;
  
-       if (find_pack_entry(sha1, &e))
+       if (find_pack_entry(sha1, &e, NULL))
                return 1;
        return find_sha1_file(sha1, &st) ? 1 : 0;
  }