From: Junio C Hamano Date: Thu, 23 Feb 2006 00:15:42 +0000 (-0800) Subject: Merge fixes up to GIT 1.2.3 X-Git-Tag: v1.3.0-rc1~158 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2cf3be1d31b322cf45640f3019a32d19a8a9b6f8?ds=inline;hp=-c Merge fixes up to GIT 1.2.3 --- 2cf3be1d31b322cf45640f3019a32d19a8a9b6f8 diff --combined sha1_file.c index 9cab99ae7c,f4b10894c8..1fd5b797a5 --- a/sha1_file.c +++ b/sha1_file.c @@@ -247,6 -247,7 +247,7 @@@ static void link_alt_odb_entries(const for ( ; cp < ep && *cp != sep; cp++) ; if (last != cp) { + struct stat st; struct alternate_object_database *alt; /* 43 = 40-byte + 2 '/' + terminating NUL */ int pfxlen = cp - last; @@@ -269,9 -270,19 +270,19 @@@ } else memcpy(ent->base, last, pfxlen); + ent->name = ent->base + pfxlen + 1; - ent->base[pfxlen] = ent->base[pfxlen + 3] = '/'; - ent->base[entlen-1] = 0; + ent->base[pfxlen + 3] = '/'; + ent->base[pfxlen] = ent->base[entlen-1] = 0; + + /* Detect cases where alternate disappeared */ + if (stat(ent->base, &st) || !S_ISDIR(st.st_mode)) { + error("object directory %s does not exist; " + "check .git/objects/info/alternates.", + ent->base); + goto bad; + } + ent->base[pfxlen] = '/'; /* Prevent the common mistake of listing the same * thing twice, or object directory itself. @@@ -552,7 -563,9 +563,9 @@@ static void prepare_packed_git_one(cha len = strlen(path); dir = opendir(path); if (!dir) { - fprintf(stderr, "unable to open object pack directory: %s: %s\n", path, strerror(errno)); + if (errno != ENOENT) + error("unable to open object pack directory: %s: %s\n", + path, strerror(errno)); return; } path[len++] = '/'; @@@ -851,7 -864,7 +864,7 @@@ void packed_object_info_detail(struct p char *type, unsigned long *size, unsigned long *store_size, - int *delta_chain_length, + unsigned int *delta_chain_length, unsigned char *base_sha1) { struct packed_git *p = e->p; @@@ -865,7 -878,7 +878,7 @@@ if (kind != OBJ_DELTA) *delta_chain_length = 0; else { - int chain_length = 0; + unsigned int chain_length = 0; memcpy(base_sha1, pack, 20); do { struct pack_entry base_ent;