summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2006-06-02 18:17:35 -0700
committerLibravatar Junio C Hamano <junkio@cox.net>2006-06-02 18:17:35 -0700
commit2f164c35fa8915ddd8e8a01809a9935ad900f13c (patch)
tree4a8e5b79c63abd436aea600457775b5557937c25 /sha1_file.c
parentformat-patch: resurrect extra headers from config (diff)
parentUpdate documentation for git-format-patch (diff)
downloadtgif-2f164c35fa8915ddd8e8a01809a9935ad900f13c.tar.xz
Merge branch 'ds/doc' into jc/fmt-patch
* ds/doc: Update documentation for git-format-patch sha1_file: avoid re-preparing duplicate packs handle concurrent pruning of packed objects http: prevent segfault during curl handle reuse Remove possible segfault in http-fetch. gitk: show_error fix [PATCH] gitk: start-up bugfix [PATCH] gitk: Replace "git-" commands with "git " [PATCH] gitk: Display commit messages with word wrap gitk: Fix bug where page-up/down wouldn't always work properly gitk: Fix display of "(...)" for parents/children we haven't drawn send-email: only 'require' instead of 'use' Net::SMTP Allow multiple -m options to git-commit.
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/sha1_file.c b/sha1_file.c
index f77c18934a..aea0f40d57 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -617,6 +617,12 @@ static void prepare_packed_git_one(char *objdir, int local)
/* we have .idx. Is it a file we can map? */
strcpy(path + len, de->d_name);
+ for (p = packed_git; p; p = p->next) {
+ if (!memcmp(path, p->pack_name, len + namelen - 4))
+ break;
+ }
+ if (p)
+ continue;
p = add_packed_git(path, len + namelen, local);
if (!p)
continue;
@@ -626,12 +632,12 @@ static void prepare_packed_git_one(char *objdir, int local)
closedir(dir);
}
+static int prepare_packed_git_run_once = 0;
void prepare_packed_git(void)
{
- static int run_once = 0;
struct alternate_object_database *alt;
- if (run_once)
+ if (prepare_packed_git_run_once)
return;
prepare_packed_git_one(get_object_directory(), 1);
prepare_alt_odb();
@@ -640,7 +646,13 @@ void prepare_packed_git(void)
prepare_packed_git_one(alt->base, 0);
alt->name[-1] = '/';
}
- run_once = 1;
+ prepare_packed_git_run_once = 1;
+}
+
+static void reprepare_packed_git(void)
+{
+ prepare_packed_git_run_once = 0;
+ prepare_packed_git();
}
int check_sha1_signature(const unsigned char *sha1, void *map, unsigned long size, const char *type)
@@ -1212,9 +1224,12 @@ int sha1_object_info(const unsigned char *sha1, char *type, unsigned long *sizep
if (!map) {
struct pack_entry e;
- if (!find_pack_entry(sha1, &e))
- return error("unable to find %s", sha1_to_hex(sha1));
- return packed_object_info(&e, type, sizep);
+ if (find_pack_entry(sha1, &e))
+ return packed_object_info(&e, type, sizep);
+ reprepare_packed_git();
+ if (find_pack_entry(sha1, &e))
+ return packed_object_info(&e, type, sizep);
+ return error("unable to find %s", sha1_to_hex(sha1));
}
if (unpack_sha1_header(&stream, map, mapsize, hdr, sizeof(hdr)) < 0)
status = error("unable to unpack %s header",
@@ -1256,6 +1271,9 @@ void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size
munmap(map, mapsize);
return buf;
}
+ reprepare_packed_git();
+ if (find_pack_entry(sha1, &e))
+ return read_packed_sha1(sha1, type, size);
return NULL;
}