summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-02-22 16:15:42 -0800
committerJunio C Hamano <junkio@cox.net>2006-02-22 16:15:42 -0800
commit2cf3be1d31b322cf45640f3019a32d19a8a9b6f8 (patch)
tree8b9fbe8932bac19c0728f144e3314871703b9456 /sha1_file.c
parentd27d5b3c5b97ca30dfc5c448dc8cdae914131051 (diff)
parent6dc78e696b8597204b903073da932fc5ed0f419e (diff)
downloadgit-2cf3be1d31b322cf45640f3019a32d19a8a9b6f8.tar.gz
Merge fixes up to GIT 1.2.3
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 9cab99ae7c..1fd5b797a5 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -247,6 +247,7 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
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 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
}
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 @@ static void prepare_packed_git_one(char *objdir, int local)
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++] = '/';