object: add repository argument to parse_object

Add a repository argument to allow the callers of parse_object
to be more specific about which repository to act on. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Stefan Beller
2018-06-28 18:21:51 -07:00
committed by Junio C Hamano
parent b16b60f71b
commit 109cd76dd3
33 changed files with 95 additions and 72 deletions

View File

@ -3,6 +3,7 @@
#include "refs.h"
#include "pkt-line.h"
#include "sideband.h"
#include "repository.h"
#include "object-store.h"
#include "tag.h"
#include "object.h"
@ -311,7 +312,7 @@ static int got_oid(const char *hex, struct object_id *oid)
if (!has_object_file(oid))
return -1;
o = parse_object(oid);
o = parse_object(the_repository, oid);
if (!o)
die("oops (%s)", oid_to_hex(oid));
if (o->type == OBJ_COMMIT) {
@ -349,7 +350,7 @@ static int reachable(struct commit *want)
break;
}
if (!commit->object.parsed)
parse_object(&commit->object.oid);
parse_object(the_repository, &commit->object.oid);
if (commit->object.flags & REACHABLE)
continue;
commit->object.flags |= REACHABLE;
@ -800,7 +801,7 @@ static int process_shallow(const char *line, struct object_array *shallows)
struct object *object;
if (get_oid_hex(arg, &oid))
die("invalid shallow line: %s", line);
object = parse_object(&oid);
object = parse_object(the_repository, &oid);
if (!object)
return 1;
if (object->type != OBJ_COMMIT)
@ -926,7 +927,7 @@ static void receive_needs(void)
if (allow_filter && parse_feature_request(features, "filter"))
filter_capability_requested = 1;
o = parse_object(&oid_buf);
o = parse_object(the_repository, &oid_buf);
if (!o) {
packet_write_fmt(1,
"ERR upload-pack: not our ref %s",
@ -1167,7 +1168,7 @@ static int parse_want(const char *line)
die("git upload-pack: protocol error, "
"expected to get oid, not '%s'", line);
o = parse_object(&oid);
o = parse_object(the_repository, &oid);
if (!o) {
packet_write_fmt(1,
"ERR upload-pack: not our ref %s",
@ -1279,7 +1280,7 @@ static int process_haves(struct oid_array *haves, struct oid_array *common)
oid_array_append(common, oid);
o = parse_object(oid);
o = parse_object(the_repository, oid);
if (!o)
die("oops (%s)", oid_to_hex(oid));
if (o->type == OBJ_COMMIT) {