Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
sha1_file: allow read_object to read objects in arbitrary repositories
author
Stefan Beller
<sbeller@google.com>
Tue, 16 Oct 2018 23:35:32 +0000
(16:35 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 19 Oct 2018 07:21:04 +0000
(16:21 +0900)
Allow read_object (a file local functon in sha1_file) to
handle arbitrary repositories by passing the repository down
to oid_object_info_extended.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1-file.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
c4df23f
)
diff --git
a/sha1-file.c
b/sha1-file.c
index dd0b6aa873a95433906b52abf605a43acc924d4a..b8ce21cbafd7a2175b24b9cd579decf8b9ad92bc 100644
(file)
--- a/
sha1-file.c
+++ b/
sha1-file.c
@@
-1361,7
+1361,9
@@
int oid_object_info(struct repository *r,
return type;
}
return type;
}
-static void *read_object(const unsigned char *sha1, enum object_type *type,
+static void *read_object(struct repository *r,
+ const unsigned char *sha1,
+ enum object_type *type,
unsigned long *size)
{
struct object_id oid;
unsigned long *size)
{
struct object_id oid;
@@
-1373,7
+1375,7
@@
static void *read_object(const unsigned char *sha1, enum object_type *type,
hashcpy(oid.hash, sha1);
hashcpy(oid.hash, sha1);
- if (oid_object_info_extended(
the_repository
, &oid, &oi, 0) < 0)
+ if (oid_object_info_extended(
r
, &oid, &oi, 0) < 0)
return NULL;
return content;
}
return NULL;
return content;
}
@@
-1414,7
+1416,7
@@
void *read_object_file_extended(const struct object_id *oid,
lookup_replace_object(the_repository, oid) : oid;
errno = 0;
lookup_replace_object(the_repository, oid) : oid;
errno = 0;
- data = read_object(repl->hash, type, size);
+ data = read_object(
the_repository,
repl->hash, type, size);
if (data)
return data;
if (data)
return data;
@@
-1755,7
+1757,7
@@
int force_object_loose(const struct object_id *oid, time_t mtime)
if (has_loose_object(oid))
return 0;
if (has_loose_object(oid))
return 0;
- buf = read_object(oid->hash, &type, &len);
+ buf = read_object(
the_repository,
oid->hash, &type, &len);
if (!buf)
return error(_("cannot read sha1_file for %s"), oid_to_hex(oid));
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;
if (!buf)
return error(_("cannot read sha1_file for %s"), oid_to_hex(oid));
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;