Merge branch 'ab/remove-implicit-use-of-the-repository'
Code clean-up around the use of the_repository. * 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:
commit
72871b198f
@ -552,7 +552,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;
|
||||
|
@ -415,7 +415,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
13
apply.c
@ -3203,7 +3203,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"),
|
||||
@ -3266,7 +3267,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 */
|
||||
@ -3494,7 +3496,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;
|
||||
@ -3612,7 +3615,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."));
|
||||
|
||||
@ -4129,7 +4132,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 */
|
||||
|
12
archive.c
12
archive.c
@ -61,7 +61,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;
|
||||
}
|
||||
@ -86,7 +87,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;
|
||||
@ -457,13 +458,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);
|
||||
|
11
bisect.c
11
bisect.c
@ -149,8 +149,9 @@ 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,
|
||||
&size);
|
||||
char *buf = repo_read_object_file(the_repository,
|
||||
&commit->object.oid, &type,
|
||||
&size);
|
||||
const char *subject_start;
|
||||
int subject_len;
|
||||
|
||||
@ -752,7 +753,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);
|
||||
|
||||
@ -847,7 +849,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;
|
||||
|
15
blame.c
15
blame.c
@ -1026,8 +1026,9 @@ 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_size);
|
||||
file->ptr = repo_read_object_file(the_repository,
|
||||
&o->blob_oid, &type,
|
||||
&file_size);
|
||||
file->size = file_size;
|
||||
|
||||
if (!file->ptr)
|
||||
@ -2427,7 +2428,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)
|
||||
@ -2590,7 +2591,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)))
|
||||
@ -2851,8 +2852,10 @@ 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_size);
|
||||
sb->final_buf = repo_read_object_file(the_repository,
|
||||
&o->blob_oid,
|
||||
&type,
|
||||
&sb->final_buf_size);
|
||||
|
||||
if (!sb->final_buf)
|
||||
die(_("cannot read blob %s for path %s"),
|
||||
|
7
branch.c
7
branch.c
@ -532,7 +532,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,
|
||||
@ -542,7 +542,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)
|
||||
@ -773,7 +774,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;
|
||||
|
23
builtin/am.c
23
builtin/am.c
@ -1067,7 +1067,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,
|
||||
@ -1110,7 +1110,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", "");
|
||||
@ -1330,7 +1330,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)
|
||||
@ -1362,7 +1363,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1403,9 +1404,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);
|
||||
@ -1557,7 +1558,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))
|
||||
@ -1647,7 +1648,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);
|
||||
@ -2089,7 +2090,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))
|
||||
@ -2131,7 +2132,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))
|
||||
@ -2164,7 +2165,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);
|
||||
|
||||
|
@ -236,7 +236,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);
|
||||
}
|
||||
@ -267,7 +267,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);
|
||||
@ -294,7 +295,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;
|
||||
}
|
||||
@ -569,7 +570,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;
|
||||
@ -605,8 +606,8 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
|
||||
|
||||
while ((commit = get_revision(&revs)) != NULL) {
|
||||
strbuf_reset(&commit_name);
|
||||
format_commit_message(commit, "%s",
|
||||
&commit_name, &pp);
|
||||
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),
|
||||
commit_name.buf);
|
||||
@ -635,7 +636,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),
|
||||
@ -777,7 +779,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"));
|
||||
|
||||
/*
|
||||
@ -803,11 +805,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 {
|
||||
@ -830,7 +832,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;
|
||||
}
|
||||
@ -935,11 +937,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)
|
||||
@ -955,7 +958,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;
|
||||
@ -1094,7 +1097,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))
|
||||
|
@ -201,13 +201,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;
|
||||
}
|
||||
|
||||
@ -221,7 +221,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);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -603,8 +603,9 @@ 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,
|
||||
auto_abbrev);
|
||||
const char *uniq = repo_find_unique_abbrev(the_repository,
|
||||
&suspect->commit->object.oid,
|
||||
auto_abbrev);
|
||||
int len = strlen(uniq);
|
||||
if (auto_abbrev < len)
|
||||
return len;
|
||||
@ -804,7 +805,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);
|
||||
}
|
||||
@ -847,7 +848,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);
|
||||
|
@ -150,17 +150,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."),
|
||||
@ -280,7 +281,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);
|
||||
|
@ -64,7 +64,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);
|
||||
@ -156,7 +156,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':
|
||||
|
||||
@ -191,7 +191,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);
|
||||
|
||||
@ -211,8 +212,10 @@ 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,
|
||||
&size);
|
||||
char *buffer = repo_read_object_file(the_repository,
|
||||
&oid,
|
||||
&type,
|
||||
&size);
|
||||
const char *target;
|
||||
if (!skip_prefix(buffer, "object ", &target) ||
|
||||
get_oid_hex(target, &blob_oid))
|
||||
@ -387,9 +390,10 @@ 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,
|
||||
&type,
|
||||
&size);
|
||||
contents = repo_read_object_file(the_repository,
|
||||
oid,
|
||||
&type,
|
||||
&size);
|
||||
if (!contents)
|
||||
die("could not convert '%s' %s",
|
||||
oid_to_hex(oid), data->rest);
|
||||
@ -406,7 +410,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;
|
||||
@ -791,7 +796,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;
|
||||
|
@ -433,8 +433,8 @@ 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,
|
||||
DEFAULT_ABBREV));
|
||||
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",
|
||||
"Updated %d paths from the index",
|
||||
@ -654,14 +654,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);
|
||||
}
|
||||
@ -715,7 +717,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);
|
||||
@ -767,7 +770,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)
|
||||
@ -829,7 +833,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 "
|
||||
@ -1018,7 +1023,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');
|
||||
}
|
||||
@ -1074,7 +1079,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));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1218,7 +1223,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1336,7 +1342,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
|
||||
@ -1433,7 +1439,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))
|
||||
@ -1762,7 +1769,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,
|
||||
|
@ -548,9 +548,9 @@ 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,
|
||||
OBJECT_INFO_QUICK |
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT))
|
||||
if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
|
||||
OBJECT_INFO_QUICK |
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT))
|
||||
continue;
|
||||
update_ref(msg, ref->name, &ref->old_oid, NULL, 0,
|
||||
UPDATE_REFS_DIE_ON_ERR);
|
||||
|
@ -46,7 +46,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);
|
||||
@ -124,7 +124,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) {
|
||||
|
@ -557,7 +557,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;
|
||||
@ -712,15 +712,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,
|
||||
@ -760,8 +760,9 @@ 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,
|
||||
&ctx);
|
||||
repo_format_commit_message(the_repository, c,
|
||||
"squash! %s\n\n", &sb,
|
||||
&ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -795,7 +796,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";
|
||||
|
||||
@ -1000,7 +1002,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. */
|
||||
@ -1135,7 +1137,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);
|
||||
}
|
||||
@ -1183,7 +1186,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);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1567,7 +1570,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);
|
||||
|
||||
@ -1710,11 +1713,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 */
|
||||
|
@ -262,7 +262,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;
|
||||
@ -299,7 +299,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)
|
||||
@ -404,7 +405,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;
|
||||
@ -532,7 +533,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);
|
||||
|
||||
|
@ -548,7 +548,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))
|
||||
|
@ -296,7 +296,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);
|
||||
|
@ -310,7 +310,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,
|
||||
@ -632,7 +632,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",
|
||||
@ -713,7 +713,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;
|
||||
@ -780,7 +780,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);
|
||||
@ -931,7 +932,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) {
|
||||
|
@ -1267,7 +1267,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));
|
||||
}
|
||||
@ -1627,7 +1627,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),
|
||||
@ -2488,7 +2488,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,
|
||||
@ -2601,7 +2601,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;
|
||||
@ -2656,7 +2656,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,
|
||||
@ -2829,7 +2829,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);
|
||||
@ -2938,7 +2938,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);
|
||||
@ -3046,7 +3046,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));
|
||||
|
@ -417,9 +417,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;
|
||||
@ -433,7 +433,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);
|
||||
|
||||
@ -454,7 +454,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);
|
||||
|
||||
@ -1014,7 +1014,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;
|
||||
@ -1347,8 +1348,8 @@ 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,
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT))
|
||||
if (!repo_has_object_file_with_flags(the_repository, &r->old_oid,
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT))
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1495,7 +1496,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);
|
||||
@ -2023,7 +2024,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;
|
||||
|
||||
/*
|
||||
@ -2279,7 +2280,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 {
|
||||
|
@ -959,7 +959,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);
|
||||
|
||||
|
@ -285,7 +285,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)
|
||||
@ -700,7 +700,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;
|
||||
@ -821,7 +821,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;
|
||||
|
||||
@ -838,7 +838,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;
|
||||
|
@ -562,7 +562,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);
|
||||
@ -652,7 +653,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));
|
||||
|
@ -804,7 +804,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();
|
||||
}
|
||||
|
||||
@ -824,7 +825,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);
|
||||
@ -1391,7 +1393,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.
|
||||
*/
|
||||
@ -1417,7 +1419,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;
|
||||
|
||||
|
@ -676,7 +676,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)
|
||||
@ -1218,7 +1218,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);
|
||||
@ -1328,10 +1329,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)
|
||||
@ -1384,7 +1386,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);
|
||||
@ -1656,14 +1658,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) {
|
||||
@ -1697,7 +1701,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"));
|
||||
@ -1715,7 +1721,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 {
|
||||
@ -2414,7 +2420,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) {
|
||||
@ -2436,12 +2442,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);
|
||||
}
|
||||
|
@ -363,7 +363,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);
|
||||
}
|
||||
@ -578,7 +578,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)
|
||||
|
@ -229,7 +229,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;
|
||||
}
|
||||
@ -260,7 +260,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;
|
||||
}
|
||||
@ -311,7 +312,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);
|
||||
@ -434,7 +435,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]);
|
||||
|
||||
/*
|
||||
|
@ -14,7 +14,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;
|
||||
@ -43,7 +44,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)
|
||||
@ -106,7 +107,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;
|
||||
@ -119,7 +120,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);
|
||||
|
@ -49,7 +49,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix UNUSED)
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -70,9 +70,9 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix UNUSED)
|
||||
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);
|
||||
|
@ -70,7 +70,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;
|
||||
@ -93,8 +95,9 @@ 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,
|
||||
&type, size);
|
||||
return repo_read_object_file(the_repository,
|
||||
&entry->blob->object.oid,
|
||||
&type, size);
|
||||
entry = entry->link;
|
||||
}
|
||||
return NULL;
|
||||
@ -444,16 +447,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);
|
||||
|
@ -339,7 +339,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:
|
||||
@ -519,7 +519,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);
|
||||
@ -1530,7 +1531,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);
|
||||
@ -1566,10 +1568,10 @@ 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,
|
||||
DEFAULT_ABBREV),
|
||||
find_unique_abbrev(&remoteheads->item->object.oid,
|
||||
DEFAULT_ABBREV));
|
||||
repo_find_unique_abbrev(the_repository, &head_commit->object.oid,
|
||||
DEFAULT_ABBREV),
|
||||
repo_find_unique_abbrev(the_repository, &remoteheads->item->object.oid,
|
||||
DEFAULT_ABBREV));
|
||||
}
|
||||
commit = remoteheads->item;
|
||||
if (!commit) {
|
||||
@ -1609,7 +1611,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,
|
||||
@ -1648,7 +1651,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;
|
||||
|
@ -52,7 +52,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));
|
||||
|
@ -182,7 +182,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;
|
||||
|
||||
@ -212,7 +212,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;
|
||||
|
||||
@ -494,7 +494,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);
|
||||
@ -528,7 +529,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)
|
||||
@ -605,7 +606,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;
|
||||
|
@ -126,7 +126,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);
|
||||
@ -259,9 +259,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);
|
||||
@ -309,9 +309,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)
|
||||
@ -379,7 +379,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) {
|
||||
@ -434,7 +434,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);
|
||||
@ -522,12 +522,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);
|
||||
@ -606,7 +606,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);
|
||||
@ -618,7 +618,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)
|
||||
@ -668,7 +669,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);
|
||||
@ -718,11 +719,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)
|
||||
@ -743,7 +744,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,
|
||||
@ -897,7 +899,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)
|
||||
|
@ -291,11 +291,13 @@ 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_size);
|
||||
base_buf = repo_read_object_file(the_repository,
|
||||
&DELTA(entry)->idx.oid, &type,
|
||||
&base_size);
|
||||
if (!base_buf)
|
||||
die("unable to read %s",
|
||||
oid_to_hex(&DELTA(entry)->idx.oid));
|
||||
@ -457,7 +459,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));
|
||||
@ -1668,7 +1672,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) {
|
||||
@ -2077,7 +2081,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)
|
||||
@ -2528,7 +2532,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"),
|
||||
@ -2541,7 +2547,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) {
|
||||
|
@ -172,7 +172,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, "");
|
||||
|
@ -1031,7 +1031,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) {
|
||||
@ -1056,7 +1056,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) &&
|
||||
|
@ -65,20 +65,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]);
|
||||
|
@ -199,7 +199,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);
|
||||
|
@ -222,13 +222,15 @@ 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,
|
||||
DEFAULT_ABBREV);
|
||||
shortrev = repo_find_unique_abbrev(the_repository,
|
||||
&base_rev->object.oid,
|
||||
DEFAULT_ABBREV);
|
||||
|
||||
*shortrevisions = xstrfmt("%s..%s", shortrev, shorthead);
|
||||
} else
|
||||
@ -876,7 +878,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)
|
||||
@ -905,7 +907,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;
|
||||
|
||||
@ -924,7 +926,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
|
||||
@ -1306,7 +1309,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);
|
||||
@ -1721,7 +1724,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);
|
||||
@ -1824,7 +1827,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 |=
|
||||
|
@ -1345,7 +1345,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,
|
||||
@ -1494,7 +1494,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";
|
||||
@ -1548,7 +1548,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";
|
||||
@ -1681,11 +1681,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";
|
||||
|
@ -443,7 +443,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
|
||||
|
@ -903,7 +903,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)
|
||||
|
@ -56,7 +56,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);
|
||||
@ -114,7 +114,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;
|
||||
@ -208,10 +208,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);
|
||||
|
||||
@ -322,7 +322,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);
|
||||
@ -377,7 +377,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]);
|
||||
@ -424,7 +424,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))
|
||||
@ -454,15 +454,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);
|
||||
|
@ -90,7 +90,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."));
|
||||
@ -125,7 +125,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)
|
||||
@ -261,8 +261,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.
|
||||
@ -289,9 +289,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,
|
||||
@ -367,13 +367,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)
|
||||
@ -381,7 +382,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)
|
||||
@ -466,7 +467,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);
|
||||
|
||||
|
@ -135,7 +135,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);
|
||||
|
@ -138,7 +138,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
|
||||
@ -164,7 +166,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));
|
||||
}
|
||||
@ -189,7 +192,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;
|
||||
}
|
||||
@ -281,7 +284,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) {
|
||||
@ -293,7 +296,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);
|
||||
@ -339,7 +342,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;
|
||||
@ -870,7 +873,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")) {
|
||||
|
@ -371,7 +371,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);
|
||||
|
@ -176,10 +176,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;
|
||||
@ -202,7 +203,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)
|
||||
@ -222,7 +223,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);
|
||||
@ -248,7 +250,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>";
|
||||
|
||||
|
@ -241,7 +241,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;
|
||||
@ -313,8 +313,8 @@ static void show_one_commit(struct commit *commit, int no_name)
|
||||
}
|
||||
else
|
||||
printf("[%s] ",
|
||||
find_unique_abbrev(&commit->object.oid,
|
||||
DEFAULT_ABBREV));
|
||||
repo_find_unique_abbrev(the_repository, &commit->object.oid,
|
||||
DEFAULT_ABBREV));
|
||||
}
|
||||
puts(pretty_str);
|
||||
strbuf_release(&pretty);
|
||||
@ -415,7 +415,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);
|
||||
}
|
||||
@ -430,7 +430,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);
|
||||
}
|
||||
@ -534,7 +534,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;
|
||||
}
|
||||
@ -747,7 +747,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? */
|
||||
@ -837,13 +838,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,
|
||||
|
@ -27,14 +27,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
|
||||
@ -44,7 +44,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);
|
||||
}
|
||||
}
|
||||
|
@ -469,7 +469,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 */
|
||||
|
@ -202,7 +202,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);
|
||||
@ -212,7 +212,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 */
|
||||
@ -232,7 +233,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);
|
||||
@ -428,7 +429,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;
|
||||
@ -601,7 +602,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."));
|
||||
@ -901,7 +902,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 |
|
||||
@ -1084,13 +1085,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;
|
||||
@ -1277,7 +1278,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);
|
||||
@ -1356,7 +1357,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"));
|
||||
@ -1374,8 +1375,9 @@ 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,
|
||||
DEFAULT_ABBREV);
|
||||
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);
|
||||
|
||||
|
@ -1110,7 +1110,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);
|
||||
@ -1176,7 +1176,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--;
|
||||
@ -1189,7 +1189,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"));
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,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);
|
||||
}
|
||||
@ -212,7 +212,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)) {
|
||||
@ -363,7 +363,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 {
|
||||
@ -591,7 +591,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))
|
||||
@ -632,7 +632,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);
|
||||
|
@ -11,7 +11,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));
|
||||
|
||||
@ -30,7 +30,7 @@ int cmd_unpack_file(int argc, const char **argv, const char *prefix UNUSED)
|
||||
|
||||
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);
|
||||
|
@ -444,7 +444,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))
|
||||
@ -510,7 +510,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));
|
||||
|
@ -116,7 +116,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: */
|
||||
@ -134,7 +134,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: */
|
||||
@ -549,7 +549,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);
|
||||
}
|
||||
|
||||
@ -560,7 +560,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);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,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);
|
||||
|
@ -52,7 +52,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;
|
||||
}
|
||||
|
@ -552,7 +552,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 {
|
||||
@ -566,7 +566,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);
|
||||
}
|
||||
@ -756,7 +756,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) {
|
||||
@ -793,7 +793,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;
|
||||
}
|
||||
|
@ -126,7 +126,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 */
|
||||
|
5
bundle.c
5
bundle.c
@ -294,7 +294,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);
|
||||
@ -383,7 +383,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;
|
||||
|
16
cache-tree.c
16
cache-tree.c
@ -231,7 +231,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))
|
||||
@ -242,7 +242,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,
|
||||
@ -282,7 +282,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;
|
||||
|
||||
/*
|
||||
@ -388,7 +388,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;
|
||||
@ -436,7 +436,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;
|
||||
@ -472,7 +472,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();
|
||||
@ -816,14 +816,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
19
cache.h
@ -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,
|
||||
@ -1093,7 +1093,7 @@ void check_repository_format(struct repository_format *fmt);
|
||||
* 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
|
||||
@ -1103,9 +1103,7 @@ void check_repository_format(struct repository_format *fmt);
|
||||
* 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)
|
||||
|
||||
/* set default permissions by passing mode arguments to open(2) */
|
||||
int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
|
||||
@ -1330,17 +1328,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);
|
||||
|
||||
@ -1388,8 +1377,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 validate_headref(const char *ref);
|
||||
|
||||
@ -1409,8 +1396,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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -333,7 +333,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));
|
||||
}
|
||||
@ -949,11 +949,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) {
|
||||
|
@ -2426,7 +2426,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;
|
||||
@ -2615,7 +2615,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;
|
||||
|
@ -165,7 +165,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
|
||||
@ -450,7 +451,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);
|
||||
@ -587,7 +588,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);
|
||||
@ -751,7 +752,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;
|
||||
@ -786,7 +787,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;
|
||||
@ -832,7 +833,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;
|
||||
@ -846,7 +847,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;
|
||||
@ -896,7 +897,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;
|
||||
@ -911,7 +912,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);
|
||||
}
|
||||
@ -930,7 +931,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;
|
||||
|
@ -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
|
||||
|
44
commit.c
44
commit.c
@ -81,10 +81,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;
|
||||
}
|
||||
@ -383,7 +383,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;
|
||||
}
|
||||
|
||||
@ -556,7 +556,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)");
|
||||
}
|
||||
@ -689,7 +689,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);
|
||||
}
|
||||
@ -763,7 +763,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;
|
||||
@ -783,7 +784,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_,
|
||||
@ -966,7 +967,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);
|
||||
@ -998,7 +999,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:
|
||||
@ -1017,7 +1019,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
|
||||
@ -1098,10 +1101,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;
|
||||
}
|
||||
|
||||
@ -1212,7 +1216,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))
|
||||
@ -1274,7 +1279,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))
|
||||
@ -1319,9 +1325,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;
|
||||
}
|
||||
|
||||
@ -1635,10 +1642,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;
|
||||
|
22
commit.h
22
commit.h
@ -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);
|
||||
|
||||
|
@ -55,7 +55,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
|
||||
@ -98,7 +98,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");
|
||||
|
123
contrib/coccinelle/the_repository.cocci
Normal file
123
contrib/coccinelle/the_repository.cocci
Normal 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,
|
||||
...)
|
@ -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);
|
@ -508,8 +508,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);
|
||||
}
|
||||
|
@ -582,7 +582,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
6
diff.c
@ -4364,7 +4364,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)
|
||||
@ -5000,7 +5000,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)
|
||||
@ -6885,7 +6885,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
5
diff.h
@ -536,9 +536,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 *);
|
||||
@ -618,7 +615,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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
2
dir.c
@ -268,7 +268,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;
|
||||
|
3
entry.c
3
entry.c
@ -87,7 +87,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) {
|
||||
|
@ -764,9 +764,9 @@ 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,
|
||||
OBJECT_INFO_QUICK |
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT))
|
||||
if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid,
|
||||
OBJECT_INFO_QUICK |
|
||||
OBJECT_INFO_SKIP_FETCH_OBJECT))
|
||||
continue;
|
||||
o = parse_object(the_repository, &ref->old_oid);
|
||||
if (!o || o->type != OBJ_COMMIT)
|
||||
@ -1965,7 +1965,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,
|
||||
|
@ -269,9 +269,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_)
|
||||
@ -382,7 +383,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)
|
||||
@ -517,7 +519,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 };
|
||||
@ -603,7 +606,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
6
fsck.c
@ -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;
|
||||
|
16
http-push.c
16
http-push.c
@ -363,7 +363,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 */
|
||||
@ -1332,7 +1333,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);
|
||||
@ -1427,7 +1429,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);
|
||||
@ -1571,7 +1573,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)
|
||||
@ -1628,14 +1630,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 */
|
||||
@ -1855,7 +1857,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)) {
|
||||
/*
|
||||
|
@ -135,7 +135,7 @@ static int fill_active_slot(void *data UNUSED)
|
||||
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(obj_req);
|
||||
@ -492,7 +492,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);
|
||||
|
@ -344,7 +344,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
|
||||
@ -372,14 +372,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;
|
||||
|
||||
/*
|
||||
|
@ -65,7 +65,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;
|
||||
|
||||
@ -228,7 +228,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);
|
||||
@ -245,7 +246,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;
|
||||
@ -276,7 +278,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;
|
||||
@ -292,7 +295,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);
|
||||
@ -310,7 +313,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);
|
||||
@ -377,8 +380,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) {
|
||||
|
28
log-tree.c
28
log-tree.c
@ -236,7 +236,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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +245,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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,7 +410,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);
|
||||
}
|
||||
@ -647,7 +650,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)
|
||||
@ -709,8 +713,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),
|
||||
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);
|
||||
@ -718,7 +722,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) {
|
||||
@ -849,7 +853,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);
|
||||
@ -985,15 +989,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);
|
||||
|
@ -190,10 +190,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)
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -3506,7 +3506,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) {
|
||||
@ -4217,7 +4217,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) {
|
||||
@ -5018,7 +5018,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);
|
||||
}
|
||||
|
@ -951,7 +951,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);
|
||||
@ -3021,7 +3022,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) {
|
||||
@ -3592,7 +3593,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);
|
||||
}
|
||||
|
||||
@ -3797,7 +3798,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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
Loading…
Reference in New Issue
Block a user