From: Junio C Hamano Date: Sun, 20 May 2007 09:18:43 +0000 (-0700) Subject: Merge branch 'np/pack' X-Git-Tag: v1.5.3-rc0~218 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/cc93020f5213b589ff1e512185c47d8c38a4b994?ds=inline;hp=-c Merge branch 'np/pack' * np/pack: deprecate the new loose object header format make "repack -f" imply "pack-objects --no-reuse-object" allow for undeltified objects not to be reused --- cc93020f5213b589ff1e512185c47d8c38a4b994 diff --combined Documentation/config.txt index efcf3019b0,d6d89ba463..b8d48d1013 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -209,19 -209,6 +209,6 @@@ core.compression: compression, and 1..9 are various speed/size tradeoffs, 9 being slowest. - core.legacyheaders:: - A boolean which - changes the format of loose objects so that they are more - efficient to pack and to send out of the repository over git - native protocol, since v1.4.2. However, loose objects - written in the new format cannot be read by git older than - that version; people fetching from your repository using - older versions of git over dumb transports (e.g. http) - will also be affected. - + - To let git use the new loose object format, you have to - set core.legacyheaders to false. - core.packedGitWindowSize:: Number of bytes of a pack file to map into memory in a single mapping operation. Larger window sizes may allow @@@ -384,11 -371,6 +371,11 @@@ format.suffix: `.patch`. Use this variable to change that suffix (make sure to include the dot if you want it). +gc.aggressiveWindow:: + The window size parameter used in the delta compression + algorithm used by 'git gc --aggressive'. This defaults + to 10. + gc.packrefs:: `git gc` does not run `git pack-refs` in a bare repository by default so that older dumb-transport clients can still fetch diff --combined cache.h index 4204bc168c,5725bce6f4..3661a3fdf0 --- a/cache.h +++ b/cache.h @@@ -273,7 -273,6 +273,6 @@@ extern void rollback_lock_file(struct l extern int delete_ref(const char *, const unsigned char *sha1); /* Environment bits from configuration mechanism */ - extern int use_legacy_headers; extern int trust_executable_bit; extern int has_symlinks; extern int assume_unchanged; @@@ -354,7 -353,6 +353,6 @@@ extern int move_temp_to_file(const cha 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 *); extern int has_pack_file(const unsigned char *sha1); extern int has_pack_index(const unsigned char *sha1); @@@ -410,7 -408,6 +408,7 @@@ struct checkout }; extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath); +extern int has_symlink_leading_path(const char *name, char *last_symlink); extern struct alternate_object_database { struct alternate_object_database *next; @@@ -548,7 -545,6 +546,7 @@@ extern void trace_argv_printf(const cha /* convert.c */ extern char *convert_to_git(const char *path, const char *src, unsigned long *sizep); extern char *convert_to_working_tree(const char *path, const char *src, unsigned long *sizep); +extern void *convert_sha1_file(const char *path, const unsigned char *sha1, unsigned int mode, enum object_type *type, unsigned long *size); /* match-trees.c */ void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, int); diff --combined config.c index 7b655fdb78,298966f215..521ebef381 --- a/config.c +++ b/config.c @@@ -299,11 -299,6 +299,6 @@@ int git_default_config(const char *var return 0; } - if (!strcmp(var, "core.legacyheaders")) { - use_legacy_headers = git_config_bool(var, value); - return 0; - } - if (!strcmp(var, "core.compression")) { int level = git_config_int(var, value); if (level == -1) @@@ -451,9 -446,6 +446,9 @@@ static int matches(const char* key, con static int store_aux(const char* key, const char* value) { + const char *ep; + size_t section_len; + switch (store.state) { case KEY_SEEN: if (matches(key, value)) { @@@ -471,29 -463,12 +466,29 @@@ } break; case SECTION_SEEN: - if (strncmp(key, store.key, store.baselen+1)) { + /* + * What we are looking for is in store.key (both + * section and var), and its section part is baselen + * long. We found key (again, both section and var). + * We would want to know if this key is in the same + * section as what we are looking for. We already + * know we are in the same section as what should + * hold store.key. + */ + ep = strrchr(key, '.'); + section_len = ep - key; + + if ((section_len != store.baselen) || + memcmp(key, store.key, section_len+1)) { store.state = SECTION_END_SEEN; break; - } else - /* do not increment matches: this is no match */ - store.offset[store.seen] = ftell(config_file); + } + + /* + * Do not increment matches: this is no match, but we + * just made sure we are in the desired section. + */ + store.offset[store.seen] = ftell(config_file); /* fallthru */ case SECTION_END_SEEN: case START: diff --combined sha1_file.c index be991ed22a,e71552795a..12d2ef2011 --- a/sha1_file.c +++ b/sha1_file.c @@@ -972,7 -972,7 +972,7 @@@ void *map_sha1_file(const unsigned cha return map; } - int legacy_loose_object(unsigned char *map) + static int legacy_loose_object(unsigned char *map) { unsigned int word; @@@ -1034,6 -1034,14 +1034,14 @@@ static int unpack_sha1_header(z_stream return inflate(stream, 0); } + + /* + * There used to be a second loose object header format which + * was meant to mimic the in-pack format, allowing for direct + * copy of the object data. This format turned up not to be + * really worth it and we don't write it any longer. But we + * can still read it. + */ used = unpack_object_header_gently(map, mapsize, &type, &size); if (!used || !valid_loose_object_type[type]) return -1; @@@ -1962,40 -1970,6 +1970,6 @@@ static int write_buffer(int fd, const v return 0; } - static int write_binary_header(unsigned char *hdr, enum object_type type, unsigned long len) - { - int hdr_len; - unsigned char c; - - c = (type << 4) | (len & 15); - len >>= 4; - hdr_len = 1; - while (len) { - *hdr++ = c | 0x80; - hdr_len++; - c = (len & 0x7f); - len >>= 7; - } - *hdr = c; - return hdr_len; - } - - static void setup_object_header(z_stream *stream, const char *type, unsigned long len) - { - int obj_type, hdrlen; - - if (use_legacy_headers) { - while (deflate(stream, 0) == Z_OK) - /* nothing */; - return; - } - obj_type = type_from_string(type); - hdrlen = write_binary_header(stream->next_out, obj_type, len); - stream->total_out = hdrlen; - stream->next_out += hdrlen; - stream->avail_out -= hdrlen; - } - int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1) { @@@ -2062,7 -2036,8 +2036,8 @@@ int write_sha1_file(void *buf, unsigne /* First header.. */ stream.next_in = (unsigned char *)hdr; stream.avail_in = hdrlen; - setup_object_header(&stream, type, len); + while (deflate(&stream, 0) == Z_OK) + /* nothing */; /* Then the data itself.. */ stream.next_in = buf; @@@ -2276,7 -2251,7 +2251,7 @@@ int read_pipe(int fd, char** return_buf { char* buf = *return_buf; unsigned long size = *return_size; - int iret; + ssize_t iret; unsigned long off = 0; do {