Merge branch 'np/pack'
authorJunio C Hamano <junkio@cox.net>
Sun, 22 Apr 2007 00:20:50 +0000 (17:20 -0700)
committerJunio C Hamano <junkio@cox.net>
Sun, 22 Apr 2007 00:20:50 +0000 (17:20 -0700)
* np/pack: (27 commits)
document --index-version for index-pack and pack-objects
pack-objects: remove obsolete comments
pack-objects: better check_object() performances
add get_size_from_delta()
pack-objects: make in_pack_header_size a variable of its own
pack-objects: get rid of create_final_object_list()
pack-objects: get rid of reuse_cached_pack
pack-objects: clean up list sorting
pack-objects: rework check_delta_limit usage
pack-objects: equal objects in size should delta against newer objects
pack-objects: optimize preferred base handling a bit
clean up add_object_entry()
tests for various pack index features
use test-genrandom in tests instead of /dev/urandom
simple random data generator for tests
validate reused pack data with CRC when possible
allow forcing index v2 and 64-bit offset treshold
pack-redundant.c: learn about index v2
show-index.c: learn about index v2
sha1_file.c: learn about index version 2
...

1  2 
Makefile
builtin-fsck.c
cache.h
git-compat-util.h
diff --combined Makefile
index 251fc31fc05035bf85265d3ea56c8b3ab24c895f,bd0ba95b1ac18096db59f2aa2a2eb137349cb3a8..173c8b68c0c49bf8614a8e929f3b3d392db9eaa3
+++ b/Makefile
@@@ -283,7 -283,7 +283,7 @@@ LIB_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 \
 -      utf8.h reflog-walk.h
 +      utf8.h reflog-walk.h patch-ids.h decorate.h
  
  DIFF_OBJS = \
        diff.o diff-lib.o diffcore-break.o diffcore-order.o \
@@@ -295,7 -295,6 +295,7 @@@ LIB_OBJS = 
        date.o diff-delta.o entry.o exec_cmd.o ident.o \
        interpolate.o \
        lockfile.o \
 +      patch-ids.o \
        object.o pack-check.o patch-delta.o path.o pkt-line.o sideband.o \
        reachable.o reflog-walk.o \
        quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
        write_or_die.o trace.o list-objects.o grep.o match-trees.o \
        alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
        color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
 -      convert.o
 +      convert.o decorate.o
  
  BUILTIN_OBJS = \
        builtin-add.o \
@@@ -729,7 -728,7 +729,7 @@@ git$X: git.c common-cmds.h $(BUILTIN_OB
  help.o: common-cmds.h
  
  git-merge-subtree$X: git-merge-recursive$X
 -      rm -f $@ && ln git-merge-recursive$X $@
 +      $(QUIET_BUILT_IN)rm -f $@ && ln git-merge-recursive$X $@
  
  $(BUILT_INS): git$X
        $(QUIET_BUILT_IN)rm -f $@ && ln git$X $@
@@@ -933,7 -932,7 +933,7 @@@ endi
  
  export NO_SVN_TESTS
  
- test: all test-chmtime$X
+ test: all test-chmtime$X test-genrandom$X
        $(MAKE) -C t/ all
  
  test-date$X: test-date.c date.o ctype.o
@@@ -954,6 -953,9 +954,9 @@@ test-match-trees$X: test-match-trees.o 
  test-chmtime$X: test-chmtime.c
        $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $<
  
+ test-genrandom$X: test-genrandom.c
+       $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $<
  check-sha1:: test-sha1$X
        ./test-sha1.sh
  
@@@ -1042,7 -1044,7 +1045,7 @@@ dist-doc
  
  clean:
        rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
-               test-chmtime$X $(LIB_FILE) $(XDIFF_LIB)
+               test-chmtime$X test-genrandom$X $(LIB_FILE) $(XDIFF_LIB)
        rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X
        rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
        rm -rf autom4te.cache
diff --combined builtin-fsck.c
index 05d98d2cfc0c8ba5e38482a181fee8115e9bd640,44a02d3120128d4956604c4254fbdd9809a36833..f480e700e9607068a8d949a520b6760593a522f7
@@@ -534,7 -534,7 +534,7 @@@ static void get_default_heads(void
         * "show_unreachable" flag.
         */
        if (!default_refs) {
 -              error("No default references");
 +              fprintf(stderr, "notice: No default references\n");
                show_unreachable = 0;
        }
  }
@@@ -554,23 -554,15 +554,23 @@@ static int fsck_head_link(void
  {
        unsigned char sha1[20];
        int flag;
 -      const char *head_points_at = resolve_ref("HEAD", sha1, 1, &flag);
 -
 -      if (!head_points_at || !(flag & REF_ISSYMREF))
 -              return error("HEAD is not a symbolic ref");
 -      if (prefixcmp(head_points_at, "refs/heads/"))
 +      int null_is_error = 0;
 +      const char *head_points_at = resolve_ref("HEAD", sha1, 0, &flag);
 +
 +      if (!head_points_at)
 +              return error("Invalid HEAD");
 +      if (!strcmp(head_points_at, "HEAD"))
 +              /* detached HEAD */
 +              null_is_error = 1;
 +      else if (prefixcmp(head_points_at, "refs/heads/"))
                return error("HEAD points to something strange (%s)",
                             head_points_at);
 -      if (is_null_sha1(sha1))
 -              return error("HEAD: not a valid git pointer");
 +      if (is_null_sha1(sha1)) {
 +              if (null_is_error)
 +                      return error("HEAD: detached HEAD points at nothing");
 +              fprintf(stderr, "notice: HEAD points to an unborn branch (%s)\n",
 +                      head_points_at + 11);
 +      }
        return 0;
  }
  
@@@ -661,7 -653,7 +661,7 @@@ int cmd_fsck(int argc, char **argv, con
                        verify_pack(p, 0);
  
                for (p = packed_git; p; p = p->next) {
-                       uint32_t i, num = num_packed_objects(p);
+                       uint32_t i, num = p->num_objects;
                        for (i = 0; i < num; i++)
                                fsck_sha1(nth_packed_object_sha1(p, i));
                }
diff --combined cache.h
index 53c23413e4ba0b6c43632be821c69c8eb80db857,63399c7c6bb3a1b8ede111aa54bc496b762148b7..ead119609a493a15b7463df8462140729b78957a
+++ b/cache.h
@@@ -217,7 -217,7 +217,7 @@@ extern int commit_locked_index(struct l
  extern void set_alternate_index_output(const char *);
  
  extern void rollback_lock_file(struct lock_file *);
 -extern int delete_ref(const char *, unsigned char *sha1);
 +extern int delete_ref(const char *, const unsigned char *sha1);
  
  /* Environment bits from configuration mechanism */
  extern int use_legacy_headers;
@@@ -376,11 -376,12 +376,12 @@@ struct pack_window 
  extern struct packed_git {
        struct packed_git *next;
        struct pack_window *windows;
-       const void *index_data;
-       off_t index_size;
        off_t pack_size;
-       time_t mtime;
+       const void *index_data;
+       size_t index_size;
+       uint32_t num_objects;
        int index_version;
+       time_t mtime;
        int pack_fd;
        int pack_local;
        unsigned char sha1[20];
@@@ -431,11 -432,11 +432,11 @@@ extern void pack_report(void)
  extern unsigned char* use_pack(struct packed_git *, struct pack_window **, off_t, unsigned int *);
  extern void unuse_pack(struct pack_window **);
  extern struct packed_git *add_packed_git(const char *, int, int);
- extern uint32_t num_packed_objects(const struct packed_git *p);
  extern const unsigned char *nth_packed_object_sha1(const struct packed_git *, uint32_t);
  extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
  extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
  extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
+ extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
  extern const char *packed_object_info_detail(struct packed_git *, off_t, unsigned long *, unsigned long *, unsigned int *, unsigned char *);
  
  /* Dumb servers support */
@@@ -472,8 -473,8 +473,8 @@@ extern int pager_in_use
  extern int pager_use_color;
  
  /* base85 */
 -int decode_85(char *dst, char *line, int linelen);
 -void encode_85(char *buf, unsigned char *data, int bytes);
 +int decode_85(char *dst, const char *line, int linelen);
 +void encode_85(char *buf, const unsigned char *data, int bytes);
  
  /* alloc.c */
  struct blob;
diff --combined git-compat-util.h
index 5f6a281b78245bbb4e1e480d81cfb8c1b4cfa6ac,bcfcb35ecf81d024147c75880428cdea370111ce..0b6d74d4d7ca0df726dd0464951a5e0f045c8715
  
  #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
  
+ #ifdef __GNUC__
+ #define TYPEOF(x) (__typeof__(x))
+ #else
+ #define TYPEOF(x)
+ #endif
+ #define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits))))
  #if !defined(__APPLE__) && !defined(__FreeBSD__)
  #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
  #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
@@@ -301,17 -309,4 +309,17 @@@ static inline int prefixcmp(const char 
        return strncmp(str, prefix, strlen(prefix));
  }
  
 +static inline int strtoul_ui(char const *s, int base, unsigned int *result)
 +{
 +      unsigned long ul;
 +      char *p;
 +
 +      errno = 0;
 +      ul = strtoul(s, &p, base);
 +      if (errno || *p || p == s || (unsigned int) ul != ul)
 +              return -1;
 +      *result = ul;
 +      return 0;
 +}
 +
  #endif