summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-02-27 23:15:53 -0800
committerJunio C Hamano <gitster@pobox.com>2009-02-28 01:06:06 -0800
commitcd673c1f17228d272c4b7f81fbb28bc31cf0cac6 (patch)
tree5e5537843e6b38f62a3b4f15437e4a3bf8ee89ab /sha1_file.c
parent2478dc84b5fb2617bfab3a8f65f1270de578b94a (diff)
downloadgit-cd673c1f17228d272c4b7f81fbb28bc31cf0cac6.tar.gz
has_sha1_pack(): refactor "pretend these packs do not exist" interface
Most of the callers of this function except only one pass NULL to its last parameter, ignore_packed. Introduce has_sha1_kept_pack() function that has the function signature and the semantics of this function, and convert the sole caller that does not pass NULL to call this new function. All other callers and has_sha1_pack() lose the ignore_packed parameter. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 88035a0cd1..ac4375d298 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1874,7 +1874,8 @@ int matches_pack_name(struct packed_git *p, const char *name)
return 0;
}
-static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)
+static int find_pack_ent(const unsigned char *sha1, struct pack_entry *e,
+ const char **ignore_packed)
{
static struct packed_git *last_found = (void *)1;
struct packed_git *p;
@@ -1934,6 +1935,17 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
return 0;
}
+static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
+{
+ return find_pack_ent(sha1, e, NULL);
+}
+
+static int find_kept_pack_entry(const unsigned char *sha1, struct pack_entry *e,
+ const char **ignore_packed)
+{
+ return find_pack_ent(sha1, e, ignore_packed);
+}
+
struct packed_git *find_sha1_pack(const unsigned char *sha1,
struct packed_git *packs)
{
@@ -1975,7 +1987,7 @@ int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
struct pack_entry e;
int status;
- if (!find_pack_entry(sha1, &e, NULL)) {
+ if (!find_pack_entry(sha1, &e)) {
/* Most likely it's a loose object. */
status = sha1_loose_object_info(sha1, sizep);
if (status >= 0)
@@ -1983,7 +1995,7 @@ int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
/* Not a loose object; someone else may have just packed it. */
reprepare_packed_git();
- if (!find_pack_entry(sha1, &e, NULL))
+ if (!find_pack_entry(sha1, &e))
return status;
}
return packed_object_info(e.p, e.offset, sizep);
@@ -1995,7 +2007,7 @@ static void *read_packed_sha1(const unsigned char *sha1,
struct pack_entry e;
void *data;
- if (!find_pack_entry(sha1, &e, NULL))
+ if (!find_pack_entry(sha1, &e))
return NULL;
data = cache_or_unpack_entry(e.p, e.offset, size, type, 1);
if (!data) {
@@ -2395,17 +2407,23 @@ int has_pack_file(const unsigned char *sha1)
return 1;
}
-int has_sha1_pack(const unsigned char *sha1, const char **ignore_packed)
+int has_sha1_pack(const unsigned char *sha1)
+{
+ struct pack_entry e;
+ return find_pack_entry(sha1, &e);
+}
+
+int has_sha1_kept_pack(const unsigned char *sha1, const char **ignore_packed)
{
struct pack_entry e;
- return find_pack_entry(sha1, &e, ignore_packed);
+ return find_kept_pack_entry(sha1, &e, ignore_packed);
}
int has_sha1_file(const unsigned char *sha1)
{
struct pack_entry e;
- if (find_pack_entry(sha1, &e, NULL))
+ if (find_pack_entry(sha1, &e))
return 1;
return has_loose_object(sha1);
}