Merge branch 'ab/remove-implicit-use-of-the-repository' into en/header-split-cache-h

* ab/remove-implicit-use-of-the-repository:
  libs: use "struct repository *" argument, not "the_repository"
  post-cocci: adjust comments for recent repo_* migration
  cocci: apply the "revision.h" part of "the_repository.pending"
  cocci: apply the "rerere.h" part of "the_repository.pending"
  cocci: apply the "refs.h" part of "the_repository.pending"
  cocci: apply the "promisor-remote.h" part of "the_repository.pending"
  cocci: apply the "packfile.h" part of "the_repository.pending"
  cocci: apply the "pretty.h" part of "the_repository.pending"
  cocci: apply the "object-store.h" part of "the_repository.pending"
  cocci: apply the "diff.h" part of "the_repository.pending"
  cocci: apply the "commit.h" part of "the_repository.pending"
  cocci: apply the "commit-reach.h" part of "the_repository.pending"
  cocci: apply the "cache.h" part of "the_repository.pending"
  cocci: add missing "the_repository" macros to "pending"
  cocci: sort "the_repository" rules by header
  cocci: fix incorrect & verbose "the_repository" rules
  cocci: remove dead rule from "the_repository.pending.cocci"
This commit is contained in:
Junio C Hamano 2023-04-04 08:25:52 -07:00
commit e7dca80692
148 changed files with 958 additions and 873 deletions

View File

@ -553,7 +553,7 @@ static int get_modified_files(struct repository *r,
opt.def = is_initial ?
empty_tree_oid_hex() : oid_to_hex(&head_oid);
init_revisions(&rev, NULL);
repo_init_revisions(r, &rev, NULL);
setup_revisions(0, NULL, &rev, &opt);
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;

View File

@ -417,7 +417,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
strvec_push(&args,
/* could be on an unborn branch */
!strcmp("HEAD", s->revision) &&
get_oid("HEAD", &oid) ?
repo_get_oid(the_repository, "HEAD", &oid) ?
empty_tree_oid_hex() : s->revision);
}
color_arg_index = args.nr;

13
apply.c
View File

@ -3208,7 +3208,8 @@ static int apply_binary(struct apply_state *state,
unsigned long size;
char *result;
result = read_object_file(&oid, &type, &size);
result = repo_read_object_file(the_repository, &oid, &type,
&size);
if (!result)
return error(_("the necessary postimage %s for "
"'%s' cannot be read"),
@ -3271,7 +3272,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
unsigned long sz;
char *result;
result = read_object_file(oid, &type, &sz);
result = repo_read_object_file(the_repository, oid, &type,
&sz);
if (!result)
return -1;
/* XXX read_sha1_file NUL-terminates */
@ -3499,7 +3501,8 @@ static int resolve_to(struct image *image, const struct object_id *result_id)
clear_image(image);
image->buf = read_object_file(result_id, &type, &size);
image->buf = repo_read_object_file(the_repository, result_id, &type,
&size);
if (!image->buf || type != OBJ_BLOB)
die("unable to read blob object %s", oid_to_hex(result_id));
image->len = size;
@ -3617,7 +3620,7 @@ static int try_threeway(struct apply_state *state,
/* Preimage the patch was prepared for */
if (patch->is_new)
write_object_file("", 0, OBJ_BLOB, &pre_oid);
else if (get_oid(patch->old_oid_prefix, &pre_oid) ||
else if (repo_get_oid(the_repository, patch->old_oid_prefix, &pre_oid) ||
read_blob_object(&buf, &pre_oid, patch->old_mode))
return error(_("repository lacks the necessary blob to perform 3-way merge."));
@ -4134,7 +4137,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
else
return error(_("sha1 information is lacking or "
"useless for submodule %s"), name);
} else if (!get_oid_blob(patch->old_oid_prefix, &oid)) {
} else if (!repo_get_oid_blob(the_repository, patch->old_oid_prefix, &oid)) {
; /* ok */
} else if (!patch->lines_added && !patch->lines_deleted) {
/* mode-only change: update the current */

View File

@ -65,7 +65,8 @@ static void format_subst(const struct commit *commit,
strbuf_add(&fmt, b + 8, c - b - 8);
strbuf_add(buf, src, b - src);
format_commit_message(commit, fmt.buf, buf, ctx);
repo_format_commit_message(the_repository, commit, fmt.buf,
buf, ctx);
len -= c + 1 - src;
src = c + 1;
}
@ -90,7 +91,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
(args->tree ? &args->tree->object.oid : NULL), oid);
path += args->baselen;
buffer = read_object_file(oid, type, sizep);
buffer = repo_read_object_file(the_repository, oid, type, sizep);
if (buffer && S_ISREG(mode)) {
struct strbuf buf = STRBUF_INIT;
size_t size = 0;
@ -461,13 +462,14 @@ static void parse_treeish_arg(const char **argv,
const char *colon = strchrnul(name, ':');
int refnamelen = colon - name;
if (!dwim_ref(name, refnamelen, &oid, &ref, 0))
if (!repo_dwim_ref(the_repository, name, refnamelen, &oid, &ref, 0))
die(_("no such ref: %.*s"), refnamelen, name);
} else {
dwim_ref(name, strlen(name), &oid, &ref, 0);
repo_dwim_ref(the_repository, name, strlen(name), &oid, &ref,
0);
}
if (get_oid(name, &oid))
if (repo_get_oid(the_repository, name, &oid))
die(_("not a valid object name: %s"), name);
commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);

View File

@ -151,7 +151,8 @@ static void show_list(const char *debug, int counted, int nr,
unsigned commit_flags = commit->object.flags;
enum object_type type;
unsigned long size;
char *buf = read_object_file(&commit->object.oid, &type,
char *buf = repo_read_object_file(the_repository,
&commit->object.oid, &type,
&size);
const char *subject_start;
int subject_len;
@ -754,7 +755,8 @@ enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
}
commit = lookup_commit_reference(the_repository, bisect_rev);
format_commit_message(commit, "[%H] %s%n", &commit_msg, &pp);
repo_format_commit_message(the_repository, commit, "[%H] %s%n",
&commit_msg, &pp);
fputs(commit_msg.buf, stdout);
strbuf_release(&commit_msg);
@ -849,7 +851,8 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, int
enum bisect_error res = BISECT_OK;
struct commit_list *result;
result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
result = repo_get_merge_bases_many(the_repository, rev[0], rev_nr - 1,
rev + 1);
for (; result; result = result->next) {
const struct object_id *mb = &result->item->object.oid;

11
blame.c
View File

@ -1031,7 +1031,8 @@ static void fill_origin_blob(struct diff_options *opt,
&o->blob_oid, 1, &file->ptr, &file_size))
;
else
file->ptr = read_object_file(&o->blob_oid, &type,
file->ptr = repo_read_object_file(the_repository,
&o->blob_oid, &type,
&file_size);
file->size = file_size;
@ -2432,7 +2433,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
if (sg_origin[i])
continue;
if (parse_commit(p))
if (repo_parse_commit(the_repository, p))
continue;
porigin = find(sb->repo, p, origin, sb->bloom_data);
if (!porigin)
@ -2595,7 +2596,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)
* so hold onto it in the meantime.
*/
blame_origin_incref(suspect);
parse_commit(commit);
repo_parse_commit(the_repository, commit);
if (sb->reverse ||
(!(commit->object.flags & UNINTERESTING) &&
!(revs->max_age != -1 && commit->date < revs->max_age)))
@ -2841,7 +2842,9 @@ void setup_scoreboard(struct blame_scoreboard *sb,
&sb->final_buf_size))
;
else
sb->final_buf = read_object_file(&o->blob_oid, &type,
sb->final_buf = repo_read_object_file(the_repository,
&o->blob_oid,
&type,
&sb->final_buf_size);
if (!sb->final_buf)

View File

@ -534,7 +534,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
explicit_tracking = 1;
real_ref = NULL;
if (get_oid_mb(start_name, &oid)) {
if (repo_get_oid_mb(r, start_name, &oid)) {
if (explicit_tracking) {
int code = die_message(_(upstream_missing), start_name);
advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
@ -544,7 +544,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
die(_("not a valid object name: '%s'"), start_name);
}
switch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref, 0)) {
switch (repo_dwim_ref(r, start_name, strlen(start_name), &oid,
&real_ref, 0)) {
case 0:
/* Not branching from any existing branch */
if (explicit_tracking)
@ -775,7 +776,7 @@ void create_branches_recursively(struct repository *r, const char *name,
name);
}
create_branch(the_repository, name, start_commitish, force, 0, reflog, quiet,
create_branch(r, name, start_commitish, force, 0, reflog, quiet,
BRANCH_TRACK_NEVER, dry_run);
if (dry_run)
return;

View File

@ -1071,7 +1071,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
else
write_state_text(state, "applying", "");
if (!get_oid("HEAD", &curr_head)) {
if (!repo_get_oid(the_repository, "HEAD", &curr_head)) {
write_state_text(state, "abort-safety", oid_to_hex(&curr_head));
if (!state->rebasing)
update_ref("am", "ORIG_HEAD", &curr_head, NULL, 0,
@ -1114,7 +1114,7 @@ static void am_next(struct am_state *state)
unlink(am_path(state, "original-commit"));
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
if (!get_oid("HEAD", &head))
if (!repo_get_oid(the_repository, "HEAD", &head))
write_state_text(state, "abort-safety", oid_to_hex(&head));
else
write_state_text(state, "abort-safety", "");
@ -1334,7 +1334,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
size_t ident_len;
struct ident_split id;
buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());
buffer = repo_logmsg_reencode(the_repository, commit, NULL,
get_commit_output_encoding());
ident_line = find_commit_header(buffer, "author", &ident_len);
if (!ident_line)
@ -1366,7 +1367,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
state->msg = xstrdup(msg + 2);
state->msg_len = strlen(state->msg);
unuse_commit_buffer(commit, buffer);
repo_unuse_commit_buffer(the_repository, commit, buffer);
}
/**
@ -1407,9 +1408,9 @@ static void write_index_patch(const struct am_state *state)
struct rev_info rev_info;
FILE *fp;
if (!get_oid("HEAD", &head)) {
if (!repo_get_oid(the_repository, "HEAD", &head)) {
struct commit *commit = lookup_commit_or_die(&head, "HEAD");
tree = get_commit_tree(commit);
tree = repo_get_commit_tree(the_repository, commit);
} else
tree = lookup_tree(the_repository,
the_repository->hash_algo->empty_tree);
@ -1561,7 +1562,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
struct commit *result;
char *their_tree_name;
if (get_oid("HEAD", &our_tree) < 0)
if (repo_get_oid(the_repository, "HEAD", &our_tree) < 0)
oidcpy(&our_tree, the_hash_algo->empty_tree);
if (build_fake_ancestor(state, index_path))
@ -1651,7 +1652,7 @@ static void do_commit(const struct am_state *state)
if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL))
die(_("git write-tree failed to write a tree"));
if (!get_oid_commit("HEAD", &parent)) {
if (!repo_get_oid_commit(the_repository, "HEAD", &parent)) {
old_oid = &parent;
commit_list_insert(lookup_commit(the_repository, &parent),
&parents);
@ -2093,7 +2094,7 @@ static void am_skip(struct am_state *state)
am_rerere_clear();
if (get_oid("HEAD", &head))
if (repo_get_oid(the_repository, "HEAD", &head))
oidcpy(&head, the_hash_algo->empty_tree);
if (clean_index(&head, &head))
@ -2135,7 +2136,7 @@ static int safe_to_abort(const struct am_state *state)
oidclr(&abort_safety);
strbuf_release(&sb);
if (get_oid("HEAD", &head))
if (repo_get_oid(the_repository, "HEAD", &head))
oidclr(&head);
if (oideq(&head, &abort_safety))
@ -2168,7 +2169,7 @@ static void am_abort(struct am_state *state)
if (!has_curr_head)
oidcpy(&curr_head, the_hash_algo->empty_tree);
has_orig_head = !get_oid("ORIG_HEAD", &orig_head);
has_orig_head = !repo_get_oid(the_repository, "ORIG_HEAD", &orig_head);
if (!has_orig_head)
oidcpy(&orig_head, the_hash_algo->empty_tree);

View File

@ -239,7 +239,7 @@ static int bisect_reset(const char *commit)
} else {
struct object_id oid;
if (get_oid_commit(commit, &oid))
if (repo_get_oid_commit(the_repository, commit, &oid))
return error(_("'%s' is not a valid commit"), commit);
strbuf_addstr(&branch, commit);
}
@ -270,7 +270,8 @@ static void log_commit(FILE *fp, char *fmt, const char *state,
struct strbuf commit_msg = STRBUF_INIT;
char *label = xstrfmt(fmt, state);
format_commit_message(commit, "%s", &commit_msg, &pp);
repo_format_commit_message(the_repository, commit, "%s", &commit_msg,
&pp);
fprintf(fp, "# %s: [%s] %s\n", label, oid_to_hex(&commit->object.oid),
commit_msg.buf);
@ -297,7 +298,7 @@ static int bisect_write(const char *state, const char *rev,
goto finish;
}
if (get_oid(rev, &oid)) {
if (repo_get_oid(the_repository, rev, &oid)) {
res = error(_("couldn't get the oid of the rev '%s'"), rev);
goto finish;
}
@ -572,7 +573,7 @@ static int prepare_revs(struct bisect_terms *terms, struct rev_info *revs)
* sets up a revision walk.
*/
reset_revision_walk();
init_revisions(revs, NULL);
repo_init_revisions(the_repository, revs, NULL);
setup_revisions(0, NULL, revs, NULL);
for_each_glob_ref_in(add_bisect_ref, bad, "refs/bisect/", &cb);
cb.object_flags = UNINTERESTING;
@ -608,7 +609,7 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
while ((commit = get_revision(&revs)) != NULL) {
strbuf_reset(&commit_name);
format_commit_message(commit, "%s",
repo_format_commit_message(the_repository, commit, "%s",
&commit_name, &pp);
fprintf(fp, "# possible first %s commit: [%s] %s\n",
terms->term_bad, oid_to_hex(&commit->object.oid),
@ -638,7 +639,8 @@ static int bisect_successful(struct bisect_terms *terms)
read_ref(bad_ref, &oid);
commit = lookup_commit_reference_by_name(bad_ref);
format_commit_message(commit, "%s", &commit_name, &pp);
repo_format_commit_message(the_repository, commit, "%s", &commit_name,
&pp);
res = append_to_file(git_path_bisect_log(), "# first %s commit: [%s] %s\n",
terms->term_bad, oid_to_hex(&commit->object.oid),
@ -780,7 +782,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
*/
head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags);
if (!head)
if (get_oid("HEAD", &head_oid))
if (repo_get_oid(the_repository, "HEAD", &head_oid))
return error(_("bad HEAD - I need a HEAD"));
/*
@ -806,11 +808,11 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
}
} else {
/* Get the rev from where we start. */
if (!get_oid(head, &head_oid) &&
if (!repo_get_oid(the_repository, head, &head_oid) &&
!starts_with(head, "refs/heads/")) {
strbuf_reset(&start_head);
strbuf_addstr(&start_head, oid_to_hex(&head_oid));
} else if (!get_oid(head, &head_oid) &&
} else if (!repo_get_oid(the_repository, head, &head_oid) &&
skip_prefix(head, "refs/heads/", &head)) {
strbuf_addstr(&start_head, head);
} else {
@ -833,7 +835,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
write_file(git_path_bisect_first_parent(), "\n");
if (no_checkout) {
if (get_oid(start_head.buf, &oid) < 0) {
if (repo_get_oid(the_repository, start_head.buf, &oid) < 0) {
res = error(_("invalid ref: '%s'"), start_head.buf);
goto finish;
}
@ -938,11 +940,12 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
if (argc == 0) {
const char *head = "BISECT_HEAD";
enum get_oid_result res_head = get_oid(head, &oid);
enum get_oid_result res_head = repo_get_oid(the_repository,
head, &oid);
if (res_head == MISSING_OBJECT) {
head = "HEAD";
res_head = get_oid(head, &oid);
res_head = repo_get_oid(the_repository, head, &oid);
}
if (res_head)
@ -958,7 +961,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
for (; argc; argc--, argv++) {
struct commit *commit;
if (get_oid(*argv, &oid)){
if (repo_get_oid(the_repository, *argv, &oid)){
error(_("Bad rev input: %s"), *argv);
oid_array_clear(&revs);
return BISECT_FAILED;
@ -1097,7 +1100,7 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, int argc,
struct rev_info revs;
struct commit *commit;
init_revisions(&revs, NULL);
repo_init_revisions(the_repository, &revs, NULL);
setup_revisions(2, argv + i - 1, &revs, NULL);
if (prepare_revision_walk(&revs))

View File

@ -205,13 +205,13 @@ static void get_commit_info(struct commit *commit,
const char *message;
encoding = get_log_output_encoding();
message = logmsg_reencode(commit, NULL, encoding);
message = repo_logmsg_reencode(the_repository, commit, NULL, encoding);
get_ac_line(message, "\nauthor ",
&ret->author, &ret->author_mail,
&ret->author_time, &ret->author_tz);
if (!detailed) {
unuse_commit_buffer(commit, message);
repo_unuse_commit_buffer(the_repository, commit, message);
return;
}
@ -225,7 +225,7 @@ static void get_commit_info(struct commit *commit,
else
strbuf_addf(&ret->summary, "(%s)", oid_to_hex(&commit->object.oid));
unuse_commit_buffer(commit, message);
repo_unuse_commit_buffer(the_repository, commit, message);
}
/*
@ -607,7 +607,8 @@ static int read_ancestry(const char *graft_file)
static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect)
{
const char *uniq = find_unique_abbrev(&suspect->commit->object.oid,
const char *uniq = repo_find_unique_abbrev(the_repository,
&suspect->commit->object.oid,
auto_abbrev);
int len = strlen(uniq);
if (auto_abbrev < len)
@ -808,7 +809,7 @@ static int is_a_rev(const char *name)
{
struct object_id oid;
if (get_oid(name, &oid))
if (repo_get_oid(the_repository, name, &oid))
return 0;
return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
}
@ -851,7 +852,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,
peel_to_commit_oid, sb);
}
for_each_string_list_item(i, ignore_rev_list) {
if (get_oid_committish(i->string, &oid) ||
if (repo_get_oid_committish(the_repository, i->string, &oid) ||
peel_to_commit_oid(&oid, sb))
die(_("cannot find revision %s to ignore"), i->string);
oidset_insert(&sb->ignore_list, &oid);

View File

@ -153,17 +153,18 @@ static int branch_merged(int kind, const char *name,
if (!reference_rev)
reference_rev = head_rev;
merged = reference_rev ? in_merge_bases(rev, reference_rev) : 0;
merged = reference_rev ? repo_in_merge_bases(the_repository, rev,
reference_rev) : 0;
/*
* After the safety valve is fully redefined to "check with
* upstream, if any, otherwise with HEAD", we should just
* return the result of the in_merge_bases() above without
* return the result of the repo_in_merge_bases() above without
* any of the following code, but during the transition period,
* a gentle reminder is in order.
*/
if ((head_rev != reference_rev) &&
(head_rev ? in_merge_bases(rev, head_rev) : 0) != merged) {
(head_rev ? repo_in_merge_bases(the_repository, rev, head_rev) : 0) != merged) {
if (merged)
warning(_("deleting branch '%s' that has been merged to\n"
" '%s', but not yet merged to HEAD."),
@ -283,7 +284,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
item = string_list_append(&refs_to_delete, name);
item->util = xstrdup((flags & REF_ISBROKEN) ? "broken"
: (flags & REF_ISSYMREF) ? target
: find_unique_abbrev(&oid, DEFAULT_ABBREV));
: repo_find_unique_abbrev(the_repository, &oid, DEFAULT_ABBREV));
next:
free(target);

View File

@ -67,7 +67,7 @@ static int filter_object(const char *path, unsigned mode,
{
enum object_type type;
*buf = read_object_file(oid, &type, size);
*buf = repo_read_object_file(the_repository, oid, &type, size);
if (!*buf)
return error(_("cannot read object %s '%s'"),
oid_to_hex(oid), path);
@ -159,7 +159,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
goto cleanup;
case 'e':
return !has_object_file(&oid);
return !repo_has_object_file(the_repository, &oid);
case 'w':
@ -194,7 +194,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
ret = stream_blob(&oid);
goto cleanup;
}
buf = read_object_file(&oid, &type, &size);
buf = repo_read_object_file(the_repository, &oid, &type,
&size);
if (!buf)
die("Cannot read object %s", obj_name);
@ -214,7 +215,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
if (exp_type_id == OBJ_BLOB) {
struct object_id blob_oid;
if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
char *buffer = read_object_file(&oid, &type,
char *buffer = repo_read_object_file(the_repository,
&oid,
&type,
&size);
const char *target;
if (!skip_prefix(buffer, "object ", &target) ||
@ -390,7 +393,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
if (!textconv_object(the_repository,
data->rest, 0100644, oid,
1, &contents, &size))
contents = read_object_file(oid,
contents = repo_read_object_file(the_repository,
oid,
&type,
&size);
if (!contents)
@ -409,7 +413,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
unsigned long size;
void *contents;
contents = read_object_file(oid, &type, &size);
contents = repo_read_object_file(the_repository, oid, &type,
&size);
if (use_mailmap) {
size_t s = size;
@ -794,7 +799,7 @@ static int batch_objects(struct batch_options *opt)
if (!memcmp(&data.info, &empty, sizeof(empty)))
data.skip_object_info = 1;
if (has_promisor_remote())
if (repo_has_promisor_remote(the_repository))
warning("This repository uses promisor remotes. Some objects may not be loaded.");
read_replace_refs = 0;

View File

@ -436,7 +436,7 @@ static int checkout_worktree(const struct checkout_opts *opts,
"Updated %d paths from %s",
nr_checkouts),
nr_checkouts,
find_unique_abbrev(&opts->source_tree->object.oid,
repo_find_unique_abbrev(the_repository, &opts->source_tree->object.oid,
DEFAULT_ABBREV));
else if (!nr_unmerged || nr_checkouts)
fprintf_ln(stderr, Q_("Updated %d path from the index",
@ -657,14 +657,16 @@ static void describe_detached_head(const char *msg, struct commit *commit)
{
struct strbuf sb = STRBUF_INIT;
if (!parse_commit(commit))
if (!repo_parse_commit(the_repository, commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
if (print_sha1_ellipsis()) {
fprintf(stderr, "%s %s... %s\n", msg,
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
sb.buf);
} else {
fprintf(stderr, "%s %s %s\n", msg,
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
sb.buf);
}
strbuf_release(&sb);
}
@ -718,7 +720,8 @@ static void setup_branch_path(struct branch_info *branch)
* If this is a ref, resolve it; otherwise, look up the OID for our
* expression. Failure here is okay.
*/
if (!dwim_ref(branch->name, strlen(branch->name), &branch->oid, &branch->refname, 0))
if (!repo_dwim_ref(the_repository, branch->name, strlen(branch->name),
&branch->oid, &branch->refname, 0))
repo_get_oid_committish(the_repository, branch->name, &branch->oid);
strbuf_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL);
@ -770,7 +773,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
BUG("'switch --orphan' should never accept a commit as starting point");
new_tree = parse_tree_indirect(the_hash_algo->empty_tree);
} else
new_tree = get_commit_tree(new_branch_info->commit);
new_tree = repo_get_commit_tree(the_repository,
new_branch_info->commit);
if (opts->discard_changes) {
ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info);
if (ret)
@ -832,7 +836,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
*/
if (!old_branch_info->commit)
return 1;
old_tree = get_commit_tree(old_branch_info->commit);
old_tree = repo_get_commit_tree(the_repository,
old_branch_info->commit);
if (repo_index_has_changes(the_repository, old_tree, &sb))
die(_("cannot continue with staged changes in "
@ -1021,7 +1026,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
strbuf_addstr(sb, " ");
strbuf_add_unique_abbrev(sb, &commit->object.oid, DEFAULT_ABBREV);
strbuf_addch(sb, ' ');
if (!parse_commit(commit))
if (!repo_parse_commit(the_repository, commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
strbuf_addch(sb, '\n');
}
@ -1077,7 +1082,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
" git branch <new-branch-name> %s\n\n",
/* Give ngettext() the count */
lost),
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
}
/*
@ -1221,7 +1226,8 @@ static void setup_new_branch_info_and_source_tree(
*source_tree = parse_tree_indirect(rev);
} else {
parse_commit_or_die(new_branch_info->commit);
*source_tree = get_commit_tree(new_branch_info->commit);
*source_tree = repo_get_commit_tree(the_repository,
new_branch_info->commit);
}
}
@ -1339,7 +1345,7 @@ static int parse_branchname_arg(int argc, const char **argv,
if (!strcmp(arg, "-"))
arg = "@{-1}";
if (get_oid_mb(arg, rev)) {
if (repo_get_oid_mb(the_repository, arg, rev)) {
/*
* Either case (3) or (4), with <something> not being
* a commit, or an attempt to use case (1) with an
@ -1436,7 +1442,8 @@ static void die_expecting_a_branch(const struct branch_info *branch_info)
char *to_free;
int code;
if (dwim_ref(branch_info->name, strlen(branch_info->name), &oid, &to_free, 0) == 1) {
if (repo_dwim_ref(the_repository, branch_info->name,
strlen(branch_info->name), &oid, &to_free, 0) == 1) {
const char *ref = to_free;
if (skip_prefix(ref, "refs/tags/", &ref))
@ -1765,7 +1772,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
} else if (!opts->accept_ref && opts->from_treeish) {
struct object_id rev;
if (get_oid_mb(opts->from_treeish, &rev))
if (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))
die(_("could not resolve %s"), opts->from_treeish);
setup_new_branch_info_and_source_tree(new_branch_info,

View File

@ -552,7 +552,7 @@ static void write_followtags(const struct ref *refs, const char *msg)
continue;
if (ends_with(ref->name, "^{}"))
continue;
if (!has_object_file_with_flags(&ref->old_oid,
if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
OBJECT_INFO_QUICK |
OBJECT_INFO_SKIP_FETCH_OBJECT))
continue;

View File

@ -47,7 +47,7 @@ static int parse_parent_arg_callback(const struct option *opt,
BUG_ON_OPT_NEG_NOARG(unset, arg);
if (get_oid_commit(arg, &oid))
if (repo_get_oid_commit(the_repository, arg, &oid))
die(_("not a valid object name %s"), arg);
assert_oid_type(&oid, OBJ_COMMIT);
@ -125,7 +125,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
if (argc != 1)
die(_("must give exactly one tree"));
if (get_oid_tree(argv[0], &tree_oid))
if (repo_get_oid_tree(the_repository, argv[0], &tree_oid))
die(_("not a valid object name %s"), argv[0]);
if (!buffer.len) {

View File

@ -559,7 +559,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
s->index_file = index_file;
s->fp = fp;
s->nowarn = nowarn;
s->is_initial = get_oid(s->reference, &oid) ? 1 : 0;
s->is_initial = repo_get_oid(the_repository, s->reference, &oid) ? 1 : 0;
if (!s->is_initial)
oidcpy(&s->oid_commit, &oid);
s->status_format = status_format;
@ -714,15 +714,15 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
{
const char *buffer, *subject, *fmt;
buffer = get_commit_buffer(commit, NULL);
buffer = repo_get_commit_buffer(the_repository, commit, NULL);
find_commit_subject(buffer, &subject);
/*
* If we amend the 'amend!' commit then we don't want to
* duplicate the subject line.
*/
fmt = starts_with(subject, "amend!") ? "%b" : "%B";
format_commit_message(commit, fmt, sb, ctx);
unuse_commit_buffer(commit, buffer);
repo_format_commit_message(the_repository, commit, fmt, sb, ctx);
repo_unuse_commit_buffer(the_repository, commit, buffer);
}
static int prepare_to_commit(const char *index_file, const char *prefix,
@ -762,7 +762,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (!c)
die(_("could not lookup commit %s"), squash_message);
ctx.output_encoding = get_commit_output_encoding();
format_commit_message(c, "squash! %s\n\n", &sb,
repo_format_commit_message(the_repository, c,
"squash! %s\n\n", &sb,
&ctx);
}
}
@ -797,7 +798,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
die(_("could not lookup commit %s"), fixup_commit);
ctx.output_encoding = get_commit_output_encoding();
fmt = xstrfmt("%s! %%s\n\n", fixup_prefix);
format_commit_message(commit, fmt, &sb, &ctx);
repo_format_commit_message(the_repository, commit, fmt, &sb,
&ctx);
free(fmt);
hook_arg1 = "message";
@ -1002,7 +1004,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (amend)
parent = "HEAD^1";
if (get_oid(parent, &oid)) {
if (repo_get_oid(the_repository, parent, &oid)) {
int i, ita_nr = 0;
/* TODO: audit for interaction with sparse-index. */
@ -1137,7 +1139,8 @@ static const char *find_author_by_nickname(const char *name)
struct pretty_print_context ctx = {0};
ctx.date_mode.type = DATE_NORMAL;
strbuf_release(&buf);
format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
repo_format_commit_message(the_repository, commit,
"%aN <%aE>", &buf, &ctx);
release_revisions(&revs);
return strbuf_detach(&buf, NULL);
}
@ -1185,7 +1188,7 @@ static const char *read_commit_message(const char *name)
if (!commit)
die(_("could not lookup commit %s"), name);
out_enc = get_commit_output_encoding();
return logmsg_reencode(commit, NULL, out_enc);
return repo_logmsg_reencode(the_repository, commit, NULL, out_enc);
}
/*
@ -1569,7 +1572,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
else
fd = -1;
s.is_initial = get_oid(s.reference, &oid) ? 1 : 0;
s.is_initial = repo_get_oid(the_repository, s.reference, &oid) ? 1 : 0;
if (!s.is_initial)
oidcpy(&s.oid_commit, &oid);
@ -1712,11 +1715,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
s.colopts = 0;
if (get_oid("HEAD", &oid))
if (repo_get_oid(the_repository, "HEAD", &oid))
current_head = NULL;
else {
current_head = lookup_commit_or_die(&oid, "HEAD");
if (parse_commit(current_head))
if (repo_parse_commit(the_repository, current_head))
die(_("could not parse HEAD commit"));
}
verbose = -1; /* unspecified */

View File

@ -265,7 +265,7 @@ static unsigned long finish_depth_computation(
best->depth++;
while (parents) {
struct commit *p = parents->item;
parse_commit(p);
repo_parse_commit(the_repository, p);
if (!(p->object.flags & SEEN))
commit_list_insert_by_date(p, list);
p->object.flags |= c->object.flags;
@ -302,7 +302,8 @@ static void append_name(struct commit_name *n, struct strbuf *dst)
static void append_suffix(int depth, const struct object_id *oid, struct strbuf *dst)
{
strbuf_addf(dst, "-%d-g%s", depth, find_unique_abbrev(oid, abbrev));
strbuf_addf(dst, "-%d-g%s", depth,
repo_find_unique_abbrev(the_repository, oid, abbrev));
}
static void describe_commit(struct object_id *oid, struct strbuf *dst)
@ -407,7 +408,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
}
while (parents) {
struct commit *p = parents->item;
parse_commit(p);
repo_parse_commit(the_repository, p);
if (!(p->object.flags & SEEN))
commit_list_insert_by_date(p, &list);
p->object.flags |= c->object.flags;
@ -535,7 +536,7 @@ static void describe(const char *arg, int last_one)
if (debug)
fprintf(stderr, _("describe %s\n"), arg);
if (get_oid(arg, &oid))
if (repo_get_oid(the_repository, arg, &oid))
die(_("Not a valid object name %s"), arg);
cmit = lookup_commit_reference_gently(the_repository, &oid, 1);

View File

@ -550,7 +550,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
if (!obj)
die(_("invalid object '%s' given."), name);
if (obj->type == OBJ_COMMIT)
obj = &get_commit_tree(((struct commit *)obj))->object;
obj = &repo_get_commit_tree(the_repository,
((struct commit *)obj))->object;
if (obj->type == OBJ_TREE) {
if (sdiff.skip && bitmap_get(sdiff.skip, i))

View File

@ -301,7 +301,8 @@ static char *get_symlink(const struct object_id *oid, const char *path)
} else {
enum object_type type;
unsigned long size;
data = read_object_file(oid, &type, &size);
data = repo_read_object_file(the_repository, oid, &type,
&size);
if (!data)
die(_("could not read object %s for symlink %s"),
oid_to_hex(oid), path);

View File

@ -298,7 +298,7 @@ static void export_blob(const struct object_id *oid)
object = (struct object *)lookup_blob(the_repository, oid);
eaten = 0;
} else {
buf = read_object_file(oid, &type, &size);
buf = repo_read_object_file(the_repository, oid, &type, &size);
if (!buf)
die("could not read blob %s", oid_to_hex(oid));
if (check_object_signature(the_repository, oid, buf, size,
@ -620,7 +620,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
rev->diffopt.output_format = DIFF_FORMAT_CALLBACK;
parse_commit_or_die(commit);
commit_buffer = get_commit_buffer(commit, NULL);
commit_buffer = repo_get_commit_buffer(the_repository, commit, NULL);
author = strstr(commit_buffer, "\nauthor ");
if (!author)
die("could not find author in commit %s",
@ -701,7 +701,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
? strlen(message) : 0),
reencoded ? reencoded : message ? message : "");
free(reencoded);
unuse_commit_buffer(commit, commit_buffer);
repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
for (i = 0, p = commit->parents; p; p = p->next) {
struct object *obj = &p->item->object;
@ -768,7 +768,8 @@ static void handle_tag(const char *name, struct tag *tag)
return;
}
buf = read_object_file(&tag->object.oid, &type, &size);
buf = repo_read_object_file(the_repository, &tag->object.oid, &type,
&size);
if (!buf)
die("could not read tag %s", oid_to_hex(&tag->object.oid));
message = memmem(buf, size, "\n\n", 2);
@ -919,7 +920,8 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
if (e->flags & UNINTERESTING)
continue;
if (dwim_ref(e->name, strlen(e->name), &oid, &full_name, 0) != 1)
if (repo_dwim_ref(the_repository, e->name, strlen(e->name),
&oid, &full_name, 0) != 1)
continue;
if (refspecs.nr) {

View File

@ -1270,7 +1270,7 @@ static void load_tree(struct tree_entry *root)
die("Can't load tree %s", oid_to_hex(oid));
} else {
enum object_type type;
buf = read_object_file(oid, &type, &size);
buf = repo_read_object_file(the_repository, oid, &type, &size);
if (!buf || type != OBJ_TREE)
die("Can't load tree %s", oid_to_hex(oid));
}
@ -1630,7 +1630,7 @@ static int update_branch(struct branch *b)
if (!old_cmit || !new_cmit)
return error("Branch %s is missing commits.", b->name);
if (!in_merge_bases(old_cmit, new_cmit)) {
if (!repo_in_merge_bases(the_repository, old_cmit, new_cmit)) {
warning("Not updating %s"
" (new tip %s does not contain %s)",
b->name, oid_to_hex(&b->oid),
@ -2491,7 +2491,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
if (commit_oe->type != OBJ_COMMIT)
die("Mark :%" PRIuMAX " not a commit", commit_mark);
oidcpy(&commit_oid, &commit_oe->idx.oid);
} else if (!get_oid(p, &commit_oid)) {
} else if (!repo_get_oid(the_repository, p, &commit_oid)) {
unsigned long size;
char *buf = read_object_with_reference(the_repository,
&commit_oid,
@ -2604,7 +2604,7 @@ static int parse_objectish(struct branch *b, const char *objectish)
} else
parse_from_existing(b);
}
} else if (!get_oid(objectish, &b->oid)) {
} else if (!repo_get_oid(the_repository, objectish, &b->oid)) {
parse_from_existing(b);
if (is_null_oid(&b->oid))
b->delete = 1;
@ -2659,7 +2659,7 @@ static struct hash_list *parse_merge(unsigned int *count)
if (oe->type != OBJ_COMMIT)
die("Mark :%" PRIuMAX " not a commit", idnum);
oidcpy(&n->oid, &oe->idx.oid);
} else if (!get_oid(from, &n->oid)) {
} else if (!repo_get_oid(the_repository, from, &n->oid)) {
unsigned long size;
char *buf = read_object_with_reference(the_repository,
&n->oid,
@ -2832,7 +2832,7 @@ static void parse_new_tag(const char *arg)
oe = find_mark(marks, from_mark);
type = oe->type;
oidcpy(&oid, &oe->idx.oid);
} else if (!get_oid(from, &oid)) {
} else if (!repo_get_oid(the_repository, from, &oid)) {
struct object_entry *oe = find_object(&oid);
if (!oe) {
type = oid_object_info(the_repository, &oid, NULL);
@ -2941,7 +2941,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
char *buf;
if (!oe || oe->pack_id == MAX_PACK_ID) {
buf = read_object_file(oid, &type, &size);
buf = repo_read_object_file(the_repository, oid, &type, &size);
} else {
type = oe->type;
buf = gfi_unpack_entry(oe, &size);
@ -3049,7 +3049,8 @@ static struct object_entry *dereference(struct object_entry *oe,
buf = gfi_unpack_entry(oe, &size);
} else {
enum object_type unused;
buf = read_object_file(oid, &unused, &size);
buf = repo_read_object_file(the_repository, oid, &unused,
&size);
}
if (!buf)
die("Can't load object %s", oid_to_hex(oid));

View File

@ -410,9 +410,9 @@ static void find_non_local_tags(const struct ref *refs,
*/
if (ends_with(ref->name, "^{}")) {
if (item &&
!has_object_file_with_flags(&ref->old_oid, quick_flags) &&
!repo_has_object_file_with_flags(the_repository, &ref->old_oid, quick_flags) &&
!oidset_contains(&fetch_oids, &ref->old_oid) &&
!has_object_file_with_flags(&item->oid, quick_flags) &&
!repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
!oidset_contains(&fetch_oids, &item->oid))
clear_item(item);
item = NULL;
@ -426,7 +426,7 @@ static void find_non_local_tags(const struct ref *refs,
* fetch.
*/
if (item &&
!has_object_file_with_flags(&item->oid, quick_flags) &&
!repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
!oidset_contains(&fetch_oids, &item->oid))
clear_item(item);
@ -447,7 +447,7 @@ static void find_non_local_tags(const struct ref *refs,
* checked to see if it needs fetching.
*/
if (item &&
!has_object_file_with_flags(&item->oid, quick_flags) &&
!repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) &&
!oidset_contains(&fetch_oids, &item->oid))
clear_item(item);
@ -968,7 +968,8 @@ static int update_local_ref(struct ref *ref,
if (fetch_show_forced_updates) {
uint64_t t_before = getnanotime();
fast_forward = in_merge_bases(current, updated);
fast_forward = repo_in_merge_bases(the_repository, current,
updated);
forced_updates_ms += (getnanotime() - t_before) / 1000000;
} else {
fast_forward = 1;
@ -1323,7 +1324,7 @@ static int check_exist_and_connected(struct ref *ref_map)
* we need all direct targets to exist.
*/
for (r = rm; r; r = r->next) {
if (!has_object_file_with_flags(&r->old_oid,
if (!repo_has_object_file_with_flags(the_repository, &r->old_oid,
OBJECT_INFO_SKIP_FETCH_OBJECT))
return -1;
}
@ -1492,7 +1493,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
int old_nr;
if (!has_glob_specials(s)) {
struct object_id oid;
if (get_oid(s, &oid))
if (repo_get_oid(the_repository, s, &oid))
die(_("%s is not a valid object"), s);
if (!has_object(the_repository, &oid, 0))
die(_("the object %s does not exist"), s);
@ -2016,7 +2017,7 @@ static inline void fetch_one_setup_partial(struct remote *remote)
* If no prior partial clone/fetch and the current fetch DID NOT
* request a partial-fetch, do a normal fetch.
*/
if (!has_promisor_remote() && !filter_options.choice)
if (!repo_has_promisor_remote(the_repository) && !filter_options.choice)
return;
/*
@ -2272,7 +2273,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
printf("%s\n", oid_to_hex(oid));
oidset_clear(&acked_commits);
} else if (remote) {
if (filter_options.choice || has_promisor_remote())
if (filter_options.choice || repo_has_promisor_remote(the_repository))
fetch_one_setup_partial(remote);
result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs);
} else {

View File

@ -960,7 +960,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
for (i = 0; i < argc; i++) {
const char *arg = argv[i];
struct object_id oid;
if (!get_oid(arg, &oid)) {
if (!repo_get_oid(the_repository, arg, &oid)) {
struct object *obj = lookup_object(the_repository,
&oid);

View File

@ -290,7 +290,7 @@ static uint64_t total_ram(void)
static uint64_t estimate_repack_memory(struct packed_git *pack)
{
unsigned long nr_objects = approximate_object_count();
unsigned long nr_objects = repo_approximate_object_count(the_repository);
size_t os_cache, heap;
if (!pack || !nr_objects)
@ -705,7 +705,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
strvec_push(&prune, prune_expire);
if (quiet)
strvec_push(&prune, "--no-progress");
if (has_promisor_remote())
if (repo_has_promisor_remote(the_repository))
strvec_push(&prune,
"--exclude-promisor-objects");
prune_cmd.git_cmd = 1;
@ -826,7 +826,7 @@ static int dfs_on_ref(const char *refname UNUSED,
commit = lookup_commit(the_repository, oid);
if (!commit)
return 0;
if (parse_commit(commit) ||
if (repo_parse_commit(the_repository, commit) ||
commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH)
return 0;
@ -843,7 +843,7 @@ static int dfs_on_ref(const char *refname UNUSED,
commit = pop_commit(&stack);
for (parent = commit->parents; parent; parent = parent->next) {
if (parse_commit(parent->item) ||
if (repo_parse_commit(the_repository, parent->item) ||
commit_graph_position(parent->item) != COMMIT_NOT_FROM_GRAPH ||
parent->item->object.flags & SEEN)
continue;

View File

@ -565,7 +565,8 @@ static int grep_cache(struct grep_opt *opt,
void *data;
unsigned long size;
data = read_object_file(&ce->oid, &type, &size);
data = repo_read_object_file(the_repository, &ce->oid,
&type, &size);
init_tree_desc(&tree, data, size);
hit |= grep_tree(opt, pathspec, &tree, &name, 0, 0);
@ -655,7 +656,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
void *data;
unsigned long size;
data = read_object_file(&entry.oid, &type, &size);
data = repo_read_object_file(the_repository,
&entry.oid, &type, &size);
if (!data)
die(_("unable to read tree (%s)"),
oid_to_hex(&entry.oid));

View File

@ -808,7 +808,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
if (startup_info->have_repository) {
read_lock();
collision_test_needed =
has_object_file_with_flags(oid, OBJECT_INFO_QUICK);
repo_has_object_file_with_flags(the_repository, oid,
OBJECT_INFO_QUICK);
read_unlock();
}
@ -828,7 +829,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
die(_("cannot read existing object info %s"), oid_to_hex(oid));
if (has_type != type || has_size != size)
die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid));
has_data = read_object_file(oid, &has_type, &has_size);
has_data = repo_read_object_file(the_repository, oid,
&has_type, &has_size);
read_unlock();
if (!data)
data = new_data = get_data_from_pack(obj_entry);
@ -1395,7 +1397,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
sorted_by_pos[i] = &ref_deltas[i];
QSORT(sorted_by_pos, nr_ref_deltas, delta_pos_compare);
if (has_promisor_remote()) {
if (repo_has_promisor_remote(the_repository)) {
/*
* Prefetch the delta bases.
*/
@ -1421,7 +1423,8 @@ static void fix_unresolved_deltas(struct hashfile *f)
if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
continue;
data = read_object_file(&d->oid, &type, &size);
data = repo_read_object_file(the_repository, &d->oid, &type,
&size);
if (!data)
continue;

View File

@ -679,7 +679,7 @@ static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
{
unsigned long size;
enum object_type type;
char *buf = read_object_file(oid, &type, &size);
char *buf = repo_read_object_file(the_repository, oid, &type, &size);
int offset = 0;
if (!buf)
@ -1208,7 +1208,8 @@ static char *find_branch_name(struct rev_info *rev)
return NULL;
ref = rev->cmdline.rev[positive].name;
tip_oid = &rev->cmdline.rev[positive].item->oid;
if (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref, 0) &&
if (repo_dwim_ref(the_repository, ref, strlen(ref), &branch_oid,
&full_ref, 0) &&
skip_prefix(full_ref, "refs/heads/", &v) &&
oideq(tip_oid, &branch_oid))
branch = xstrdup(v);
@ -1318,10 +1319,11 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
log_write_email_headers(rev, head, &pp.after_subject, &need_8bit_cte, 0);
for (i = 0; !need_8bit_cte && i < nr; i++) {
const char *buf = get_commit_buffer(list[i], NULL);
const char *buf = repo_get_commit_buffer(the_repository,
list[i], NULL);
if (has_non_ascii(buf))
need_8bit_cte = 1;
unuse_commit_buffer(list[i], buf);
repo_unuse_commit_buffer(the_repository, list[i], buf);
}
if (!branch_name)
@ -1374,7 +1376,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
.other_arg = &other_arg
};
diff_setup(&opts);
repo_diff_setup(the_repository, &opts);
opts.file = rev->diffopt.file;
opts.use_color = rev->diffopt.use_color;
diff_setup_done(&opts);
@ -1646,14 +1648,16 @@ static struct commit *get_base_commit(const char *base_commit,
struct commit *commit;
struct object_id oid;
if (get_oid(upstream, &oid)) {
if (repo_get_oid(the_repository, upstream, &oid)) {
if (die_on_failure)
die(_("failed to resolve '%s' as a valid ref"), upstream);
else
return NULL;
}
commit = lookup_commit_or_die(&oid, "upstream base");
base_list = get_merge_bases_many(commit, total, list);
base_list = repo_get_merge_bases_many(the_repository,
commit, total,
list);
/* There should be one and only one merge base. */
if (!base_list || base_list->next) {
if (die_on_failure) {
@ -1687,7 +1691,9 @@ static struct commit *get_base_commit(const char *base_commit,
while (rev_nr > 1) {
for (i = 0; i < rev_nr / 2; i++) {
struct commit_list *merge_base;
merge_base = get_merge_bases(rev[2 * i], rev[2 * i + 1]);
merge_base = repo_get_merge_bases(the_repository,
rev[2 * i],
rev[2 * i + 1]);
if (!merge_base || merge_base->next) {
if (die_on_failure) {
die(_("failed to find exact merge base"));
@ -1705,7 +1711,7 @@ static struct commit *get_base_commit(const char *base_commit,
rev_nr = DIV_ROUND_UP(rev_nr, 2);
}
if (!in_merge_bases(base, rev[0])) {
if (!repo_in_merge_bases(the_repository, base, rev[0])) {
if (die_on_failure) {
die(_("base commit should be the ancestor of revision list"));
} else {
@ -2401,7 +2407,7 @@ done:
static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
{
struct object_id oid;
if (get_oid(arg, &oid) == 0) {
if (repo_get_oid(the_repository, arg, &oid) == 0) {
struct commit *commit = lookup_commit_reference(the_repository,
&oid);
if (commit) {
@ -2423,12 +2429,12 @@ static void print_commit(char sign, struct commit *commit, int verbose,
{
if (!verbose) {
fprintf(file, "%c %s\n", sign,
find_unique_abbrev(&commit->object.oid, abbrev));
repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev));
} else {
struct strbuf buf = STRBUF_INIT;
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
fprintf(file, "%c %s %s\n", sign,
find_unique_abbrev(&commit->object.oid, abbrev),
repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev),
buf.buf);
strbuf_release(&buf);
}

View File

@ -362,7 +362,7 @@ static void show_ru_info(struct index_state *istate)
if (!ui->mode[i])
continue;
printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
find_unique_abbrev(&ui->oid[i], abbrev),
repo_find_unique_abbrev(the_repository, &ui->oid[i], abbrev),
i + 1);
write_name(path);
}
@ -577,7 +577,7 @@ void overlay_tree_on_index(struct index_state *istate,
read_tree_fn_t fn = NULL;
int err;
if (get_oid(tree_name, &oid))
if (repo_get_oid(the_repository, tree_name, &oid))
die("tree-ish %s not found.", tree_name);
tree = parse_tree_indirect(&oid);
if (!tree)

View File

@ -230,7 +230,7 @@ static int show_tree_default(const struct object_id *oid, struct strbuf *base,
return early;
printf("%06o %s %s\t", mode, type_name(object_type(mode)),
find_unique_abbrev(oid, options->abbrev));
repo_find_unique_abbrev(the_repository, oid, options->abbrev));
show_tree_common_default_long(options, base, pathname, base->len);
return recurse;
}
@ -261,7 +261,8 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
}
printf("%06o %s %s %7s\t", mode, type_name(type),
find_unique_abbrev(oid, options->abbrev), size_text);
repo_find_unique_abbrev(the_repository, oid, options->abbrev),
size_text);
show_tree_common_default_long(options, base, pathname, base->len);
return recurse;
}
@ -312,7 +313,7 @@ static int show_tree_object(const struct object_id *oid, struct strbuf *base,
if (early >= 0)
return early;
str = find_unique_abbrev(oid, options->abbrev);
str = repo_find_unique_abbrev(the_repository, oid, options->abbrev);
if (options->null_termination) {
fputs(str, stdout);
fputc('\0', stdout);
@ -435,7 +436,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
ls_tree_usage, ls_tree_options);
if (argc < 1)
usage_with_options(ls_tree_usage, ls_tree_options);
if (get_oid(argv[0], &oid))
if (repo_get_oid(the_repository, argv[0], &oid))
die("Not a valid object name %s", argv[0]);
/*

View File

@ -15,7 +15,8 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
{
struct commit_list *result, *r;
result = get_merge_bases_many_dirty(rev[0], rev_nr - 1, rev + 1);
result = repo_get_merge_bases_many_dirty(the_repository, rev[0],
rev_nr - 1, rev + 1);
if (!result)
return 1;
@ -44,7 +45,7 @@ static struct commit *get_commit_reference(const char *arg)
struct object_id revkey;
struct commit *r;
if (get_oid(arg, &revkey))
if (repo_get_oid(the_repository, arg, &revkey))
die("Not a valid object name %s", arg);
r = lookup_commit_reference(the_repository, &revkey);
if (!r)
@ -107,7 +108,7 @@ static int handle_is_ancestor(int argc, const char **argv)
die("--is-ancestor takes exactly two commits");
one = get_commit_reference(argv[0]);
two = get_commit_reference(argv[1]);
if (in_merge_bases(one, two))
if (repo_in_merge_bases(the_repository, one, two))
return 0;
else
return 1;
@ -120,7 +121,7 @@ static int handle_fork_point(int argc, const char **argv)
const char *commitname;
commitname = (argc == 2) ? argv[1] : "HEAD";
if (get_oid(commitname, &oid))
if (repo_get_oid(the_repository, commitname, &oid))
die("Not a valid object name: '%s'", commitname);
derived = lookup_commit_reference(the_repository, &oid);

View File

@ -50,7 +50,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
}
if (bases_count < ARRAY_SIZE(bases)-1) {
struct object_id *oid = xmalloc(sizeof(struct object_id));
if (get_oid(argv[i], oid))
if (repo_get_oid(the_repository, argv[i], oid))
die(_("could not parse object '%s'"), argv[i]);
bases[bases_count++] = oid;
}
@ -71,9 +71,9 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
o.branch1 = argv[++i];
o.branch2 = argv[++i];
if (get_oid(o.branch1, &h1))
if (repo_get_oid(the_repository, o.branch1, &h1))
die(_("could not resolve ref '%s'"), o.branch1);
if (get_oid(o.branch2, &h2))
if (repo_get_oid(the_repository, o.branch2, &h2))
die(_("could not resolve ref '%s'"), o.branch2);
o.branch1 = better1 = better_branch_name(o.branch1);

View File

@ -71,7 +71,9 @@ static void *result(struct merge_list *entry, unsigned long *size)
const char *path = entry->path;
if (!entry->stage)
return read_object_file(&entry->blob->object.oid, &type, size);
return repo_read_object_file(the_repository,
&entry->blob->object.oid, &type,
size);
base = NULL;
if (entry->stage == 1) {
base = entry->blob;
@ -94,7 +96,8 @@ static void *origin(struct merge_list *entry, unsigned long *size)
enum object_type type;
while (entry) {
if (entry->stage == 2)
return read_object_file(&entry->blob->object.oid,
return repo_read_object_file(the_repository,
&entry->blob->object.oid,
&type, size);
entry = entry->link;
}
@ -445,16 +448,17 @@ static int real_merge(struct merge_tree_options *o,
die(_("could not lookup commit %s"), merge_base);
opt.ancestor = merge_base;
base_tree = get_commit_tree(base_commit);
parent1_tree = get_commit_tree(parent1);
parent2_tree = get_commit_tree(parent2);
base_tree = repo_get_commit_tree(the_repository, base_commit);
parent1_tree = repo_get_commit_tree(the_repository, parent1);
parent2_tree = repo_get_commit_tree(the_repository, parent2);
merge_incore_nonrecursive(&opt, base_tree, parent1_tree, parent2_tree, &result);
} else {
/*
* Get the merge bases, in reverse order; see comment above
* merge_incore_recursive in merge-ort.h
*/
merge_bases = get_merge_bases(parent1, parent2);
merge_bases = repo_get_merge_bases(the_repository, parent1,
parent2);
if (!merge_bases && !o->allow_unrelated_histories)
die(_("refusing to merge unrelated histories"));
merge_bases = reverse_commit_list(merge_bases);

View File

@ -343,7 +343,7 @@ static int save_state(struct object_id *stash)
else if (!len) /* no changes */
goto out;
strbuf_setlen(&buffer, buffer.len-1);
if (get_oid(buffer.buf, stash))
if (repo_get_oid(the_repository, buffer.buf, stash))
die(_("not a valid object: %s"), buffer.buf);
rc = 0;
out:
@ -523,7 +523,8 @@ static void merge_name(const char *remote, struct strbuf *msg)
if (!remote_head)
die(_("'%s' does not point to a commit"), remote);
if (dwim_ref(remote, strlen(remote), &branch_head, &found_ref, 0) > 0) {
if (repo_dwim_ref(the_repository, remote, strlen(remote), &branch_head,
&found_ref, 0) > 0) {
if (starts_with(found_ref, "refs/heads/")) {
strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
oid_to_hex(&branch_head), remote);
@ -1534,7 +1535,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
if (!remoteheads)
; /* already up-to-date */
else if (!remoteheads->next)
common = get_merge_bases(head_commit, remoteheads->item);
common = repo_get_merge_bases(the_repository, head_commit,
remoteheads->item);
else {
struct commit_list *list = remoteheads;
commit_list_insert(head_commit, &list);
@ -1570,9 +1572,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
if (verbosity >= 0) {
printf(_("Updating %s..%s\n"),
find_unique_abbrev(&head_commit->object.oid,
repo_find_unique_abbrev(the_repository, &head_commit->object.oid,
DEFAULT_ABBREV),
find_unique_abbrev(&remoteheads->item->object.oid,
repo_find_unique_abbrev(the_repository, &remoteheads->item->object.oid,
DEFAULT_ABBREV));
}
commit = remoteheads->item;
@ -1613,7 +1615,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* Must first ensure that index matches HEAD before
* attempting a trivial merge.
*/
struct tree *head_tree = get_commit_tree(head_commit);
struct tree *head_tree = repo_get_commit_tree(the_repository,
head_commit);
struct strbuf sb = STRBUF_INIT;
if (repo_index_has_changes(the_repository, head_tree,
@ -1652,7 +1655,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* merge_bases again, otherwise "git merge HEAD^
* HEAD^^" would be missed.
*/
common_one = get_merge_bases(head_commit, j->item);
common_one = repo_get_merge_bases(the_repository,
head_commit,
j->item);
if (!oideq(&common_one->item->object.oid, &j->item->object.oid)) {
up_to_date = 0;
break;

View File

@ -53,7 +53,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)
void *buffer;
const struct object_id *repl;
buffer = read_object_file(tagged_oid, &type, &size);
buffer = repo_read_object_file(the_repository, tagged_oid, &type,
&size);
if (!buffer)
die(_("could not read tagged object '%s'"),
oid_to_hex(tagged_oid));

View File

@ -184,7 +184,7 @@ static void name_rev(struct commit *start_commit,
size_t parents_to_queue_nr, parents_to_queue_alloc = 0;
struct rev_name *start_name;
parse_commit(start_commit);
repo_parse_commit(the_repository, start_commit);
if (commit_is_before_cutoff(start_commit))
return;
@ -214,7 +214,7 @@ static void name_rev(struct commit *start_commit,
struct rev_name *parent_name;
int generation, distance;
parse_commit(parent);
repo_parse_commit(the_repository, parent);
if (commit_is_before_cutoff(parent))
continue;
@ -496,7 +496,8 @@ static void show_name(const struct object *obj,
else if (allow_undefined)
printf("undefined\n");
else if (always)
printf("%s\n", find_unique_abbrev(oid, DEFAULT_ABBREV));
printf("%s\n",
repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
else
die("cannot describe '%s'", oid_to_hex(oid));
strbuf_release(&buf);
@ -530,7 +531,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)
counter = 0;
*(p+1) = 0;
if (!get_oid(p - (hexsz - 1), &oid)) {
if (!repo_get_oid(the_repository, p - (hexsz - 1), &oid)) {
struct object *o =
lookup_object(the_repository, &oid);
if (o)
@ -607,7 +608,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
struct object *object;
struct commit *commit;
if (get_oid(*argv, &oid)) {
if (repo_get_oid(the_repository, *argv, &oid)) {
fprintf(stderr, "Could not get sha1 for %s. Skipping.\n",
*argv);
continue;

View File

@ -128,7 +128,7 @@ static void copy_obj_to_fd(int fd, const struct object_id *oid)
{
unsigned long size;
enum object_type type;
char *buf = read_object_file(oid, &type, &size);
char *buf = repo_read_object_file(the_repository, oid, &type, &size);
if (buf) {
if (size)
write_or_die(fd, buf, size);
@ -261,9 +261,9 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
if (d->buf.len)
strbuf_addch(&d->buf, '\n');
if (get_oid(arg, &object))
if (repo_get_oid(the_repository, arg, &object))
die(_("failed to resolve '%s' as a valid ref."), arg);
if (!(buf = read_object_file(&object, &type, &len)))
if (!(buf = repo_read_object_file(the_repository, &object, &type, &len)))
die(_("failed to read object '%s'."), arg);
if (type != OBJ_BLOB) {
free(buf);
@ -311,9 +311,9 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
die(_("malformed input line: '%s'."), buf.buf);
strbuf_rtrim(split[0]);
strbuf_rtrim(split[1]);
if (get_oid(split[0]->buf, &from_obj))
if (repo_get_oid(the_repository, split[0]->buf, &from_obj))
die(_("failed to resolve '%s' as a valid ref."), split[0]->buf);
if (get_oid(split[1]->buf, &to_obj))
if (repo_get_oid(the_repository, split[1]->buf, &to_obj))
die(_("failed to resolve '%s' as a valid ref."), split[1]->buf);
if (rewrite_cmd)
@ -381,7 +381,7 @@ static int list(int argc, const char **argv, const char *prefix)
t = init_notes_check("list", 0);
if (argc) {
if (get_oid(argv[0], &object))
if (repo_get_oid(the_repository, argv[0], &object))
die(_("failed to resolve '%s' as a valid ref."), argv[0]);
note = get_note(t, &object);
if (note) {
@ -436,7 +436,7 @@ static int add(int argc, const char **argv, const char *prefix)
object_ref = argc > 1 ? argv[1] : "HEAD";
if (get_oid(object_ref, &object))
if (repo_get_oid(the_repository, object_ref, &object))
die(_("failed to resolve '%s' as a valid ref."), object_ref);
t = init_notes_check("add", NOTES_INIT_WRITABLE);
@ -524,12 +524,12 @@ static int copy(int argc, const char **argv, const char *prefix)
usage_with_options(git_notes_copy_usage, options);
}
if (get_oid(argv[0], &from_obj))
if (repo_get_oid(the_repository, argv[0], &from_obj))
die(_("failed to resolve '%s' as a valid ref."), argv[0]);
object_ref = 1 < argc ? argv[1] : "HEAD";
if (get_oid(object_ref, &object))
if (repo_get_oid(the_repository, object_ref, &object))
die(_("failed to resolve '%s' as a valid ref."), object_ref);
t = init_notes_check("copy", NOTES_INIT_WRITABLE);
@ -608,7 +608,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)
object_ref = 1 < argc ? argv[1] : "HEAD";
if (get_oid(object_ref, &object))
if (repo_get_oid(the_repository, object_ref, &object))
die(_("failed to resolve '%s' as a valid ref."), object_ref);
t = init_notes_check(argv[0], NOTES_INIT_WRITABLE);
@ -620,7 +620,8 @@ static int append_edit(int argc, const char **argv, const char *prefix)
/* Append buf to previous note contents */
unsigned long size;
enum object_type type;
char *prev_buf = read_object_file(note, &type, &size);
char *prev_buf = repo_read_object_file(the_repository, note,
&type, &size);
strbuf_grow(&d.buf, size + 1);
if (d.buf.len && prev_buf && size)
@ -670,7 +671,7 @@ static int show(int argc, const char **argv, const char *prefix)
object_ref = argc ? argv[0] : "HEAD";
if (get_oid(object_ref, &object))
if (repo_get_oid(the_repository, object_ref, &object))
die(_("failed to resolve '%s' as a valid ref."), object_ref);
t = init_notes_check("show", 0);
@ -720,11 +721,11 @@ static int merge_commit(struct notes_merge_options *o)
* and target notes ref from .git/NOTES_MERGE_REF.
*/
if (get_oid("NOTES_MERGE_PARTIAL", &oid))
if (repo_get_oid(the_repository, "NOTES_MERGE_PARTIAL", &oid))
die(_("failed to read ref NOTES_MERGE_PARTIAL"));
else if (!(partial = lookup_commit_reference(the_repository, &oid)))
die(_("could not find commit from NOTES_MERGE_PARTIAL."));
else if (parse_commit(partial))
else if (repo_parse_commit(the_repository, partial))
die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
if (partial->parents)
@ -745,7 +746,8 @@ static int merge_commit(struct notes_merge_options *o)
/* Reuse existing commit message in reflog message */
memset(&pretty_ctx, 0, sizeof(pretty_ctx));
format_commit_message(partial, "%s", &msg, &pretty_ctx);
repo_format_commit_message(the_repository, partial, "%s", &msg,
&pretty_ctx);
strbuf_trim(&msg);
strbuf_insertstr(&msg, 0, "notes: ");
update_ref(msg.buf, o->local_ref, &oid,
@ -899,7 +901,7 @@ static int remove_one_note(struct notes_tree *t, const char *name, unsigned flag
{
int status;
struct object_id oid;
if (get_oid(name, &oid))
if (repo_get_oid(the_repository, name, &oid))
return error(_("Failed to resolve '%s' as a valid ref."), name);
status = remove_note(t, oid.hash);
if (status)

View File

@ -293,10 +293,12 @@ static void *get_delta(struct object_entry *entry)
void *buf, *base_buf, *delta_buf;
enum object_type type;
buf = read_object_file(&entry->idx.oid, &type, &size);
buf = repo_read_object_file(the_repository, &entry->idx.oid, &type,
&size);
if (!buf)
die(_("unable to read %s"), oid_to_hex(&entry->idx.oid));
base_buf = read_object_file(&DELTA(entry)->idx.oid, &type,
base_buf = repo_read_object_file(the_repository,
&DELTA(entry)->idx.oid, &type,
&base_size);
if (!base_buf)
die("unable to read %s",
@ -459,7 +461,9 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
&size, NULL)) != NULL)
buf = NULL;
else {
buf = read_object_file(&entry->idx.oid, &type, &size);
buf = repo_read_object_file(the_repository,
&entry->idx.oid, &type,
&size);
if (!buf)
die(_("unable to read %s"),
oid_to_hex(&entry->idx.oid));
@ -1670,7 +1674,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
/* Did not find one. Either we got a bogus request or
* we need to read and perhaps cache.
*/
data = read_object_file(oid, &type, &size);
data = repo_read_object_file(the_repository, oid, &type, &size);
if (!data)
return NULL;
if (type != OBJ_TREE) {
@ -2079,7 +2083,7 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) {
if (has_promisor_remote()) {
if (repo_has_promisor_remote(the_repository)) {
prefetch_to_pack(object_index);
if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi,
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0)
@ -2530,7 +2534,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
/* Load data if not already done */
if (!trg->data) {
packing_data_lock(&to_pack);
trg->data = read_object_file(&trg_entry->idx.oid, &type, &sz);
trg->data = repo_read_object_file(the_repository,
&trg_entry->idx.oid, &type,
&sz);
packing_data_unlock(&to_pack);
if (!trg->data)
die(_("object %s cannot be read"),
@ -2543,7 +2549,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
}
if (!src->data) {
packing_data_lock(&to_pack);
src->data = read_object_file(&src_entry->idx.oid, &type, &sz);
src->data = repo_read_object_file(the_repository,
&src_entry->idx.oid, &type,
&sz);
packing_data_unlock(&to_pack);
if (!src->data) {
if (src_entry->preferred_base) {

View File

@ -174,7 +174,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
struct object_id oid;
const char *name = *argv++;
if (!get_oid(name, &oid)) {
if (!repo_get_oid(the_repository, name, &oid)) {
struct object *object = parse_object_or_die(&oid,
name);
add_pending_object(&revs, object, "");

View File

@ -1032,7 +1032,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
if (file_exists(git_path_merge_head(the_repository)))
die_conclude_merge();
if (get_oid("HEAD", &orig_head))
if (repo_get_oid(the_repository, "HEAD", &orig_head))
oidclr(&orig_head);
if (opt_rebase) {
@ -1057,7 +1057,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
if (opt_dry_run)
return 0;
if (get_oid("HEAD", &curr_head))
if (repo_get_oid(the_repository, "HEAD", &curr_head))
oidclr(&curr_head);
if (!is_null_oid(&orig_head) && !is_null_oid(&curr_head) &&

View File

@ -66,20 +66,20 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
if (dash_dash == 3 ||
(dash_dash < 0 && argc > 2 &&
!get_oid_committish(argv[0], &oid) &&
!get_oid_committish(argv[1], &oid) &&
!get_oid_committish(argv[2], &oid))) {
!repo_get_oid_committish(the_repository, argv[0], &oid) &&
!repo_get_oid_committish(the_repository, argv[1], &oid) &&
!repo_get_oid_committish(the_repository, argv[2], &oid))) {
if (dash_dash < 0)
; /* already validated arguments */
else if (get_oid_committish(argv[0], &oid))
else if (repo_get_oid_committish(the_repository, argv[0], &oid))
usage_msg_optf(_("not a revision: '%s'"),
builtin_range_diff_usage, options,
argv[0]);
else if (get_oid_committish(argv[1], &oid))
else if (repo_get_oid_committish(the_repository, argv[1], &oid))
usage_msg_optf(_("not a revision: '%s'"),
builtin_range_diff_usage, options,
argv[1]);
else if (get_oid_committish(argv[2], &oid))
else if (repo_get_oid_committish(the_repository, argv[2], &oid))
usage_msg_optf(_("not a revision: '%s'"),
builtin_range_diff_usage, options,
argv[2]);

View File

@ -201,7 +201,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
for (i = 0; i < argc; i++) {
const char *arg = argv[i];
if (get_oid(arg, &oid))
if (repo_get_oid(the_repository, arg, &oid))
die("Not a valid object name %s", arg);
if (list_tree(&oid) < 0)
die("failed to unpack tree object %s", arg);

View File

@ -223,12 +223,14 @@ static int get_revision_ranges(struct commit *upstream, struct commit *onto,
*revisions = xstrfmt("%s...%s", oid_to_hex(&base_rev->object.oid),
oid_to_hex(orig_head));
shorthead = find_unique_abbrev(orig_head, DEFAULT_ABBREV);
shorthead = repo_find_unique_abbrev(the_repository, orig_head,
DEFAULT_ABBREV);
if (upstream) {
const char *shortrev;
shortrev = find_unique_abbrev(&base_rev->object.oid,
shortrev = repo_find_unique_abbrev(the_repository,
&base_rev->object.oid,
DEFAULT_ABBREV);
*shortrevisions = xstrfmt("%s..%s", shortrev, shorthead);
@ -856,7 +858,7 @@ static int checkout_up_to_date(struct rebase_options *options)
static int is_linear_history(struct commit *from, struct commit *to)
{
while (to && to != from) {
parse_commit(to);
repo_parse_commit(the_repository, to);
if (!to->parents)
return 1;
if (to->parents->next)
@ -885,7 +887,7 @@ static int can_fast_forward(struct commit *onto, struct commit *upstream,
if (!upstream)
goto done;
merge_bases = get_merge_bases(upstream, head);
merge_bases = repo_get_merge_bases(the_repository, upstream, head);
if (!merge_bases || merge_bases->next)
goto done;
@ -904,7 +906,8 @@ static void fill_branch_base(struct rebase_options *options,
{
struct commit_list *merge_bases = NULL;
merge_bases = get_merge_bases(options->onto, options->orig_head);
merge_bases = repo_get_merge_bases(the_repository, options->onto,
options->orig_head);
if (!merge_bases || merge_bases->next)
oidcpy(branch_base, null_oid());
else
@ -1266,7 +1269,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
int fd;
/* Sanity check */
if (get_oid("HEAD", &head))
if (repo_get_oid(the_repository, "HEAD", &head))
die(_("Cannot read HEAD"));
fd = repo_hold_locked_index(the_repository, &lock_file, 0);
@ -1685,7 +1688,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
} else if (!options.onto_name)
options.onto_name = options.upstream_name;
if (strstr(options.onto_name, "...")) {
if (get_oid_mb(options.onto_name, &branch_base) < 0) {
if (repo_get_oid_mb(the_repository, options.onto_name, &branch_base) < 0) {
if (keep_base)
die(_("'%s': need exactly one merge base with branch"),
options.upstream_name);
@ -1788,7 +1791,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
}
/* We want color (if set), but no pager */
diff_setup(&opts);
repo_diff_setup(the_repository, &opts);
opts.stat_width = -1; /* use full terminal width */
opts.stat_graph_width = -1; /* respect statGraphWidth config */
opts.output_format |=

View File

@ -1348,7 +1348,7 @@ static int head_has_history(void)
{
struct object_id oid;
return !get_oid("HEAD", &oid);
return !repo_get_oid(the_repository, "HEAD", &oid);
}
static const char *push_to_deploy(unsigned char *sha1,
@ -1497,7 +1497,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
}
}
if (!is_null_oid(new_oid) && !has_object_file(new_oid)) {
if (!is_null_oid(new_oid) && !repo_has_object_file(the_repository, new_oid)) {
error("unpack should have generated %s, "
"but I can't find it!", oid_to_hex(new_oid));
ret = "bad pack";
@ -1551,7 +1551,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
}
old_commit = (struct commit *)old_object;
new_commit = (struct commit *)new_object;
if (!in_merge_bases(old_commit, new_commit)) {
if (!repo_in_merge_bases(the_repository, old_commit, new_commit)) {
rp_error("denying non-fast-forward %s"
" (you should pull first)", name);
ret = "non-fast-forward";
@ -1684,11 +1684,11 @@ static void check_aliased_update_internal(struct command *cmd,
rp_error("refusing inconsistent update between symref '%s' (%s..%s) and"
" its target '%s' (%s..%s)",
cmd->ref_name,
find_unique_abbrev(&cmd->old_oid, DEFAULT_ABBREV),
find_unique_abbrev(&cmd->new_oid, DEFAULT_ABBREV),
repo_find_unique_abbrev(the_repository, &cmd->old_oid, DEFAULT_ABBREV),
repo_find_unique_abbrev(the_repository, &cmd->new_oid, DEFAULT_ABBREV),
dst_cmd->ref_name,
find_unique_abbrev(&dst_cmd->old_oid, DEFAULT_ABBREV),
find_unique_abbrev(&dst_cmd->new_oid, DEFAULT_ABBREV));
repo_find_unique_abbrev(the_repository, &dst_cmd->old_oid, DEFAULT_ABBREV),
repo_find_unique_abbrev(the_repository, &dst_cmd->new_oid, DEFAULT_ABBREV));
cmd->error_string = dst_cmd->error_string =
"inconsistent aliased update";

View File

@ -444,7 +444,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
info->status = PUSH_STATUS_UPTODATE;
else if (is_null_oid(&ref->old_oid))
info->status = PUSH_STATUS_CREATE;
else if (has_object_file(&ref->old_oid) &&
else if (repo_has_object_file(the_repository, &ref->old_oid) &&
ref_newer(&ref->new_oid, &ref->old_oid))
info->status = PUSH_STATUS_FASTFORWARD;
else

View File

@ -905,7 +905,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
strvec_push(&cmd.args, "--reflog");
strvec_push(&cmd.args, "--indexed-objects");
}
if (has_promisor_remote())
if (repo_has_promisor_remote(the_repository))
strvec_push(&cmd.args, "--exclude-promisor-objects");
if (!write_midx) {
if (write_bitmaps > 0)

View File

@ -58,7 +58,7 @@ static int show_reference(struct repository *r, const char *refname,
struct object_id object;
enum object_type obj_type, repl_type;
if (get_oid(refname, &object))
if (repo_get_oid(r, refname, &object))
return error(_("failed to resolve '%s' as a valid ref"), refname);
obj_type = oid_object_info(r, &object, NULL);
@ -116,7 +116,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
base_len = ref.len;
for (p = argv; *p; p++) {
if (get_oid(*p, &oid)) {
if (repo_get_oid(the_repository, *p, &oid)) {
error("failed to resolve '%s' as a valid ref", *p);
had_error = 1;
continue;
@ -210,10 +210,10 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
{
struct object_id object, repl;
if (get_oid(object_ref, &object))
if (repo_get_oid(the_repository, object_ref, &object))
return error(_("failed to resolve '%s' as a valid ref"),
object_ref);
if (get_oid(replace_ref, &repl))
if (repo_get_oid(the_repository, replace_ref, &repl))
return error(_("failed to resolve '%s' as a valid ref"),
replace_ref);
@ -324,7 +324,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
struct object_id old_oid, new_oid, prev;
struct strbuf ref = STRBUF_INIT;
if (get_oid(object_ref, &old_oid) < 0)
if (repo_get_oid(the_repository, object_ref, &old_oid) < 0)
return error(_("not a valid object name: '%s'"), object_ref);
type = oid_object_info(the_repository, &old_oid, NULL);
@ -379,7 +379,7 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv)
struct object_id oid;
struct commit *commit;
if (get_oid(argv[i], &oid) < 0) {
if (repo_get_oid(the_repository, argv[i], &oid) < 0) {
strbuf_release(&new_parents);
return error(_("not a valid object name: '%s'"),
argv[i]);
@ -426,7 +426,7 @@ static int check_one_mergetag(struct commit *commit,
/* iterate over new parents */
for (i = 1; i < mergetag_data->argc; i++) {
struct object_id oid;
if (get_oid(mergetag_data->argv[i], &oid) < 0)
if (repo_get_oid(the_repository, mergetag_data->argv[i], &oid) < 0)
return error(_("not a valid object name: '%s'"),
mergetag_data->argv[i]);
if (oideq(get_tagged_oid(tag), &oid))
@ -456,15 +456,15 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
const char *buffer;
unsigned long size;
if (get_oid(old_ref, &old_oid) < 0)
if (repo_get_oid(the_repository, old_ref, &old_oid) < 0)
return error(_("not a valid object name: '%s'"), old_ref);
commit = lookup_commit_reference(the_repository, &old_oid);
if (!commit)
return error(_("could not parse %s"), old_ref);
buffer = get_commit_buffer(commit, &size);
buffer = repo_get_commit_buffer(the_repository, commit, &size);
strbuf_add(&buf, buffer, size);
unuse_commit_buffer(commit, buffer);
repo_unuse_commit_buffer(the_repository, commit, buffer);
if (replace_parents(&buf, argc - 1, &argv[1]) < 0) {
strbuf_release(&buf);

View File

@ -93,7 +93,7 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t
if (reset_type == KEEP) {
struct object_id head_oid;
if (get_oid("HEAD", &head_oid))
if (repo_get_oid(the_repository, "HEAD", &head_oid))
return error(_("You do not have a valid HEAD."));
if (!fill_tree_descriptor(the_repository, desc + nr, &head_oid))
return error(_("Failed to find tree of HEAD."));
@ -128,7 +128,7 @@ static void print_new_head_line(struct commit *commit)
struct strbuf buf = STRBUF_INIT;
printf(_("HEAD is now at %s"),
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
if (buf.len > 0)
@ -264,8 +264,8 @@ static void parse_args(struct pathspec *pathspec,
* has to be unambiguous. If there is a single argument, it
* can not be a tree
*/
else if ((!argv[1] && !get_oid_committish(argv[0], &unused)) ||
(argv[1] && !get_oid_treeish(argv[0], &unused))) {
else if ((!argv[1] && !repo_get_oid_committish(the_repository, argv[0], &unused)) ||
(argv[1] && !repo_get_oid_treeish(the_repository, argv[0], &unused))) {
/*
* Ok, argv[0] looks like a commit/tree; it should not
* be a filename.
@ -292,9 +292,9 @@ static int reset_refs(const char *rev, const struct object_id *oid)
struct object_id *orig = NULL, oid_orig,
*old_orig = NULL, oid_old_orig;
if (!get_oid("ORIG_HEAD", &oid_old_orig))
if (!repo_get_oid(the_repository, "ORIG_HEAD", &oid_old_orig))
old_orig = &oid_old_orig;
if (!get_oid("HEAD", &oid_orig)) {
if (!repo_get_oid(the_repository, "HEAD", &oid_orig)) {
orig = &oid_orig;
set_reflog_message(&msg, "updating ORIG_HEAD", NULL);
update_ref(msg.buf, "ORIG_HEAD", orig, old_orig, 0,
@ -370,13 +370,14 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
die(_("the option '%s' requires '%s'"), "--pathspec-file-nul", "--pathspec-from-file");
}
unborn = !strcmp(rev, "HEAD") && get_oid("HEAD", &oid);
unborn = !strcmp(rev, "HEAD") && repo_get_oid(the_repository, "HEAD",
&oid);
if (unborn) {
/* reset on unborn branch: treat as reset to empty tree */
oidcpy(&oid, the_hash_algo->empty_tree);
} else if (!pathspec.nr && !patch_mode) {
struct commit *commit;
if (get_oid_committish(rev, &oid))
if (repo_get_oid_committish(the_repository, rev, &oid))
die(_("Failed to resolve '%s' as a valid revision."), rev);
commit = lookup_commit_reference(the_repository, &oid);
if (!commit)
@ -384,7 +385,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
oidcpy(&oid, &commit->object.oid);
} else {
struct tree *tree;
if (get_oid_treeish(rev, &oid))
if (repo_get_oid_treeish(the_repository, rev, &oid))
die(_("Failed to resolve '%s' as a valid tree."), rev);
tree = parse_tree_indirect(&oid);
if (!tree)
@ -469,7 +470,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
char *ref = NULL;
int err;
dwim_ref(rev, strlen(rev), &dummy, &ref, 0);
repo_dwim_ref(the_repository, rev, strlen(rev),
&dummy, &ref, 0);
if (ref && !starts_with(ref, "refs/"))
FREE_AND_NULL(ref);

View File

@ -137,7 +137,7 @@ static void show_commit(struct commit *commit, void *data)
if (!revs->graph)
fputs(get_revision_mark(revs, commit), stdout);
if (revs->abbrev_commit && revs->abbrev)
fputs(find_unique_abbrev(&commit->object.oid, revs->abbrev),
fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, revs->abbrev),
stdout);
else
fputs(oid_to_hex(&commit->object.oid), stdout);

View File

@ -142,7 +142,9 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
struct object_id discard;
char *full;
switch (dwim_ref(name, strlen(name), &discard, &full, 0)) {
switch (repo_dwim_ref(the_repository, name,
strlen(name), &discard, &full,
0)) {
case 0:
/*
* Not found -- not a ref. We could
@ -168,7 +170,8 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
}
}
else if (abbrev)
show_with_type(type, find_unique_abbrev(oid, abbrev));
show_with_type(type,
repo_find_unique_abbrev(the_repository, oid, abbrev));
else
show_with_type(type, oid_to_hex(oid));
}
@ -193,7 +196,7 @@ static int show_default(void)
struct object_id oid;
def = NULL;
if (!get_oid(s, &oid)) {
if (!repo_get_oid(the_repository, s, &oid)) {
show_rev(NORMAL, &oid, s);
return 1;
}
@ -285,7 +288,7 @@ static int try_difference(const char *arg)
return 0;
}
if (!get_oid_committish(start, &start_oid) && !get_oid_committish(end, &end_oid)) {
if (!repo_get_oid_committish(the_repository, start, &start_oid) && !repo_get_oid_committish(the_repository, end, &end_oid)) {
show_rev(NORMAL, &end_oid, end);
show_rev(symmetric ? NORMAL : REVERSED, &start_oid, start);
if (symmetric) {
@ -297,7 +300,7 @@ static int try_difference(const char *arg)
*dotdot = '.';
return 0;
}
exclude = get_merge_bases(a, b);
exclude = repo_get_merge_bases(the_repository, a, b);
while (exclude) {
struct commit *commit = pop_commit(&exclude);
show_rev(REVERSED, &commit->object.oid, NULL);
@ -343,7 +346,7 @@ static int try_parent_shorthands(const char *arg)
return 0;
*dotdot = 0;
if (get_oid_committish(arg, &oid) ||
if (repo_get_oid_committish(the_repository, arg, &oid) ||
!(commit = lookup_commit_reference(the_repository, &oid))) {
*dotdot = '^';
return 0;
@ -874,7 +877,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (skip_prefix(arg, "--disambiguate=", &arg)) {
for_each_abbrev(arg, show_abbrev, NULL);
repo_for_each_abbrev(the_repository, arg,
show_abbrev, NULL);
continue;
}
if (!strcmp(arg, "--bisect")) {

View File

@ -373,7 +373,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
*/
if (!force) {
struct object_id oid;
if (get_oid("HEAD", &oid))
if (repo_get_oid(the_repository, "HEAD", &oid))
oidclr(&oid);
if (check_local_mod(&oid, index_only))
exit(1);

View File

@ -179,10 +179,11 @@ static void insert_records_from_trailers(struct shortlog *log,
return;
/*
* Using format_commit_message("%B") would be simpler here, but
* Using repo_format_commit_message("%B") would be simpler here, but
* this saves us copying the message.
*/
commit_buffer = logmsg_reencode(commit, NULL, ctx->output_encoding);
commit_buffer = repo_logmsg_reencode(the_repository, commit, NULL,
ctx->output_encoding);
body = strstr(commit_buffer, "\n\n");
if (!body)
return;
@ -205,7 +206,7 @@ static void insert_records_from_trailers(struct shortlog *log,
trailer_iterator_release(&iter);
strbuf_release(&ident);
unuse_commit_buffer(commit, commit_buffer);
repo_unuse_commit_buffer(the_repository, commit, commit_buffer);
}
static int shortlog_needs_dedup(const struct shortlog *log)
@ -225,7 +226,8 @@ static void insert_records_from_format(struct shortlog *log,
for_each_string_list_item(item, &log->format) {
strbuf_reset(&buf);
format_commit_message(commit, item->string, &buf, ctx);
repo_format_commit_message(the_repository, commit,
item->string, &buf, ctx);
if (!shortlog_needs_dedup(log) || strset_add(dups, buf.buf))
insert_one_record(log, buf.buf, oneline);
@ -251,7 +253,8 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
if (log->user_format)
pretty_print_commit(&ctx, commit, &oneline);
else
format_commit_message(commit, "%s", &oneline, &ctx);
repo_format_commit_message(the_repository, commit,
"%s", &oneline, &ctx);
}
oneline_str = oneline.len ? oneline.buf : "<none>";

View File

@ -243,7 +243,7 @@ static void join_revs(struct commit_list **list_p,
parents = parents->next;
if ((this_flag & flags) == flags)
continue;
parse_commit(p);
repo_parse_commit(the_repository, p);
if (mark_seen(p, seen_p) && !still_interesting)
extra--;
p->object.flags |= flags;
@ -315,7 +315,7 @@ static void show_one_commit(struct commit *commit, int no_name)
}
else
printf("[%s] ",
find_unique_abbrev(&commit->object.oid,
repo_find_unique_abbrev(the_repository, &commit->object.oid,
DEFAULT_ABBREV));
}
puts(pretty_str);
@ -417,7 +417,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
if (repo_get_oid(the_repository, refname + ofs, &tmp) || !oideq(&tmp, oid))
ofs = 5;
return append_ref(refname + ofs, oid, 0);
}
@ -432,7 +432,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
/* If both heads/foo and tags/foo exists, get_sha1 would
* get confused.
*/
if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
if (repo_get_oid(the_repository, refname + ofs, &tmp) || !oideq(&tmp, oid))
ofs = 5;
return append_ref(refname + ofs, oid, 0);
}
@ -536,7 +536,7 @@ static int show_independent(struct commit **rev,
static void append_one_rev(const char *av)
{
struct object_id revkey;
if (!get_oid(av, &revkey)) {
if (!repo_get_oid(the_repository, av, &revkey)) {
append_ref(av, &revkey, 0);
return;
}
@ -749,7 +749,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
die(Q_("only %d entry can be shown at one time.",
"only %d entries can be shown at one time.",
MAX_REVS), MAX_REVS);
if (!dwim_ref(*av, strlen(*av), &oid, &ref, 0))
if (!repo_dwim_ref(the_repository, *av, strlen(*av), &oid,
&ref, 0))
die(_("no such ref %s"), *av);
/* Has the base been specified? */
@ -839,13 +840,13 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
die(Q_("cannot handle more than %d rev.",
"cannot handle more than %d revs.",
MAX_REVS), MAX_REVS);
if (get_oid(ref_name[num_rev], &revkey))
if (repo_get_oid(the_repository, ref_name[num_rev], &revkey))
die(_("'%s' is not a valid ref."), ref_name[num_rev]);
commit = lookup_commit_reference(the_repository, &revkey);
if (!commit)
die(_("cannot find commit %s (%s)"),
ref_name[num_rev], oid_to_hex(&revkey));
parse_commit(commit);
repo_parse_commit(the_repository, commit);
mark_seen(commit, &seen);
/* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,

View File

@ -28,14 +28,14 @@ static void show_one(const char *refname, const struct object_id *oid)
const char *hex;
struct object_id peeled;
if (!has_object_file(oid))
if (!repo_has_object_file(the_repository, oid))
die("git show-ref: bad ref %s (%s)", refname,
oid_to_hex(oid));
if (quiet)
return;
hex = find_unique_abbrev(oid, abbrev);
hex = repo_find_unique_abbrev(the_repository, oid, abbrev);
if (hash_only)
printf("%s\n", hex);
else
@ -45,7 +45,7 @@ static void show_one(const char *refname, const struct object_id *oid)
return;
if (!peel_iterated_oid(oid, &peeled)) {
hex = find_unique_abbrev(&peeled, abbrev);
hex = repo_find_unique_abbrev(the_repository, &peeled, abbrev);
printf("%s %s^{}\n", hex, refname);
}
}

View File

@ -472,7 +472,7 @@ static int sparse_checkout_init(int argc, const char **argv, const char *prefix)
return update_working_directory(NULL);
}
if (get_oid("HEAD", &oid)) {
if (repo_get_oid(the_repository, "HEAD", &oid)) {
FILE *fp;
/* assume we are in a fresh repo, but update the sparse-checkout file */

View File

@ -206,7 +206,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
revision = info->revision.buf;
if (get_oid(revision, &info->w_commit))
if (repo_get_oid(the_repository, revision, &info->w_commit))
return error(_("%s is not a valid reference"), revision);
assert_stash_like(info, revision);
@ -216,7 +216,8 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
end_of_rev = strchrnul(revision, '@');
strbuf_add(&symbolic, revision, end_of_rev - revision);
ret = dwim_ref(symbolic.buf, symbolic.len, &dummy, &expanded_ref, 0);
ret = repo_dwim_ref(the_repository, symbolic.buf, symbolic.len,
&dummy, &expanded_ref, 0);
strbuf_release(&symbolic);
switch (ret) {
case 0: /* Not found, but valid ref */
@ -236,7 +237,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
static int do_clear_stash(void)
{
struct object_id obj;
if (get_oid(ref_stash, &obj))
if (repo_get_oid(the_repository, ref_stash, &obj))
return 0;
return delete_ref(NULL, ref_stash, &obj, 0);
@ -432,7 +433,7 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)
* to the index before a merge was run) and the current index
* (reflecting the changes brought in by the merge).
*/
diff_setup(&diff_opts);
repo_diff_setup(the_repository, &diff_opts);
diff_opts.flags.recursive = 1;
diff_opts.detect_rename = 0;
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
@ -605,7 +606,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
ret = error(_("could not write index"));
if (ret) {
rerere(0);
repo_rerere(the_repository, 0);
if (index)
fprintf_ln(stderr, _("Index was not unstashed."));
@ -905,7 +906,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
init_diff_ui_defaults();
git_config(git_diff_ui_config, NULL);
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
argc = parse_options(argc, argv, prefix, options, git_stash_show_usage,
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT |
@ -1088,13 +1089,13 @@ static int check_changes_tracked_files(const struct pathspec *ps)
int ret = 0;
/* No initial commit. */
if (get_oid("HEAD", &dummy))
if (repo_get_oid(the_repository, "HEAD", &dummy))
return -1;
if (repo_read_index(the_repository) < 0)
return -1;
init_revisions(&rev, NULL);
repo_init_revisions(the_repository, &rev, NULL);
copy_pathspec(&rev.prune_data, ps);
rev.diffopt.flags.quick = 1;
@ -1281,7 +1282,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
struct strbuf diff_output = STRBUF_INIT;
struct index_state istate = INDEX_STATE_INIT(the_repository);
init_revisions(&rev, NULL);
repo_init_revisions(the_repository, &rev, NULL);
copy_pathspec(&rev.prune_data, ps);
set_alternate_index_output(stash_index_path.buf);
@ -1360,7 +1361,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
goto done;
}
if (get_oid("HEAD", &info->b_commit)) {
if (repo_get_oid(the_repository, "HEAD", &info->b_commit)) {
if (!quiet)
fprintf_ln(stderr, _("You do not have "
"the initial commit yet"));
@ -1378,7 +1379,8 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
branch_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
if (flags & REF_ISSYMREF)
skip_prefix(branch_ref, "refs/heads/", &branch_name);
head_short_sha1 = find_unique_abbrev(&head_commit->object.oid,
head_short_sha1 = repo_find_unique_abbrev(the_repository,
&head_commit->object.oid,
DEFAULT_ABBREV);
strbuf_addf(&msg, "%s: %s ", branch_name, head_short_sha1);
pp_commit_easy(CMIT_FMT_ONELINE, head_commit, &msg);

View File

@ -1114,7 +1114,7 @@ static int compute_summary_module_list(struct object_id *head_oid,
strvec_pushv(&diff_args, info->argv);
git_config(git_diff_basic_config, NULL);
init_revisions(&rev, info->prefix);
repo_init_revisions(the_repository, &rev, info->prefix);
rev.abbrev = 0;
precompose_argv_prefix(diff_args.nr, diff_args.v, NULL);
setup_revisions(diff_args.nr, diff_args.v, &rev, &opt);
@ -1180,7 +1180,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
if (!summary_limit)
return 0;
if (!get_oid(argc ? argv[0] : "HEAD", &head_oid)) {
if (!repo_get_oid(the_repository, argc ? argv[0] : "HEAD", &head_oid)) {
if (argc) {
argv++;
argc--;
@ -1193,7 +1193,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
argc--;
}
} else {
if (get_oid("HEAD", &head_oid))
if (repo_get_oid(the_repository, "HEAD", &head_oid))
die(_("could not fetch a revision for HEAD"));
}

View File

@ -141,7 +141,7 @@ static int delete_tags(const char **argv)
if (!ref_exists(name))
printf(_("Deleted tag '%s' (was %s)\n"),
item->string + 10,
find_unique_abbrev(oid, DEFAULT_ABBREV));
repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
free(oid);
}
@ -214,7 +214,7 @@ static void write_tag_body(int fd, const struct object_id *oid)
struct strbuf payload = STRBUF_INIT;
struct strbuf signature = STRBUF_INIT;
orig = buf = read_object_file(oid, &type, &size);
orig = buf = repo_read_object_file(the_repository, oid, &type, &size);
if (!buf)
return;
if (parse_signature(buf, size, &payload, &signature)) {
@ -365,7 +365,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
strbuf_addstr(sb, "object of unknown type");
break;
case OBJ_COMMIT:
if ((buf = read_object_file(oid, &type, &size))) {
if ((buf = repo_read_object_file(the_repository, oid, &type, &size))) {
subject_len = find_commit_subject(buf, &subject_start);
strbuf_insert(sb, sb->len, subject_start, subject_len);
} else {
@ -593,7 +593,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (argc > 2)
die(_("too many arguments"));
if (get_oid(object_ref, &object))
if (repo_get_oid(the_repository, object_ref, &object))
die(_("Failed to resolve '%s' as a valid ref."), object_ref);
if (strbuf_check_tag_ref(&ref, tag))
@ -634,7 +634,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
ref_transaction_free(transaction);
if (force && !is_null_oid(&prev) && !oideq(&prev, &object))
printf(_("Updated tag '%s' (was %s)\n"), tag,
find_unique_abbrev(&prev, DEFAULT_ABBREV));
repo_find_unique_abbrev(the_repository, &prev, DEFAULT_ABBREV));
cleanup:
ref_sorting_release(sorting);

View File

@ -12,7 +12,7 @@ static char *create_temp_file(struct object_id *oid)
unsigned long size;
int fd;
buf = read_object_file(oid, &type, &size);
buf = repo_read_object_file(the_repository, oid, &type, &size);
if (!buf || type != OBJ_BLOB)
die("unable to read blob object %s", oid_to_hex(oid));
@ -31,7 +31,7 @@ int cmd_unpack_file(int argc, const char **argv, const char *prefix)
if (argc != 2 || !strcmp(argv[1], "-h"))
usage("git unpack-file <blob>");
if (get_oid(argv[1], &oid))
if (repo_get_oid(the_repository, argv[1], &oid))
die("Not a valid object name %s", argv[1]);
git_config(git_default_config, NULL);

View File

@ -446,7 +446,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
delta_data = get_data(delta_size);
if (!delta_data)
return;
if (has_object_file(&base_oid))
if (repo_has_object_file(the_repository, &base_oid))
; /* Ok we have this one */
else if (resolve_against_held(nr, &base_oid,
delta_data, delta_size))
@ -512,7 +512,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
if (resolve_against_held(nr, &base_oid, delta_data, delta_size))
return;
base = read_object_file(&base_oid, &type, &base_size);
base = repo_read_object_file(the_repository, &base_oid, &type,
&base_size);
if (!base) {
error("failed to read delta-pack base object %s",
oid_to_hex(&base_oid));

View File

@ -117,7 +117,7 @@ static int parse_next_oid(const char **next, const char *end,
(*next)++;
*next = parse_arg(*next, &arg);
if (arg.len) {
if (get_oid(arg.buf, oid))
if (repo_get_oid(the_repository, arg.buf, oid))
goto invalid;
} else {
/* Without -z, an empty value means all zeros: */
@ -135,7 +135,7 @@ static int parse_next_oid(const char **next, const char *end,
*next += arg.len;
if (arg.len) {
if (get_oid(arg.buf, oid))
if (repo_get_oid(the_repository, arg.buf, oid))
goto invalid;
} else if (flags & PARSE_SHA1_ALLOW_EMPTY) {
/* With -z, treat an empty value as all zeros: */
@ -550,7 +550,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
refname = argv[0];
value = argv[1];
oldval = argv[2];
if (get_oid(value, &oid))
if (repo_get_oid(the_repository, value, &oid))
die("%s: not a valid SHA1", value);
}
@ -561,7 +561,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
* must not already exist:
*/
oidclr(&oldoid);
else if (get_oid(oldval, &oldoid))
else if (repo_get_oid(the_repository, oldval, &oldoid))
die("%s: not a valid old SHA1", oldval);
}

View File

@ -40,7 +40,7 @@ static int verify_commit(const char *name, unsigned flags)
struct object_id oid;
struct object *obj;
if (get_oid(name, &oid))
if (repo_get_oid(the_repository, name, &oid))
return error("commit '%s' not found.", name);
obj = parse_object(the_repository, &oid);

View File

@ -53,7 +53,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
struct object_id oid;
const char *name = argv[i++];
if (get_oid(name, &oid)) {
if (repo_get_oid(the_repository, name, &oid)) {
had_error = !!error("tag '%s' not found.", name);
continue;
}

View File

@ -557,7 +557,7 @@ static void print_preparing_worktree_line(int detach,
else
fprintf_ln(stderr, _("Preparing worktree (resetting branch '%s'; was at %s)"),
new_branch,
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
} else if (new_branch) {
fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch);
} else {
@ -571,7 +571,7 @@ static void print_preparing_worktree_line(int detach,
if (!commit)
die(_("invalid reference: %s"), branch);
fprintf_ln(stderr, _("Preparing worktree (detached HEAD %s)"),
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
}
strbuf_release(&s);
}
@ -761,7 +761,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)
strbuf_addstr(&sb, "(bare)");
else {
strbuf_addf(&sb, "%-*s ", abbrev_len,
find_unique_abbrev(&wt->head_oid, DEFAULT_ABBREV));
repo_find_unique_abbrev(the_repository, &wt->head_oid, DEFAULT_ABBREV));
if (wt->is_detached)
strbuf_addstr(&sb, "(detached HEAD)");
else if (wt->head_ref) {
@ -798,7 +798,7 @@ static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)
if (path_len > *maxlen)
*maxlen = path_len;
sha1_len = strlen(find_unique_abbrev(&wt[i]->head_oid, *abbrev));
sha1_len = strlen(repo_find_unique_abbrev(the_repository, &wt[i]->head_oid, *abbrev));
if (sha1_len > *abbrev)
*abbrev = sha1_len;
}

View File

@ -128,7 +128,7 @@ static int already_written(struct bulk_checkin_packfile *state, struct object_id
int i;
/* The object may already exist in the repository */
if (has_object_file(oid))
if (repo_has_object_file(the_repository, oid))
return 1;
/* Might want to keep the list sorted */

View File

@ -297,7 +297,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
if (revs->max_age == -1 && revs->min_age == -1)
goto out;
buf = read_object_file(&tag->oid, &type, &size);
buf = repo_read_object_file(the_repository, &tag->oid, &type, &size);
if (!buf)
goto out;
line = memmem(buf, size, "\ntagger ", 8);
@ -386,7 +386,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
if (e->item->flags & UNINTERESTING)
continue;
if (dwim_ref(e->name, strlen(e->name), &oid, &ref, 0) != 1)
if (repo_dwim_ref(the_repository, e->name, strlen(e->name),
&oid, &ref, 0) != 1)
goto skip_write_ref;
if (read_ref_full(e->name, RESOLVE_REF_READING, &oid, &flag))
flag = 0;

View File

@ -232,7 +232,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
int i;
if (!it)
return 0;
if (it->entry_count < 0 || !has_object_file(&it->oid))
if (it->entry_count < 0 || !repo_has_object_file(the_repository, &it->oid))
return 0;
for (i = 0; i < it->subtree_nr; i++) {
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
@ -243,7 +243,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
static int must_check_existence(const struct cache_entry *ce)
{
return !(has_promisor_remote() && ce_skip_worktree(ce));
return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
}
static int update_one(struct cache_tree *it,
@ -283,7 +283,7 @@ static int update_one(struct cache_tree *it,
}
}
if (0 <= it->entry_count && has_object_file(&it->oid))
if (0 <= it->entry_count && repo_has_object_file(the_repository, &it->oid))
return it->entry_count;
/*
@ -389,7 +389,7 @@ static int update_one(struct cache_tree *it,
ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
!must_check_existence(ce);
if (is_null_oid(oid) ||
(!ce_missing_ok && !has_object_file(oid))) {
(!ce_missing_ok && !repo_has_object_file(the_repository, oid))) {
strbuf_release(&buffer);
if (expected_missing)
return -1;
@ -437,7 +437,7 @@ static int update_one(struct cache_tree *it,
struct object_id oid;
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
OBJ_TREE, &oid);
if (has_object_file_with_flags(&oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
if (repo_has_object_file_with_flags(the_repository, &oid, OBJECT_INFO_SKIP_FETCH_OBJECT))
oidcpy(&it->oid, &oid);
else
to_invalidate = 1;
@ -473,7 +473,7 @@ int cache_tree_update(struct index_state *istate, int flags)
if (!istate->cache_tree)
istate->cache_tree = cache_tree();
if (!(flags & WRITE_TREE_MISSING_OK) && has_promisor_remote())
if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(the_repository))
prefetch_cache_entries(istate, must_check_existence);
trace_performance_enter();
@ -817,14 +817,14 @@ void prime_cache_tree(struct repository *r,
{
struct strbuf tree_path = STRBUF_INIT;
trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
trace2_region_enter("cache-tree", "prime_cache_tree", r);
cache_tree_free(&istate->cache_tree);
istate->cache_tree = cache_tree();
prime_cache_tree_rec(r, istate->cache_tree, tree, &tree_path);
strbuf_release(&tree_path);
istate->cache_changed |= CACHE_TREE_CHANGED;
trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
trace2_region_leave("cache-tree", "prime_cache_tree", r);
}
/*

19
cache.h
View File

@ -435,7 +435,7 @@ void validate_cache_entries(const struct index_state *istate);
/*
* Bulk prefetch all missing cache entries that are not GITLINKs and that match
* the given predicate. This function should only be called if
* has_promisor_remote() returns true.
* repo_has_promisor_remote() returns true.
*/
typedef int (*must_prefetch_predicate)(const struct cache_entry *);
void prefetch_cache_entries(const struct index_state *istate,
@ -700,7 +700,7 @@ extern int quote_path_fully;
* terminated.
*
* The non-`_r` version returns a static buffer which remains valid until 4
* more calls to find_unique_abbrev are made.
* more calls to repo_find_unique_abbrev are made.
*
* The `_r` variant writes to a buffer supplied by the caller, which must be at
* least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
@ -710,9 +710,7 @@ extern int quote_path_fully;
* reentrant, as it calls into other non-reentrant git code.
*/
const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
#define find_unique_abbrev(oid, len) repo_find_unique_abbrev(the_repository, oid, len)
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
/*
* Create the directory containing the named path, using care to be
@ -853,17 +851,8 @@ enum get_oid_result get_oid_with_context(struct repository *repo, const char *st
unsigned flags, struct object_id *oid,
struct object_context *oc);
#define get_oid(str, oid) repo_get_oid(the_repository, str, oid)
#define get_oid_commit(str, oid) repo_get_oid_commit(the_repository, str, oid)
#define get_oid_committish(str, oid) repo_get_oid_committish(the_repository, str, oid)
#define get_oid_tree(str, oid) repo_get_oid_tree(the_repository, str, oid)
#define get_oid_treeish(str, oid) repo_get_oid_treeish(the_repository, str, oid)
#define get_oid_blob(str, oid) repo_get_oid_blob(the_repository, str, oid)
#define get_oid_mb(str, oid) repo_get_oid_mb(the_repository, str, oid)
typedef int each_abbrev_fn(const struct object_id *oid, void *);
int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
#define for_each_abbrev(prefix, fn, data) repo_for_each_abbrev(the_repository, prefix, fn, data)
int set_disambiguate_hint_config(const char *var, const char *value);
@ -911,8 +900,6 @@ int repo_interpret_branch_name(struct repository *r,
const char *str, int len,
struct strbuf *buf,
const struct interpret_branch_name_options *options);
#define interpret_branch_name(str, len, buf, options) \
repo_interpret_branch_name(the_repository, str, len, buf, options)
int base_name_compare(const char *name1, size_t len1, int mode1,
const char *name2, size_t len2, int mode2);
@ -930,8 +917,6 @@ void *read_object_with_reference(struct repository *r,
struct object *repo_peel_to_type(struct repository *r,
const char *name, int namelen,
struct object *o, enum object_type);
#define peel_to_type(name, namelen, obj, type) \
repo_peel_to_type(the_repository, name, namelen, obj, type)
const char *git_editor(void);
const char *git_sequence_editor(void);

View File

@ -23,7 +23,7 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
memset(&query, 0, sizeof(struct refspec_item));
query.src = cb->src_ref;
if (remote_find_tracking(remote, &query) ||
get_oid(query.dst, cb->dst_oid)) {
repo_get_oid(the_repository, query.dst, cb->dst_oid)) {
free(query.dst);
return 0;
}

View File

@ -334,7 +334,7 @@ static char *grab_blob(struct repository *r,
*size = fill_textconv(r, textconv, df, &blob);
free_filespec(df);
} else {
blob = read_object_file(oid, &type, size);
blob = repo_read_object_file(r, oid, &type, size);
if (type != OBJ_BLOB)
die("object '%s' is not a blob!", oid_to_hex(oid));
}
@ -950,11 +950,11 @@ static void show_combined_header(struct combine_diff_path *elem,
"", elem->path, line_prefix, c_meta, c_reset);
printf("%s%sindex ", line_prefix, c_meta);
for (i = 0; i < num_parent; i++) {
abb = find_unique_abbrev(&elem->parent[i].oid,
abbrev);
abb = repo_find_unique_abbrev(the_repository,
&elem->parent[i].oid, abbrev);
printf("%s%s", i ? "," : "", abb);
}
abb = find_unique_abbrev(&elem->oid, abbrev);
abb = repo_find_unique_abbrev(the_repository, &elem->oid, abbrev);
printf("..%s%s\n", abb, c_reset);
if (mode_differs) {

View File

@ -2363,7 +2363,7 @@ int write_commit_graph(struct object_directory *odb,
replace = ctx->opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;
}
ctx->approx_nr_objects = approximate_object_count();
ctx->approx_nr_objects = repo_approximate_object_count(the_repository);
if (ctx->append && ctx->r->objects->commit_graph) {
struct commit_graph *g = ctx->r->objects->commit_graph;
@ -2552,7 +2552,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
graph_commit = lookup_commit(r, &cur_oid);
odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
if (parse_commit_internal(odb_commit, 0, 0)) {
if (repo_parse_commit_internal(r, odb_commit, 0, 0)) {
graph_report(_("failed to parse commit %s from object database for commit-graph"),
oid_to_hex(&cur_oid));
continue;

View File

@ -164,7 +164,8 @@ struct commit_list *get_octopus_merge_bases(struct commit_list *in)
for (j = ret; j; j = j->next) {
struct commit_list *bases;
bases = get_merge_bases(i->item, j->item);
bases = repo_get_merge_bases(the_repository, i->item,
j->item);
if (!new_commits)
new_commits = bases;
else
@ -449,7 +450,7 @@ int repo_is_descendant_of(struct repository *r,
if (!with_commit)
return 1;
if (generation_numbers_enabled(the_repository)) {
if (generation_numbers_enabled(r)) {
struct commit_list *from_list = NULL;
int result;
commit_list_insert(commit, &from_list);
@ -586,7 +587,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
return 0;
new_commit = (struct commit *) o;
if (parse_commit(new_commit) < 0)
if (repo_parse_commit(the_repository, new_commit) < 0)
return 0;
commit_list_insert(old_commit, &old_commit_list);
@ -750,7 +751,7 @@ int can_all_from_reach_with_flag(struct object_array *from,
}
list[nr_commits] = (struct commit *)from_one;
if (parse_commit(list[nr_commits]) ||
if (repo_parse_commit(the_repository, list[nr_commits]) ||
commit_graph_generation(list[nr_commits]) < min_generation) {
result = 0;
goto cleanup;
@ -785,7 +786,7 @@ int can_all_from_reach_with_flag(struct object_array *from,
if (!(parent->item->object.flags & assign_flag)) {
parent->item->object.flags |= assign_flag;
if (parse_commit(parent->item) ||
if (repo_parse_commit(the_repository, parent->item) ||
parent->item->date < min_commit_date ||
commit_graph_generation(parent->item) < min_generation)
continue;
@ -831,7 +832,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
while (from_iter) {
add_object_array(&from_iter->item->object, NULL, &from_objs);
if (!parse_commit(from_iter->item)) {
if (!repo_parse_commit(the_repository, from_iter->item)) {
timestamp_t generation;
if (from_iter->item->date < min_commit_date)
min_commit_date = from_iter->item->date;
@ -845,7 +846,7 @@ int can_all_from_reach(struct commit_list *from, struct commit_list *to,
}
while (to_iter) {
if (!parse_commit(to_iter->item)) {
if (!repo_parse_commit(the_repository, to_iter->item)) {
timestamp_t generation;
if (to_iter->item->date < min_commit_date)
min_commit_date = to_iter->item->date;
@ -895,7 +896,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
timestamp_t generation;
struct commit *c = *item;
parse_commit(c);
repo_parse_commit(the_repository, c);
generation = commit_graph_generation(c);
if (generation < min_generation)
min_generation = generation;
@ -910,7 +911,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
struct commit *c = *item;
if (!(c->object.flags & PARENT2)) {
c->object.flags |= PARENT2;
parse_commit(c);
repo_parse_commit(the_repository, c);
prio_queue_put(&queue, *item);
}
@ -929,7 +930,7 @@ struct commit_list *get_reachable_subset(struct commit **from, int nr_from,
for (parents = current->parents; parents; parents = parents->next) {
struct commit *p = parents->item;
parse_commit(p);
repo_parse_commit(the_repository, p);
if (commit_graph_generation(p) < min_generation)
continue;

View File

@ -19,11 +19,6 @@ struct commit_list *repo_get_merge_bases_many(struct repository *r,
struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
struct commit *one, int n,
struct commit **twos);
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
#define get_merge_bases(r1, r2) repo_get_merge_bases(the_repository, r1, r2)
#define get_merge_bases_many(one, n, two) repo_get_merge_bases_many(the_repository, one, n, two)
#define get_merge_bases_many_dirty(one, n, twos) repo_get_merge_bases_many_dirty(the_repository, one, n, twos)
#endif
struct commit_list *get_octopus_merge_bases(struct commit_list *in);
@ -36,10 +31,6 @@ int repo_in_merge_bases(struct repository *r,
int repo_in_merge_bases_many(struct repository *r,
struct commit *commit,
int nr_reference, struct commit **reference);
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
#define in_merge_bases(c1, c2) repo_in_merge_bases(the_repository, c1, c2)
#define in_merge_bases_many(c1, n, cs) repo_in_merge_bases_many(the_repository, c1, n, cs)
#endif
/*
* Takes a list of commits and returns a new list where those

View File

@ -84,10 +84,10 @@ struct commit *lookup_commit_reference_by_name(const char *name)
struct object_id oid;
struct commit *commit;
if (get_oid_committish(name, &oid))
if (repo_get_oid_committish(the_repository, name, &oid))
return NULL;
commit = lookup_commit_reference(the_repository, &oid);
if (parse_commit(commit))
if (repo_parse_commit(the_repository, commit))
return NULL;
return commit;
}
@ -386,7 +386,7 @@ struct tree *repo_get_commit_tree(struct repository *r,
struct object_id *get_commit_tree_oid(const struct commit *commit)
{
struct tree *tree = get_commit_tree(commit);
struct tree *tree = repo_get_commit_tree(the_repository, commit);
return tree ? &tree->object.oid : NULL;
}
@ -559,7 +559,7 @@ int repo_parse_commit_gently(struct repository *r,
void parse_commit_or_die(struct commit *item)
{
if (parse_commit(item))
if (repo_parse_commit(the_repository, item))
die("unable to parse commit %s",
item ? oid_to_hex(&item->object.oid) : "(null)");
}
@ -692,7 +692,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
while (parents) {
struct commit *commit = parents->item;
if (!parse_commit(commit) && !(commit->object.flags & mark)) {
if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) {
commit->object.flags |= mark;
commit_list_insert_by_date(commit, list);
}
@ -766,7 +766,8 @@ define_commit_slab(author_date_slab, timestamp_t);
void record_author_date(struct author_date_slab *author_date,
struct commit *commit)
{
const char *buffer = get_commit_buffer(commit, NULL);
const char *buffer = repo_get_commit_buffer(the_repository, commit,
NULL);
struct ident_split ident;
const char *ident_line;
size_t ident_len;
@ -786,7 +787,7 @@ void record_author_date(struct author_date_slab *author_date,
*(author_date_slab_at(author_date, commit)) = date;
fail_exit:
unuse_commit_buffer(commit, buffer);
repo_unuse_commit_buffer(the_repository, commit, buffer);
}
int compare_commits_by_author_date(const void *a_, const void *b_,
@ -969,7 +970,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
commit = lookup_commit(the_repository, oid);
if (!commit ||
(commit->object.flags & TMP_MARK) ||
parse_commit(commit))
repo_parse_commit(the_repository, commit))
return;
ALLOC_GROW(revs->commit, revs->nr + 1, revs->alloc);
@ -1001,7 +1002,8 @@ struct commit *get_fork_point(const char *refname, struct commit *commit)
struct commit *ret = NULL;
char *full_refname;
switch (dwim_ref(refname, strlen(refname), &oid, &full_refname, 0)) {
switch (repo_dwim_ref(the_repository, refname, strlen(refname), &oid,
&full_refname, 0)) {
case 0:
die("No such ref: '%s'", refname);
case 1:
@ -1020,7 +1022,8 @@ struct commit *get_fork_point(const char *refname, struct commit *commit)
for (i = 0; i < revs.nr; i++)
revs.commit[i]->object.flags &= ~TMP_MARK;
bases = get_merge_bases_many(commit, revs.nr, revs.commit);
bases = repo_get_merge_bases_many(the_repository, commit, revs.nr,
revs.commit);
/*
* There should be one and only one merge base, when we found
@ -1101,10 +1104,11 @@ int parse_signed_commit(const struct commit *commit,
const struct git_hash_algo *algop)
{
unsigned long size;
const char *buffer = get_commit_buffer(commit, &size);
const char *buffer = repo_get_commit_buffer(the_repository, commit,
&size);
int ret = parse_buffer_signed_by_header(buffer, size, payload, signature, algop);
unuse_commit_buffer(commit, buffer);
repo_unuse_commit_buffer(the_repository, commit, buffer);
return ret;
}
@ -1215,7 +1219,8 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header
desc = merge_remote_util(parent);
if (!desc || !desc->obj)
return;
buf = read_object_file(&desc->obj->oid, &type, &size);
buf = repo_read_object_file(the_repository, &desc->obj->oid, &type,
&size);
if (!buf || type != OBJ_TAG)
goto free_return;
if (!parse_signature(buf, size, &payload, &signature))
@ -1277,7 +1282,8 @@ void verify_merge_signature(struct commit *commit, int verbosity,
ret = check_commit_signature(commit, &signature_check);
find_unique_abbrev_r(hex, &commit->object.oid, DEFAULT_ABBREV);
repo_find_unique_abbrev_r(the_repository, hex, &commit->object.oid,
DEFAULT_ABBREV);
switch (signature_check.result) {
case 'G':
if (ret || (check_trust && signature_check.trust_level < TRUST_MARGINAL))
@ -1322,9 +1328,10 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,
{
struct commit_extra_header *extra = NULL;
unsigned long size;
const char *buffer = get_commit_buffer(commit, &size);
const char *buffer = repo_get_commit_buffer(the_repository, commit,
&size);
extra = read_commit_extra_header_lines(buffer, size, exclude);
unuse_commit_buffer(commit, buffer);
repo_unuse_commit_buffer(the_repository, commit, buffer);
return extra;
}
@ -1638,10 +1645,11 @@ struct commit *get_merge_parent(const char *name)
struct object *obj;
struct commit *commit;
struct object_id oid;
if (get_oid(name, &oid))
if (repo_get_oid(the_repository, name, &oid))
return NULL;
obj = parse_object(the_repository, &oid);
commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
commit = (struct commit *)repo_peel_to_type(the_repository, name, 0,
obj, OBJ_COMMIT);
if (commit && !merge_remote_util(commit))
set_merge_remote_desc(commit, name, obj);
return commit;

View File

@ -109,11 +109,6 @@ static inline int repo_parse_commit_no_graph(struct repository *r,
return repo_parse_commit_internal(r, commit, 0, 0);
}
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use)
#define parse_commit(item) repo_parse_commit(the_repository, item)
#endif
void parse_commit_or_die(struct commit *item);
struct buffer_slab;
@ -135,27 +130,21 @@ const void *get_cached_commit_buffer(struct repository *, const struct commit *,
/*
* Get the commit's object contents, either from cache or by reading the object
* from disk. The resulting memory should not be modified, and must be given
* to unuse_commit_buffer when the caller is done.
* to repo_unuse_commit_buffer when the caller is done.
*/
const void *repo_get_commit_buffer(struct repository *r,
const struct commit *,
unsigned long *size);
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
#define get_commit_buffer(c, s) repo_get_commit_buffer(the_repository, c, s)
#endif
/*
* Tell the commit subsystem that we are done with a particular commit buffer.
* The commit and buffer should be the input and return value, respectively,
* from an earlier call to get_commit_buffer. The buffer may or may not be
* from an earlier call to repo_get_commit_buffer. The buffer may or may not be
* freed by this call; callers should not access the memory afterwards.
*/
void repo_unuse_commit_buffer(struct repository *r,
const struct commit *,
const void *buffer);
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
#define unuse_commit_buffer(c, b) repo_unuse_commit_buffer(the_repository, c, b)
#endif
/*
* Free any cached object buffer associated with the commit.
@ -163,7 +152,6 @@ void repo_unuse_commit_buffer(struct repository *r,
void free_commit_buffer(struct parsed_object_pool *pool, struct commit *);
struct tree *repo_get_commit_tree(struct repository *, const struct commit *);
#define get_commit_tree(c) repo_get_commit_tree(the_repository, c)
struct object_id *get_commit_tree_oid(const struct commit *);
/*
@ -205,16 +193,10 @@ void free_commit_list(struct commit_list *list);
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
const char *logmsg_reencode(const struct commit *commit,
char **commit_encoding,
const char *output_encoding);
const char *repo_logmsg_reencode(struct repository *r,
const struct commit *commit,
char **commit_encoding,
const char *output_encoding);
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
#define logmsg_reencode(c, enc, out) repo_logmsg_reencode(the_repository, c, enc, out)
#endif
const char *skip_blank_lines(const char *msg);

View File

@ -56,7 +56,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
strbuf_release(&idx_file);
}
if (has_promisor_remote()) {
if (repo_has_promisor_remote(the_repository)) {
/*
* For partial clones, we don't want to have to do a regular
* connectivity check because we have to enumerate and exclude
@ -99,7 +99,7 @@ no_promisor_pack_found:
strvec_push(&rev_list.args,"rev-list");
strvec_push(&rev_list.args, "--objects");
strvec_push(&rev_list.args, "--stdin");
if (has_promisor_remote())
if (repo_has_promisor_remote(the_repository))
strvec_push(&rev_list.args, "--exclude-promisor-objects");
if (!opt->is_deepening_fetch) {
strvec_push(&rev_list.args, "--not");

View File

@ -0,0 +1,123 @@
// Fully migrated "the_repository" additions
@@
@@
(
// cache.h
- get_oid
+ repo_get_oid
|
- get_oid_commit
+ repo_get_oid_commit
|
- get_oid_committish
+ repo_get_oid_committish
|
- get_oid_tree
+ repo_get_oid_tree
|
- get_oid_treeish
+ repo_get_oid_treeish
|
- get_oid_blob
+ repo_get_oid_blob
|
- get_oid_mb
+ repo_get_oid_mb
|
- find_unique_abbrev
+ repo_find_unique_abbrev
|
- find_unique_abbrev_r
+ repo_find_unique_abbrev_r
|
- for_each_abbrev
+ repo_for_each_abbrev
|
- interpret_branch_name
+ repo_interpret_branch_name
|
- peel_to_type
+ repo_peel_to_type
// commit-reach.h
|
- get_merge_bases
+ repo_get_merge_bases
|
- get_merge_bases_many
+ repo_get_merge_bases_many
|
- get_merge_bases_many_dirty
+ repo_get_merge_bases_many_dirty
|
- in_merge_bases
+ repo_in_merge_bases
|
- in_merge_bases_many
+ repo_in_merge_bases_many
// commit.h
|
- parse_commit_internal
+ repo_parse_commit_internal
|
- parse_commit
+ repo_parse_commit
|
- get_commit_buffer
+ repo_get_commit_buffer
|
- unuse_commit_buffer
+ repo_unuse_commit_buffer
|
- logmsg_reencode
+ repo_logmsg_reencode
|
- get_commit_tree
+ repo_get_commit_tree
// diff.h
|
- diff_setup
+ repo_diff_setup
// object-store.h
|
- read_object_file
+ repo_read_object_file
|
- has_object_file
+ repo_has_object_file
|
- has_object_file_with_flags
+ repo_has_object_file_with_flags
// pretty.h
|
- format_commit_message
+ repo_format_commit_message
// packfile.h
|
- approximate_object_count
+ repo_approximate_object_count
// promisor-remote.h
|
- promisor_remote_reinit
+ repo_promisor_remote_reinit
|
- promisor_remote_find
+ repo_promisor_remote_find
|
- has_promisor_remote
+ repo_has_promisor_remote
// refs.h
|
- dwim_ref
+ repo_dwim_ref
// rerere.h
|
- rerere
+ repo_rerere
// revision.h
|
- init_revisions
+ repo_init_revisions
)
(
+ the_repository,
...)

View File

@ -1,128 +0,0 @@
// This file is used for the ongoing refactoring of
// bringing the index or repository struct in all of
// our code base.
@@
expression E;
expression F;
expression G;
@@
- read_object_file(
+ repo_read_object_file(the_repository,
E, F, G)
@@
expression E;
@@
- has_object_file(
+ repo_has_object_file(the_repository,
E)
@@
expression E;
@@
- has_object_file_with_flags(
+ repo_has_object_file_with_flags(the_repository,
E)
@@
expression E;
expression F;
expression G;
@@
- parse_commit_internal(
+ repo_parse_commit_internal(the_repository,
E, F, G)
@@
expression E;
expression F;
@@
- parse_commit_gently(
+ repo_parse_commit_gently(the_repository,
E, F)
@@
expression E;
@@
- parse_commit(
+ repo_parse_commit(the_repository,
E)
@@
expression E;
expression F;
@@
- get_merge_bases(
+ repo_get_merge_bases(the_repository,
E, F);
@@
expression E;
expression F;
expression G;
@@
- get_merge_bases_many(
+ repo_get_merge_bases_many(the_repository,
E, F, G);
@@
expression E;
expression F;
expression G;
@@
- get_merge_bases_many_dirty(
+ repo_get_merge_bases_many_dirty(the_repository,
E, F, G);
@@
expression E;
expression F;
@@
- in_merge_bases(
+ repo_in_merge_bases(the_repository,
E, F);
@@
expression E;
expression F;
expression G;
@@
- in_merge_bases_many(
+ repo_in_merge_bases_many(the_repository,
E, F, G);
@@
expression E;
expression F;
@@
- get_commit_buffer(
+ repo_get_commit_buffer(the_repository,
E, F);
@@
expression E;
expression F;
@@
- unuse_commit_buffer(
+ repo_unuse_commit_buffer(the_repository,
E, F);
@@
expression E;
expression F;
expression G;
@@
- logmsg_reencode(
+ repo_logmsg_reencode(the_repository,
E, F, G);
@@
expression E;
expression F;
expression G;
expression H;
@@
- format_commit_message(
+ repo_format_commit_message(the_repository,
E, F, G, H);

View File

@ -509,8 +509,9 @@ void propagate_island_marks(struct commit *commit)
struct commit_list *p;
struct island_bitmap *root_marks = kh_value(island_marks, pos);
parse_commit(commit);
set_island_marks(&get_commit_tree(commit)->object, root_marks);
repo_parse_commit(the_repository, commit);
set_island_marks(&repo_get_commit_tree(the_repository, commit)->object,
root_marks);
for (p = commit->parents; p; p = p->next)
set_island_marks(&p->item->object, root_marks);
}

View File

@ -583,7 +583,7 @@ void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb)
if (revs->pending.nr == 1) {
struct object_id oid;
if (get_oid("HEAD", &oid))
if (repo_get_oid(the_repository, "HEAD", &oid))
die(_("unable to get HEAD"));
mb_child[1] = lookup_commit_reference(the_repository, &oid);

6
diff.c
View File

@ -4358,7 +4358,7 @@ static int similarity_index(struct diff_filepair *p)
static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)
{
if (startup_info->have_repository)
return find_unique_abbrev(oid, abbrev);
return repo_find_unique_abbrev(the_repository, oid, abbrev);
else {
char *hex = oid_to_hex(oid);
if (abbrev < 0)
@ -4995,7 +4995,7 @@ static int diff_opt_find_object(const struct option *option,
struct object_id oid;
BUG_ON_OPT_NEG(unset);
if (get_oid(arg, &oid))
if (repo_get_oid(the_repository, arg, &oid))
return error(_("unable to resolve '%s'"), arg);
if (!opt->objfind)
@ -6867,7 +6867,7 @@ void diffcore_std(struct diff_options *options)
* If no prefetching occurs, diffcore_rename() will prefetch if it
* decides that it needs inexact rename detection.
*/
if (options->repo == the_repository && has_promisor_remote() &&
if (options->repo == the_repository && repo_has_promisor_remote(the_repository) &&
(options->output_format & output_formats_to_prefetch ||
options->pickaxe_opts & DIFF_PICKAXE_KINDS_MASK))
diff_queued_diff_prefetch(options->repo);

5
diff.h
View File

@ -534,9 +534,6 @@ int git_diff_basic_config(const char *var, const char *value, void *cb);
int git_diff_heuristic_config(const char *var, const char *value, void *cb);
void init_diff_ui_defaults(void);
int git_diff_ui_config(const char *var, const char *value, void *cb);
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
#define diff_setup(diffopts) repo_diff_setup(the_repository, diffopts)
#endif
void repo_diff_setup(struct repository *, struct diff_options *);
struct option *add_diff_options(const struct option *, struct diff_options *);
int diff_opt_parse(struct diff_options *, const char **, int, const char *);
@ -616,7 +613,7 @@ void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc);
#define DIFF_STATUS_FILTER_BROKEN 'B'
/*
* This is different from find_unique_abbrev() in that
* This is different from repo_find_unique_abbrev() in that
* it stuffs the result with dots for alignment.
*/
const char *diff_aligned_abbrev(const struct object_id *sha1, int);

View File

@ -65,7 +65,7 @@ static int should_break(struct repository *r,
oideq(&src->oid, &dst->oid))
return 0; /* they are the same */
if (r == the_repository && has_promisor_remote()) {
if (r == the_repository && repo_has_promisor_remote(the_repository)) {
options.missing_object_cb = diff_queued_diff_prefetch;
options.missing_object_data = r;
}

View File

@ -986,7 +986,7 @@ static int find_basename_matches(struct diff_options *options,
strintmap_set(&dests, base, i);
}
if (options->repo == the_repository && has_promisor_remote()) {
if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
dpf_options.missing_object_cb = basename_prefetch;
dpf_options.missing_object_data = &prefetch_options;
}
@ -1572,7 +1572,7 @@ void diffcore_rename_extended(struct diff_options *options,
/* Finish setting up dpf_options */
prefetch_options.skip_unmodified = skip_unmodified;
if (options->repo == the_repository && has_promisor_remote()) {
if (options->repo == the_repository && repo_has_promisor_remote(the_repository)) {
dpf_options.missing_object_cb = inexact_prefetch;
dpf_options.missing_object_data = &prefetch_options;
}

2
dir.c
View File

@ -273,7 +273,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat,
*size_out = 0;
*data_out = NULL;
data = read_object_file(oid, &type, &sz);
data = repo_read_object_file(the_repository, oid, &type, &sz);
if (!data || type != OBJ_BLOB) {
free(data);
return -1;

View File

@ -90,7 +90,8 @@ void *read_blob_entry(const struct cache_entry *ce, size_t *size)
{
enum object_type type;
unsigned long ul;
void *blob_data = read_object_file(&ce->oid, &type, &ul);
void *blob_data = repo_read_object_file(the_repository, &ce->oid,
&type, &ul);
*size = ul;
if (blob_data) {

View File

@ -767,7 +767,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
if (!commit) {
struct object *o;
if (!has_object_file_with_flags(&ref->old_oid,
if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
OBJECT_INFO_QUICK |
OBJECT_INFO_SKIP_FETCH_OBJECT))
continue;
@ -1968,7 +1968,7 @@ static void update_shallow(struct fetch_pack_args *args,
struct oid_array extra = OID_ARRAY_INIT;
struct object_id *oid = si->shallow->oid;
for (i = 0; i < si->shallow->nr; i++)
if (has_object_file(&oid[i]))
if (repo_has_object_file(the_repository, &oid[i]))
oid_array_append(&extra, &oid[i]);
if (extra.nr) {
setup_alternate_shallow(&shallow_lock,

View File

@ -270,9 +270,10 @@ static void record_person_from_buf(int which, struct string_list *people,
static void record_person(int which, struct string_list *people,
struct commit *commit)
{
const char *buffer = get_commit_buffer(commit, NULL);
const char *buffer = repo_get_commit_buffer(the_repository, commit,
NULL);
record_person_from_buf(which, people, buffer);
unuse_commit_buffer(commit, buffer);
repo_unuse_commit_buffer(the_repository, commit, buffer);
}
static int cmp_string_list_util_as_integral(const void *a_, const void *b_)
@ -383,7 +384,8 @@ static void shortlog(const char *name,
if (subjects.nr > limit)
continue;
format_commit_message(commit, "%s", &sb, &ctx);
repo_format_commit_message(the_repository, commit, "%s", &sb,
&ctx);
strbuf_ltrim(&sb);
if (!sb.len)
@ -518,7 +520,8 @@ static void fmt_merge_msg_sigs(struct strbuf *out)
struct object_id *oid = origins.items[i].util;
enum object_type type;
unsigned long size;
char *buf = read_object_file(oid, &type, &size);
char *buf = repo_read_object_file(the_repository, oid, &type,
&size);
char *origbuf = buf;
unsigned long len = size;
struct signature_check sigc = { NULL };
@ -604,7 +607,9 @@ static void find_merge_parents(struct merge_parents *result,
* util field yet.
*/
obj = parse_object(the_repository, &oid);
parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);
parent = (struct commit *)repo_peel_to_type(the_repository,
NULL, 0, obj,
OBJ_COMMIT);
if (!parent)
continue;
commit_list_insert(parent, &parents);

6
fsck.c
View File

@ -355,7 +355,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
int result;
const char *name;
if (parse_commit(commit))
if (repo_parse_commit(the_repository, commit))
return -1;
name = fsck_get_object_name(options, &commit->object.oid);
@ -363,7 +363,7 @@ static int fsck_walk_commit(struct commit *commit, void *data, struct fsck_optio
fsck_put_object_name(options, get_commit_tree_oid(commit),
"%s:", name);
result = options->walk((struct object *)get_commit_tree(commit),
result = options->walk((struct object *) repo_get_commit_tree(the_repository, commit),
OBJ_TREE, data, options);
if (result < 0)
return result;
@ -1334,7 +1334,7 @@ static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done,
if (oidset_contains(blobs_done, oid))
continue;
buf = read_object_file(oid, &type, &size);
buf = repo_read_object_file(the_repository, oid, &type, &size);
if (!buf) {
if (is_promisor_object(oid))
continue;

View File

@ -365,7 +365,8 @@ static void start_put(struct transfer_request *request)
ssize_t size;
git_zstream stream;
unpacked = read_object_file(&request->obj->oid, &type, &len);
unpacked = repo_read_object_file(the_repository, &request->obj->oid,
&type, &len);
hdrlen = format_object_header(hdr, sizeof(hdr), type, len);
/* Set it up */
@ -1334,7 +1335,8 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
int count = 0;
while ((commit = get_revision(revs)) != NULL) {
p = process_tree(get_commit_tree(commit), p);
p = process_tree(repo_get_commit_tree(the_repository, commit),
p);
commit->object.flags |= LOCAL;
if (!(commit->object.flags & UNINTERESTING))
count += add_send_request(&commit->object, lock);
@ -1429,7 +1431,7 @@ static void one_remote_ref(const char *refname)
* Fetch a copy of the object if it doesn't exist locally - it
* may be required for updating server info later.
*/
if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
if (repo->can_update_info_refs && !repo_has_object_file(the_repository, &ref->old_oid)) {
obj = lookup_unknown_object(the_repository, &ref->old_oid);
fprintf(stderr, " fetch %s for %s\n",
oid_to_hex(&ref->old_oid), refname);
@ -1573,7 +1575,7 @@ static int verify_merge_base(struct object_id *head_oid, struct ref *remote)
struct commit *branch = lookup_commit_or_die(&remote->old_oid,
remote->name);
return in_merge_bases(branch, head);
return repo_in_merge_bases(the_repository, branch, head);
}
static int delete_remote_branch(const char *pattern, int force)
@ -1630,14 +1632,14 @@ static int delete_remote_branch(const char *pattern, int force)
return error("Remote HEAD symrefs too deep");
if (is_null_oid(&head_oid))
return error("Unable to resolve remote HEAD");
if (!has_object_file(&head_oid))
if (!repo_has_object_file(the_repository, &head_oid))
return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid));
/* Remote branch must resolve to a known object */
if (is_null_oid(&remote_ref->old_oid))
return error("Unable to resolve remote branch %s",
remote_ref->name);
if (!has_object_file(&remote_ref->old_oid))
if (!repo_has_object_file(the_repository, &remote_ref->old_oid))
return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid));
/* Remote branch must be an ancestor of remote HEAD */
@ -1857,7 +1859,7 @@ int cmd_main(int argc, const char **argv)
if (!force_all &&
!is_null_oid(&ref->old_oid) &&
!ref->force) {
if (!has_object_file(&ref->old_oid) ||
if (!repo_has_object_file(the_repository, &ref->old_oid) ||
!ref_newer(&ref->peer_ref->new_oid,
&ref->old_oid)) {
/*

View File

@ -136,7 +136,7 @@ static int fill_active_slot(struct walker *walker)
list_for_each_safe(pos, tmp, head) {
obj_req = list_entry(pos, struct object_request, node);
if (obj_req->state == WAITING) {
if (has_object_file(&obj_req->oid))
if (repo_has_object_file(the_repository, &obj_req->oid))
obj_req->state = COMPLETE;
else {
start_object_request(walker, obj_req);
@ -493,7 +493,7 @@ static int fetch_object(struct walker *walker, unsigned char *hash)
if (!obj_req)
return error("Couldn't find request for %s in the queue", hex);
if (has_object_file(&obj_req->oid)) {
if (repo_has_object_file(the_repository, &obj_req->oid)) {
if (obj_req->req)
abort_http_object_request(obj_req->req);
abort_object_request(obj_req);

View File

@ -343,7 +343,7 @@ void partial_clone_register(
char *filter_name;
/* Check if it is already registered */
if ((promisor_remote = promisor_remote_find(remote))) {
if ((promisor_remote = repo_promisor_remote_find(the_repository, remote))) {
if (promisor_remote->partial_clone_filter)
/*
* Remote is already registered and a filter is already
@ -371,14 +371,15 @@ void partial_clone_register(
free(filter_name);
/* Make sure the config info are reset */
promisor_remote_reinit();
repo_promisor_remote_reinit(the_repository);
}
void partial_clone_get_default_filter_spec(
struct list_objects_filter_options *filter_options,
const char *remote)
{
struct promisor_remote *promisor = promisor_remote_find(remote);
struct promisor_remote *promisor = repo_promisor_remote_find(the_repository,
remote);
struct strbuf errbuf = STRBUF_INIT;
/*

View File

@ -66,7 +66,7 @@ static void process_blob(struct traversal_context *ctx,
* of missing objects.
*/
if (ctx->revs->exclude_promisor_objects &&
!has_object_file(&obj->oid) &&
!repo_has_object_file(the_repository, &obj->oid) &&
is_promisor_object(&obj->oid))
return;
@ -229,7 +229,8 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
struct commit *parent = parents->item;
if (!(parent->object.flags & UNINTERESTING))
continue;
mark_tree_uninteresting(revs->repo, get_commit_tree(parent));
mark_tree_uninteresting(revs->repo,
repo_get_commit_tree(the_repository, parent));
if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
parent->object.flags |= SHOWN;
show_edge(parent);
@ -246,7 +247,8 @@ static void add_edge_parents(struct commit *commit,
for (parents = commit->parents; parents; parents = parents->next) {
struct commit *parent = parents->item;
struct tree *tree = get_commit_tree(parent);
struct tree *tree = repo_get_commit_tree(the_repository,
parent);
if (!tree)
continue;
@ -277,7 +279,8 @@ void mark_edges_uninteresting(struct rev_info *revs,
for (list = revs->commits; list; list = list->next) {
struct commit *commit = list->item;
struct tree *tree = get_commit_tree(commit);
struct tree *tree = repo_get_commit_tree(the_repository,
commit);
if (commit->object.flags & UNINTERESTING)
tree->object.flags |= UNINTERESTING;
@ -293,7 +296,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
struct commit *commit = list->item;
if (commit->object.flags & UNINTERESTING) {
mark_tree_uninteresting(revs->repo,
get_commit_tree(commit));
repo_get_commit_tree(the_repository, commit));
if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
commit->object.flags |= SHOWN;
show_edge(commit);
@ -311,7 +314,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
continue;
mark_tree_uninteresting(revs->repo,
get_commit_tree(commit));
repo_get_commit_tree(the_repository, commit));
if (!(obj->flags & SHOWN)) {
obj->flags |= SHOWN;
show_edge(commit);
@ -378,8 +381,9 @@ static void do_traverse(struct traversal_context *ctx)
*/
if (!ctx->revs->tree_objects)
; /* do not bother loading tree */
else if (get_commit_tree(commit)) {
struct tree *tree = get_commit_tree(commit);
else if (repo_get_commit_tree(the_repository, commit)) {
struct tree *tree = repo_get_commit_tree(the_repository,
commit);
tree->object.flags |= NOT_USER_GIVEN;
add_pending_tree(ctx->revs, tree);
} else if (commit->object.parsed) {

View File

@ -238,7 +238,8 @@ static void show_parents(struct commit *commit, int abbrev, FILE *file)
struct commit_list *p;
for (p = commit->parents; p ; p = p->next) {
struct commit *parent = p->item;
fprintf(file, " %s", find_unique_abbrev(&parent->object.oid, abbrev));
fprintf(file, " %s",
repo_find_unique_abbrev(the_repository, &parent->object.oid, abbrev));
}
}
@ -246,7 +247,8 @@ static void show_children(struct rev_info *opt, struct commit *commit, int abbre
{
struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
for ( ; p; p = p->next) {
fprintf(opt->diffopt.file, " %s", find_unique_abbrev(&p->item->object.oid, abbrev));
fprintf(opt->diffopt.file, " %s",
repo_find_unique_abbrev(the_repository, &p->item->object.oid, abbrev));
}
}
@ -410,7 +412,8 @@ void fmt_output_commit(struct strbuf *filename,
struct pretty_print_context ctx = {0};
struct strbuf subject = STRBUF_INIT;
format_commit_message(commit, "%f", &subject, &ctx);
repo_format_commit_message(the_repository, commit, "%f", &subject,
&ctx);
fmt_output_subject(filename, subject.buf, info);
strbuf_release(&subject);
}
@ -649,7 +652,8 @@ void show_log(struct rev_info *opt)
if (!opt->graph)
put_revision_mark(opt, commit);
fputs(find_unique_abbrev(&commit->object.oid, abbrev_commit), opt->diffopt.file);
fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev_commit),
opt->diffopt.file);
if (opt->print_parents)
show_parents(commit, abbrev_commit, opt->diffopt.file);
if (opt->children.name)
@ -711,7 +715,7 @@ void show_log(struct rev_info *opt)
if (!opt->graph)
put_revision_mark(opt, commit);
fputs(find_unique_abbrev(&commit->object.oid,
fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid,
abbrev_commit),
opt->diffopt.file);
if (opt->print_parents)
@ -720,7 +724,7 @@ void show_log(struct rev_info *opt)
show_children(opt, commit, abbrev_commit);
if (parent)
fprintf(opt->diffopt.file, " (from %s)",
find_unique_abbrev(&parent->object.oid, abbrev_commit));
repo_find_unique_abbrev(the_repository, &parent->object.oid, abbrev_commit));
fputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);
show_decorations(opt, commit);
if (opt->commit_format == CMIT_FMT_ONELINE) {
@ -851,7 +855,7 @@ void show_log(struct rev_info *opt)
* Pass minimum required diff-options to range-diff; others
* can be added later if deemed desirable.
*/
diff_setup(&opts);
repo_diff_setup(the_repository, &opts);
opts.file = opt->diffopt.file;
opts.use_color = opt->diffopt.use_color;
diff_setup_done(&opts);
@ -987,15 +991,17 @@ static int do_remerge_diff(struct rev_info *opt,
o.msg_header_prefix = "remerge";
ctx.abbrev = DEFAULT_ABBREV;
format_commit_message(parent1, "%h (%s)", &parent1_desc, &ctx);
format_commit_message(parent2, "%h (%s)", &parent2_desc, &ctx);
repo_format_commit_message(the_repository, parent1, "%h (%s)",
&parent1_desc, &ctx);
repo_format_commit_message(the_repository, parent2, "%h (%s)",
&parent2_desc, &ctx);
o.branch1 = parent1_desc.buf;
o.branch2 = parent2_desc.buf;
/* Parse the relevant commits and get the merge bases */
parse_commit_or_die(parent1);
parse_commit_or_die(parent2);
bases = get_merge_bases(parent1, parent2);
bases = repo_get_merge_bases(the_repository, parent1, parent2);
/* Re-merge the parents */
merge_incore_recursive(&o, bases, parent1, parent2, &res);

View File

@ -215,10 +215,10 @@ static int read_mailmap_blob(struct string_list *map, const char *name)
if (!name)
return 0;
if (get_oid(name, &oid) < 0)
if (repo_get_oid(the_repository, name, &oid) < 0)
return 0;
buf = read_object_file(&oid, &type, &size);
buf = repo_read_object_file(the_repository, &oid, &type, &size);
if (!buf)
return error("unable to read mailmap object at %s", name);
if (type != OBJ_BLOB)

View File

@ -56,7 +56,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,
enum object_type type;
unsigned long size;
buffer = read_object_file(hash, &type, &size);
buffer = repo_read_object_file(the_repository, hash, &type, &size);
if (!buffer)
die("unable to read tree (%s)", oid_to_hex(hash));
if (type != OBJ_TREE)
@ -189,7 +189,7 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
if (*subpath)
subpath++;
buf = read_object_file(oid1, &type, &sz);
buf = repo_read_object_file(the_repository, oid1, &type, &sz);
if (!buf)
die("cannot read tree %s", oid_to_hex(oid1));
init_tree_desc(&desc, buf, sz);

View File

@ -12,7 +12,8 @@ static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
unsigned long size;
enum object_type type;
buf = read_object_file(&obj->object.oid, &type, &size);
buf = repo_read_object_file(the_repository, &obj->object.oid, &type,
&size);
if (!buf)
return -1;
if (type != OBJ_BLOB) {
@ -78,7 +79,8 @@ void *merge_blobs(struct index_state *istate, const char *path,
return NULL;
if (!our)
our = their;
return read_object_file(&our->object.oid, &type, size);
return repo_read_object_file(the_repository, &our->object.oid,
&type, size);
}
if (fill_mmfile_blob(&f1, our) < 0)

View File

@ -3508,7 +3508,7 @@ static int read_oid_strbuf(struct merge_options *opt,
void *buf;
enum object_type type;
unsigned long size;
buf = read_object_file(oid, &type, &size);
buf = repo_read_object_file(the_repository, oid, &type, &size);
if (!buf)
return err(opt, _("cannot read object %s"), oid_to_hex(oid));
if (type != OBJ_BLOB) {
@ -4219,7 +4219,7 @@ static void prefetch_for_content_merges(struct merge_options *opt,
struct string_list_item *e;
struct oid_array to_fetch = OID_ARRAY_INIT;
if (opt->repo != the_repository || !has_promisor_remote())
if (opt->repo != the_repository || !repo_has_promisor_remote(the_repository))
return;
for (e = &plist->items[plist->nr-1]; e >= plist->items; --e) {
@ -5020,7 +5020,7 @@ static void merge_ort_internal(struct merge_options *opt,
struct strbuf merge_base_abbrev = STRBUF_INIT;
if (!merge_bases) {
merge_bases = get_merge_bases(h1, h2);
merge_bases = repo_get_merge_bases(the_repository, h1, h2);
/* See merge-ort.h:merge_incore_recursive() declaration NOTE */
merge_bases = reverse_commit_list(merge_bases);
}

View File

@ -954,7 +954,8 @@ static int update_file_flags(struct merge_options *opt,
goto update_index;
}
buf = read_object_file(&contents->oid, &type, &size);
buf = repo_read_object_file(the_repository, &contents->oid,
&type, &size);
if (!buf) {
ret = err(opt, _("cannot read object %s '%s'"),
oid_to_hex(&contents->oid), path);
@ -3024,7 +3025,7 @@ static int read_oid_strbuf(struct merge_options *opt,
void *buf;
enum object_type type;
unsigned long size;
buf = read_object_file(oid, &type, &size);
buf = repo_read_object_file(the_repository, oid, &type, &size);
if (!buf)
return err(opt, _("cannot read object %s"), oid_to_hex(oid));
if (type != OBJ_BLOB) {
@ -3595,7 +3596,7 @@ static int merge_recursive_internal(struct merge_options *opt,
}
if (!merge_bases) {
merge_bases = get_merge_bases(h1, h2);
merge_bases = repo_get_merge_bases(the_repository, h1, h2);
merge_bases = reverse_commit_list(merge_bases);
}
@ -3800,7 +3801,7 @@ static struct commit *get_ref(struct repository *repo,
return make_virtual_commit(repo, (struct tree*)object, name);
if (object->type != OBJ_COMMIT)
return NULL;
if (parse_commit((struct commit *)object))
if (repo_parse_commit(repo, (struct commit *)object))
return NULL;
return (struct commit *)object;
}

View File

@ -25,7 +25,7 @@ static void rev_list_push(struct negotiation_state *ns,
if (!(commit->object.flags & mark)) {
commit->object.flags |= mark;
if (parse_commit(commit))
if (repo_parse_commit(the_repository, commit))
return;
prio_queue_put(&ns->rev_list, commit);
@ -69,7 +69,7 @@ static void mark_common(struct negotiation_state *ns, struct commit *commit,
if (!ancestors_only && !(o->flags & POPPED))
ns->non_common_revs--;
if (!o->parsed && !dont_parse)
if (parse_commit(commit))
if (repo_parse_commit(the_repository, commit))
return;
for (parents = commit->parents;
@ -96,7 +96,7 @@ static const struct object_id *get_rev(struct negotiation_state *ns)
return NULL;
commit = prio_queue_get(&ns->rev_list);
parse_commit(commit);
repo_parse_commit(the_repository, commit);
parents = commit->parents;
commit->object.flags |= POPPED;

View File

@ -184,7 +184,7 @@ static const struct object_id *get_rev(struct data *data)
if (!(commit->object.flags & COMMON) && !entry->ttl)
to_send = commit;
parse_commit(commit);
repo_parse_commit(the_repository, commit);
for (p = commit->parents; p; p = p->next)
parent_pushed |= push_parent(data, entry, p->item);

Some files were not shown because too many files have changed in this diff Show More