odb: trivial refactorings to get rid of the_repository
All of the external functions provided by the object database subsystem don't depend on `the_repository` anymore, but some internal functions still do. Refactor those cases by plumbing through the repository that owns the object database. This change allows us to get rid of the `USE_THE_REPOSITORY_VARIABLE` preprocessor define. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
fc28a8a856
commit
16cf749496
32
odb.c
32
odb.c
@@ -1,5 +1,3 @@
|
|||||||
#define USE_THE_REPOSITORY_VARIABLE
|
|
||||||
|
|
||||||
#include "git-compat-util.h"
|
#include "git-compat-util.h"
|
||||||
#include "abspath.h"
|
#include "abspath.h"
|
||||||
#include "commit-graph.h"
|
#include "commit-graph.h"
|
||||||
@@ -476,12 +474,13 @@ void odb_add_submodule_source_by_path(struct object_database *odb,
|
|||||||
string_list_insert(&odb->submodule_source_paths, path);
|
string_list_insert(&odb->submodule_source_paths, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_alternate_refs_command(struct child_process *cmd,
|
static void fill_alternate_refs_command(struct repository *repo,
|
||||||
|
struct child_process *cmd,
|
||||||
const char *repo_path)
|
const char *repo_path)
|
||||||
{
|
{
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
if (!git_config_get_value("core.alternateRefsCommand", &value)) {
|
if (!repo_config_get_value(repo, "core.alternateRefsCommand", &value)) {
|
||||||
cmd->use_shell = 1;
|
cmd->use_shell = 1;
|
||||||
|
|
||||||
strvec_push(&cmd->args, value);
|
strvec_push(&cmd->args, value);
|
||||||
@@ -493,7 +492,7 @@ static void fill_alternate_refs_command(struct child_process *cmd,
|
|||||||
strvec_push(&cmd->args, "for-each-ref");
|
strvec_push(&cmd->args, "for-each-ref");
|
||||||
strvec_push(&cmd->args, "--format=%(objectname)");
|
strvec_push(&cmd->args, "--format=%(objectname)");
|
||||||
|
|
||||||
if (!git_config_get_value("core.alternateRefsPrefixes", &value)) {
|
if (!repo_config_get_value(repo, "core.alternateRefsPrefixes", &value)) {
|
||||||
strvec_push(&cmd->args, "--");
|
strvec_push(&cmd->args, "--");
|
||||||
strvec_split(&cmd->args, value);
|
strvec_split(&cmd->args, value);
|
||||||
}
|
}
|
||||||
@@ -503,7 +502,8 @@ static void fill_alternate_refs_command(struct child_process *cmd,
|
|||||||
cmd->out = -1;
|
cmd->out = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_alternate_refs(const char *path,
|
static void read_alternate_refs(struct repository *repo,
|
||||||
|
const char *path,
|
||||||
odb_for_each_alternate_ref_fn *cb,
|
odb_for_each_alternate_ref_fn *cb,
|
||||||
void *payload)
|
void *payload)
|
||||||
{
|
{
|
||||||
@@ -511,7 +511,7 @@ static void read_alternate_refs(const char *path,
|
|||||||
struct strbuf line = STRBUF_INIT;
|
struct strbuf line = STRBUF_INIT;
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
|
|
||||||
fill_alternate_refs_command(&cmd, path);
|
fill_alternate_refs_command(repo, &cmd, path);
|
||||||
|
|
||||||
if (start_command(&cmd))
|
if (start_command(&cmd))
|
||||||
return;
|
return;
|
||||||
@@ -521,7 +521,7 @@ static void read_alternate_refs(const char *path,
|
|||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
if (parse_oid_hex(line.buf, &oid, &p) || *p) {
|
if (parse_oid_hex_algop(line.buf, &oid, &p, repo->hash_algo) || *p) {
|
||||||
warning(_("invalid line while parsing alternate refs: %s"),
|
warning(_("invalid line while parsing alternate refs: %s"),
|
||||||
line.buf);
|
line.buf);
|
||||||
break;
|
break;
|
||||||
@@ -559,7 +559,7 @@ static int refs_from_alternate_cb(struct odb_source *alternate,
|
|||||||
goto out;
|
goto out;
|
||||||
strbuf_setlen(&path, base_len);
|
strbuf_setlen(&path, base_len);
|
||||||
|
|
||||||
read_alternate_refs(path.buf, cb->fn, cb->payload);
|
read_alternate_refs(alternate->odb->repo, path.buf, cb->fn, cb->payload);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
strbuf_release(&path);
|
strbuf_release(&path);
|
||||||
@@ -677,7 +677,7 @@ static int do_oid_object_info_extended(struct repository *r,
|
|||||||
if (oi->disk_sizep)
|
if (oi->disk_sizep)
|
||||||
*(oi->disk_sizep) = 0;
|
*(oi->disk_sizep) = 0;
|
||||||
if (oi->delta_base_oid)
|
if (oi->delta_base_oid)
|
||||||
oidclr(oi->delta_base_oid, the_repository->hash_algo);
|
oidclr(oi->delta_base_oid, r->hash_algo);
|
||||||
if (oi->contentp)
|
if (oi->contentp)
|
||||||
*oi->contentp = xmemdupz(co->buf, co->size);
|
*oi->contentp = xmemdupz(co->buf, co->size);
|
||||||
oi->whence = OI_CACHED;
|
oi->whence = OI_CACHED;
|
||||||
@@ -763,10 +763,10 @@ static int oid_object_info_convert(struct repository *r,
|
|||||||
void *content;
|
void *content;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (repo_oid_to_algop(r, input_oid, the_hash_algo, &oid)) {
|
if (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) {
|
||||||
if (do_die)
|
if (do_die)
|
||||||
die(_("missing mapping of %s to %s"),
|
die(_("missing mapping of %s to %s"),
|
||||||
oid_to_hex(input_oid), the_hash_algo->name);
|
oid_to_hex(input_oid), r->hash_algo->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -797,8 +797,8 @@ static int oid_object_info_convert(struct repository *r,
|
|||||||
struct strbuf outbuf = STRBUF_INIT;
|
struct strbuf outbuf = STRBUF_INIT;
|
||||||
|
|
||||||
if (type != OBJ_BLOB) {
|
if (type != OBJ_BLOB) {
|
||||||
ret = convert_object_file(the_repository, &outbuf,
|
ret = convert_object_file(r, &outbuf,
|
||||||
the_hash_algo, input_algo,
|
r->hash_algo, input_algo,
|
||||||
content, size, type, !do_die);
|
content, size, type, !do_die);
|
||||||
free(content);
|
free(content);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
@@ -944,9 +944,9 @@ void *read_object_with_reference(struct repository *r,
|
|||||||
}
|
}
|
||||||
ref_length = strlen(ref_type);
|
ref_length = strlen(ref_type);
|
||||||
|
|
||||||
if (ref_length + the_hash_algo->hexsz > isize ||
|
if (ref_length + r->hash_algo->hexsz > isize ||
|
||||||
memcmp(buffer, ref_type, ref_length) ||
|
memcmp(buffer, ref_type, ref_length) ||
|
||||||
get_oid_hex((char *) buffer + ref_length, &actual_oid)) {
|
get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, r->hash_algo)) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user