libs: use "struct repository *" argument, not "the_repository"

As can easily be seen from grepping in our sources, we had these uses of "the_repository" in various library code in cases where the function in question was already getting a "struct repository *" argument. Let's use that argument instead. Out of these changes only the changes to "cache-tree.c", "commit-reach.c", "shallow.c" and "upload-pack.c" would have cleanly applied before the migration away from the "repo_*()" wrapper macros in the preceding commits. The rest aren't new, as we'd previously implicitly refer to "the_repository", but it's now more obvious that we were doing the wrong thing all along, and should have used the parameter instead. The change to change "get_index_format_default(the_repository)" in "read-cache.c" to use the "r" variable instead should arguably have been part of [1], or in the subsequent cleanup in [2]. Let's do it here, as can be seen from the initial code in [3] it's not important that we use "the_repository" there, but would prefer to always use the current repository. This change excludes the "the_repository" use in "upload-pack.c"'s upload_pack_advertise(), as the in-flight [4] makes that change. 1. ee1f0c242ef (read-cache: add index.skipHash config option, 2023-01-06) 2. 6269f8eaad0 (treewide: always have a valid "index_state.repo" member, 2023-01-17) 3. 7211b9e7534 (repo-settings: consolidate some config settings, 2019-08-13) 4. <Y/hbUsGPVNAxTdmS@coredump.intra.peff.net> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 28, 2023 at 15:58 UTC 4a93b899c19794c28b140bf78a13fb9c2b34f433
17 files changed +76 -82
add-interactive.c
+1 -1
@@ -551,7 +551,7 @@ static int get_modified_files(struct repository *r,
551 opt.def = is_initial ?
552 empty_tree_oid_hex() : oid_to_hex(&head_oid);
553
554 - repo_init_revisions(the_repository, &rev, NULL);
554 + repo_init_revisions(r, &rev, NULL);
555 setup_revisions(0, NULL, &rev, &opt);
556
557 rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
branch.c
+4 -4
@@ -531,7 +531,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
531 explicit_tracking = 1;
532
533 real_ref = NULL;
534 - if (repo_get_oid_mb(the_repository, start_name, &oid)) {
534 + if (repo_get_oid_mb(r, start_name, &oid)) {
535 if (explicit_tracking) {
536 int code = die_message(_(upstream_missing), start_name);
537 advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
@@ -541,8 +541,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
541 die(_("not a valid object name: '%s'"), start_name);
542 }
543
544 - switch (repo_dwim_ref(the_repository, start_name, strlen(start_name),
545 - &oid, &real_ref, 0)) {
544 + switch (repo_dwim_ref(r, start_name, strlen(start_name), &oid,
545 + &real_ref, 0)) {
546 case 0:
547 /* Not branching from any existing branch */
548 if (explicit_tracking)
@@ -773,7 +773,7 @@ void create_branches_recursively(struct repository *r, const char *name,
773 name);
774 }
775
776 - create_branch(the_repository, name, start_commitish, force, 0, reflog, quiet,
776 + create_branch(r, name, start_commitish, force, 0, reflog, quiet,
777 BRANCH_TRACK_NEVER, dry_run);
778 if (dry_run)
779 return;
builtin/replace.c
+1 -1
@@ -54,7 +54,7 @@ static int show_reference(struct repository *r, const char *refname,
54 struct object_id object;
55 enum object_type obj_type, repl_type;
56
57 - if (repo_get_oid(the_repository, refname, &object))
57 + if (repo_get_oid(r, refname, &object))
58 return error(_("failed to resolve '%s' as a valid ref"), refname);
59
60 obj_type = oid_object_info(r, &object, NULL);
cache-tree.c
+2 -2
@@ -814,14 +814,14 @@ void prime_cache_tree(struct repository *r,
814 {
815 struct strbuf tree_path = STRBUF_INIT;
816
817 - trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
817 + trace2_region_enter("cache-tree", "prime_cache_tree", r);
818 cache_tree_free(&istate->cache_tree);
819 istate->cache_tree = cache_tree();
820
821 prime_cache_tree_rec(r, istate->cache_tree, tree, &tree_path);
822 strbuf_release(&tree_path);
823 istate->cache_changed |= CACHE_TREE_CHANGED;
824 - trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
824 + trace2_region_leave("cache-tree", "prime_cache_tree", r);
825 }
826
827 /*
combine-diff.c
+1 -1
@@ -332,7 +332,7 @@ static char *grab_blob(struct repository *r,
332 *size = fill_textconv(r, textconv, df, &blob);
333 free_filespec(df);
334 } else {
335 - blob = repo_read_object_file(the_repository, oid, &type, size);
335 + blob = repo_read_object_file(r, oid, &type, size);
336 if (type != OBJ_BLOB)
337 die("object '%s' is not a blob!", oid_to_hex(oid));
338 }
commit-graph.c
+1 -1
@@ -2549,7 +2549,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2549
2550 graph_commit = lookup_commit(r, &cur_oid);
2551 odb_commit = (struct commit *)create_object(r, &cur_oid, alloc_commit_node(r));
2552 - if (repo_parse_commit_internal(the_repository, odb_commit, 0, 0)) {
2552 + if (repo_parse_commit_internal(r, odb_commit, 0, 0)) {
2553 graph_report(_("failed to parse commit %s from object database for commit-graph"),
2554 oid_to_hex(&cur_oid));
2555 continue;
commit-reach.c
+1 -1
@@ -448,7 +448,7 @@ int repo_is_descendant_of(struct repository *r,
448 if (!with_commit)
449 return 1;
450
451 - if (generation_numbers_enabled(the_repository)) {
451 + if (generation_numbers_enabled(r)) {
452 struct commit_list *from_list = NULL;
453 int result;
454 commit_list_insert(commit, &from_list);
merge-recursive.c
+1 -1
@@ -3798,7 +3798,7 @@ static struct commit *get_ref(struct repository *repo,
3798 return make_virtual_commit(repo, (struct tree*)object, name);
3799 if (object->type != OBJ_COMMIT)
3800 return NULL;
3801 - if (repo_parse_commit(the_repository, (struct commit *)object))
3801 + if (repo_parse_commit(repo, (struct commit *)object))
3802 return NULL;
3803 return (struct commit *)object;
3804 }
notes-cache.c
+1 -1
@@ -23,7 +23,7 @@ static int notes_cache_match_validity(struct repository *r,
23 return 0;
24
25 memset(&pretty_ctx, 0, sizeof(pretty_ctx));
26 - repo_format_commit_message(the_repository, commit, "%s", &msg,
26 + repo_format_commit_message(r, commit, "%s", &msg,
27 &pretty_ctx);
28 strbuf_trim(&msg);
29
notes-utils.c
+1 -1
@@ -23,7 +23,7 @@ void create_notes_commit(struct repository *r,
23 struct object_id parent_oid;
24 if (!read_ref(t->ref, &parent_oid)) {
25 struct commit *parent = lookup_commit(r, &parent_oid);
26 - if (repo_parse_commit(the_repository, parent))
26 + if (repo_parse_commit(r, parent))
27 die("Failed to find/parse commit %s", t->ref);
28 commit_list_insert(parent, &parents);
29 }
object-name.c
+4 -4
@@ -1038,7 +1038,7 @@ static enum get_oid_result get_parent(struct repository *r,
1038 if (ret)
1039 return ret;
1040 commit = lookup_commit_reference(r, &oid);
1041 - if (repo_parse_commit(the_repository, commit))
1041 + if (repo_parse_commit(r, commit))
1042 return MISSING_OBJECT;
1043 if (!idx) {
1044 oidcpy(result, &commit->object.oid);
@@ -1072,7 +1072,7 @@ static enum get_oid_result get_nth_ancestor(struct repository *r,
1072 return MISSING_OBJECT;
1073
1074 while (generation--) {
1075 - if (repo_parse_commit(the_repository, commit) || !commit->parents)
1075 + if (repo_parse_commit(r, commit) || !commit->parents)
1076 return MISSING_OBJECT;
1077 commit = commit->parents->item;
1078 }
@@ -1363,10 +1363,10 @@ static int get_oid_oneline(struct repository *r,
1363 commit = pop_most_recent_commit(&list, ONELINE_SEEN);
1364 if (!parse_object(r, &commit->object.oid))
1365 continue;
1366 - buf = repo_get_commit_buffer(the_repository, commit, NULL);
1366 + buf = repo_get_commit_buffer(r, commit, NULL);
1367 p = strstr(buf, "\n\n");
1368 matches = negative ^ (p && !regexec(&regex, p + 2, 0, NULL, 0));
1369 - repo_unuse_commit_buffer(the_repository, commit, buf);
1369 + repo_unuse_commit_buffer(r, commit, buf);
1370
1371 if (matches) {
1372 oidcpy(oid, &commit->object.oid);
read-cache.c
+2 -2
@@ -2628,7 +2628,7 @@ int repo_index_has_changes(struct repository *repo,
2628
2629 if (tree)
2630 cmp = tree->object.oid;
2631 - if (tree || !repo_get_oid_tree(the_repository, "HEAD", &cmp)) {
2631 + if (tree || !repo_get_oid_tree(repo, "HEAD", &cmp)) {
2632 struct diff_options opt;
2633
2634 repo_diff_setup(repo, &opt);
@@ -2947,7 +2947,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
2947 }
2948
2949 if (!istate->version)
2950 - istate->version = get_index_format_default(the_repository);
2950 + istate->version = get_index_format_default(r);
2951
2952 /* demote version 3 to version 2 when the latter suffices */
2953 if (istate->version == 3 || istate->version == 2)
reset.c
+1 -1
@@ -106,7 +106,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
106 goto leave_reset_head;
107 }
108
109 - if (!repo_get_oid(the_repository, "HEAD", &head_oid)) {
109 + if (!repo_get_oid(r, "HEAD", &head_oid)) {
110 head = &head_oid;
111 } else if (!oid || !reset_hard) {
112 ret = error(_("could not determine HEAD revision"));
sequencer.c
+48 -54
@@ -694,8 +694,8 @@ static int do_recursive_merge(struct repository *r,
694 o.show_rename_progress = 1;
695
696 head_tree = parse_tree_indirect(head);
697 - next_tree = next ? repo_get_commit_tree(the_repository, next) : empty_tree(r);
698 - base_tree = base ? repo_get_commit_tree(the_repository, base) : empty_tree(r);
697 + next_tree = next ? repo_get_commit_tree(r, next) : empty_tree(r);
698 + base_tree = base ? repo_get_commit_tree(r, base) : empty_tree(r);
699
700 for (i = 0; i < opts->xopts_nr; i++)
701 parse_merge_opt(&o, opts->xopts[i]);
@@ -773,7 +773,7 @@ static int is_index_unchanged(struct repository *r)
773 * the commit is invalid, repo_parse_commit() will complain. So
774 * there is nothing for us to say here. Just return failure.
775 */
776 - if (repo_parse_commit(the_repository, head_commit))
776 + if (repo_parse_commit(r, head_commit))
777 return -1;
778
779 if (!(cache_tree_oid = get_cache_tree_oid(istate)))
@@ -1338,15 +1338,15 @@ void print_commit_summary(struct repository *r,
1338 commit = lookup_commit(r, oid);
1339 if (!commit)
1340 die(_("couldn't look up newly created commit"));
1341 - if (repo_parse_commit(the_repository, commit))
1341 + if (repo_parse_commit(r, commit))
1342 die(_("could not parse newly created commit"));
1343
1344 strbuf_addstr(&format, "format:%h] %s");
1345
1346 - repo_format_commit_message(the_repository, commit, "%an <%ae>",
1347 - &author_ident, &pctx);
1348 - repo_format_commit_message(the_repository, commit, "%cn <%ce>",
1349 - &committer_ident, &pctx);
1346 + repo_format_commit_message(r, commit, "%an <%ae>", &author_ident,
1347 + &pctx);
1348 + repo_format_commit_message(r, commit, "%cn <%ce>", &committer_ident,
1349 + &pctx);
1350 if (strbuf_cmp(&author_ident, &committer_ident)) {
1351 strbuf_addstr(&format, "\n Author: ");
1352 strbuf_addbuf_percentquote(&format, &author_ident);
@@ -1354,8 +1354,7 @@ void print_commit_summary(struct repository *r,
1354 if (flags & SUMMARY_SHOW_AUTHOR_DATE) {
1355 struct strbuf date = STRBUF_INIT;
1356
1357 - repo_format_commit_message(the_repository, commit, "%ad",
1358 - &date, &pctx);
1357 + repo_format_commit_message(r, commit, "%ad", &date, &pctx);
1358 strbuf_addstr(&format, "\n Date: ");
1359 strbuf_addbuf_percentquote(&format, &date);
1360 strbuf_release(&date);
@@ -1385,7 +1384,7 @@ void print_commit_summary(struct repository *r,
1384 rev.diffopt.detect_rename = DIFF_DETECT_RENAME;
1385 diff_setup_done(&rev.diffopt);
1386
1388 - refs = get_main_ref_store(the_repository);
1387 + refs = get_main_ref_store(r);
1388 head = refs_resolve_ref_unsafe(refs, "HEAD", 0, NULL, NULL);
1389 if (!head)
1390 die(_("unable to resolve HEAD after creating commit"));
@@ -1411,7 +1410,7 @@ static int parse_head(struct repository *r, struct commit **head)
1410 struct commit *current_head;
1411 struct object_id oid;
1412
1414 - if (repo_get_oid(the_repository, "HEAD", &oid)) {
1413 + if (repo_get_oid(r, "HEAD", &oid)) {
1414 current_head = NULL;
1415 } else {
1416 current_head = lookup_commit_reference(r, &oid);
@@ -1421,7 +1420,7 @@ static int parse_head(struct repository *r, struct commit **head)
1420 warning(_("HEAD %s is not a commit!"),
1421 oid_to_hex(&oid));
1422 }
1424 - if (repo_parse_commit(the_repository, current_head))
1423 + if (repo_parse_commit(r, current_head))
1424 return error(_("could not parse HEAD commit"));
1425 }
1426 *head = current_head;
@@ -1464,9 +1463,8 @@ static int try_to_commit(struct repository *r,
1463 if (flags & AMEND_MSG) {
1464 const char *exclude_gpgsig[] = { "gpgsig", "gpgsig-sha256", NULL };
1465 const char *out_enc = get_commit_output_encoding();
1467 - const char *message = repo_logmsg_reencode(the_repository,
1468 - current_head, NULL,
1469 - out_enc);
1466 + const char *message = repo_logmsg_reencode(r, current_head,
1467 + NULL, out_enc);
1468
1469 if (!msg) {
1470 const char *orig_message = NULL;
@@ -1477,7 +1475,7 @@ static int try_to_commit(struct repository *r,
1475 hook_commit = "HEAD";
1476 }
1477 author = amend_author = get_author(message);
1480 - repo_unuse_commit_buffer(the_repository, current_head,
1478 + repo_unuse_commit_buffer(r, current_head,
1479 message);
1480 if (!author) {
1481 res = error(_("unable to parse commit author"));
@@ -2004,18 +2002,18 @@ static int update_squash_messages(struct repository *r,
2002 struct commit *head_commit;
2003 const char *head_message, *body;
2004
2007 - if (repo_get_oid(the_repository, "HEAD", &head))
2005 + if (repo_get_oid(r, "HEAD", &head))
2006 return error(_("need a HEAD to fixup"));
2007 if (!(head_commit = lookup_commit_reference(r, &head)))
2008 return error(_("could not read HEAD"));
2011 - if (!(head_message = repo_logmsg_reencode(the_repository, head_commit, NULL, encoding)))
2009 + if (!(head_message = repo_logmsg_reencode(r, head_commit, NULL,
2010 + encoding)))
2011 return error(_("could not read HEAD's commit message"));
2012
2013 find_commit_subject(head_message, &body);
2014 if (command == TODO_FIXUP && !flag && write_message(body, strlen(body),
2015 rebase_path_fixup_msg(), 0) < 0) {
2017 - repo_unuse_commit_buffer(the_repository, head_commit,
2018 - head_message);
2016 + repo_unuse_commit_buffer(r, head_commit, head_message);
2017 return error(_("cannot write '%s'"), rebase_path_fixup_msg());
2018 }
2019 strbuf_addf(&buf, "%c ", comment_line_char);
@@ -2030,11 +2028,10 @@ static int update_squash_messages(struct repository *r,
2028 else
2029 strbuf_addstr(&buf, body);
2030
2033 - repo_unuse_commit_buffer(the_repository, head_commit,
2034 - head_message);
2031 + repo_unuse_commit_buffer(r, head_commit, head_message);
2032 }
2033
2037 - if (!(message = repo_logmsg_reencode(the_repository, commit, NULL, encoding)))
2034 + if (!(message = repo_logmsg_reencode(r, commit, NULL, encoding)))
2035 return error(_("could not read commit message of %s"),
2036 oid_to_hex(&commit->object.oid));
2037 find_commit_subject(message, &body);
@@ -2049,7 +2046,7 @@ static int update_squash_messages(struct repository *r,
2046 strbuf_add_commented_lines(&buf, body, strlen(body));
2047 } else
2048 return error(_("unknown command: %d"), command);
2052 - repo_unuse_commit_buffer(the_repository, commit, message);
2049 + repo_unuse_commit_buffer(r, commit, message);
2050
2051 if (!res)
2052 res = write_message(buf.buf, buf.len, rebase_path_squash_msg(),
@@ -2162,7 +2159,7 @@ static int do_pick_commit(struct repository *r,
2159 if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))
2160 return error(_("your index file is unmerged."));
2161 } else {
2165 - unborn = repo_get_oid(the_repository, "HEAD", &head);
2162 + unborn = repo_get_oid(r, "HEAD", &head);
2163 /* Do we want to generate a root commit? */
2164 if (is_pick_or_similar(command) && opts->have_squash_onto &&
2165 oideq(&head, &opts->squash_onto)) {
@@ -2224,7 +2221,7 @@ static int do_pick_commit(struct repository *r,
2221 msg_file = NULL;
2222 goto fast_forward_edit;
2223 }
2227 - if (parent && repo_parse_commit(the_repository, parent) < 0)
2224 + if (parent && repo_parse_commit(r, parent) < 0)
2225 /* TRANSLATORS: The first %s will be a "todo" command like
2226 "revert" or "pick", the second %s a SHA1. */
2227 return error(_("%s: cannot parse parent commit %s"),
@@ -2616,7 +2613,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
2613 end_of_object_name = (char *) bol + strcspn(bol, " \t\n");
2614 saved = *end_of_object_name;
2615 *end_of_object_name = '\0';
2619 - status = repo_get_oid(the_repository, bol, &commit_oid);
2616 + status = repo_get_oid(r, bol, &commit_oid);
2617 if (status < 0)
2618 error(_("could not parse '%s'"), bol); /* return later */
2619 *end_of_object_name = saved;
@@ -3531,12 +3528,12 @@ static int make_patch(struct repository *r,
3528 strbuf_addf(&buf, "%s/message", get_dir(opts));
3529 if (!file_exists(buf.buf)) {
3530 const char *encoding = get_commit_output_encoding();
3534 - const char *commit_buffer = repo_logmsg_reencode(the_repository,
3531 + const char *commit_buffer = repo_logmsg_reencode(r,
3532 commit, NULL,
3533 encoding);
3534 find_commit_subject(commit_buffer, &subject);
3535 res |= write_message(subject, strlen(subject), buf.buf, 1);
3539 - repo_unuse_commit_buffer(the_repository, commit,
3536 + repo_unuse_commit_buffer(r, commit,
3537 commit_buffer);
3538 }
3539 strbuf_release(&buf);
@@ -3716,7 +3713,7 @@ static int do_label(struct repository *r, const char *name, int len)
3713 if (!transaction) {
3714 error("%s", err.buf);
3715 ret = -1;
3719 - } else if (repo_get_oid(the_repository, "HEAD", &head_oid)) {
3716 + } else if (repo_get_oid(r, "HEAD", &head_oid)) {
3717 error(_("could not read HEAD"));
3718 ret = -1;
3719 } else if (ref_transaction_update(transaction, ref_name.buf, &head_oid,
@@ -4004,8 +4001,7 @@ static int do_merge(struct repository *r,
4001
4002 if (commit) {
4003 const char *encoding = get_commit_output_encoding();
4007 - const char *message = repo_logmsg_reencode(the_repository,
4008 - commit, NULL,
4004 + const char *message = repo_logmsg_reencode(r, commit, NULL,
4005 encoding);
4006 const char *body;
4007 int len;
@@ -4019,7 +4015,7 @@ static int do_merge(struct repository *r,
4015 find_commit_subject(message, &body);
4016 len = strlen(body);
4017 ret = write_message(body, len, git_path_merge_msg(r), 0);
4022 - repo_unuse_commit_buffer(the_repository, commit, message);
4018 + repo_unuse_commit_buffer(r, commit, message);
4019 if (ret) {
4020 error_errno(_("could not write '%s'"),
4021 git_path_merge_msg(r));
@@ -4119,8 +4115,7 @@ static int do_merge(struct repository *r,
4115 }
4116
4117 merge_commit = to_merge->item;
4122 - bases = repo_get_merge_bases(the_repository, head_commit,
4123 - merge_commit);
4118 + bases = repo_get_merge_bases(r, head_commit, merge_commit);
4119 if (bases && oideq(&merge_commit->object.oid,
4120 &bases->item->object.oid)) {
4121 ret = 0;
@@ -4475,7 +4470,7 @@ void create_autostash(struct repository *r, const char *path)
4470 if (capture_command(&stash, &buf, GIT_MAX_HEXSZ))
4471 die(_("Cannot autostash"));
4472 strbuf_trim_trailing_newline(&buf);
4478 - if (repo_get_oid(the_repository, buf.buf, &oid))
4473 + if (repo_get_oid(r, buf.buf, &oid))
4474 die(_("Unexpected stash response: '%s'"),
4475 buf.buf);
4476 strbuf_reset(&buf);
@@ -4600,9 +4595,9 @@ static int stopped_at_head(struct repository *r)
4595 struct commit *commit;
4596 struct commit_message message;
4597
4603 - if (repo_get_oid(the_repository, "HEAD", &head) ||
4598 + if (repo_get_oid(r, "HEAD", &head) ||
4599 !(commit = lookup_commit(r, &head)) ||
4605 - repo_parse_commit(the_repository, commit) || get_message(commit, &message))
4600 + repo_parse_commit(r, commit) || get_message(commit, &message))
4601 fprintf(stderr, _("Stopped at HEAD\n"));
4602 else {
4603 fprintf(stderr, _("Stopped at %s\n"), message.label);
@@ -4750,7 +4745,7 @@ static int pick_commits(struct repository *r,
4745 * otherwise we do not.
4746 */
4747 if (item->command == TODO_REWORD &&
4753 - !repo_get_oid(the_repository, "HEAD", &oid) &&
4748 + !repo_get_oid(r, "HEAD", &oid) &&
4749 (oideq(&item->commit->object.oid, &oid) ||
4750 (opts->have_squash_onto &&
4751 oideq(&opts->squash_onto, &oid))))
@@ -4839,7 +4834,7 @@ static int pick_commits(struct repository *r,
4834 struct object_id head, orig;
4835 int res;
4836
4842 - if (repo_get_oid(the_repository, "HEAD", &head)) {
4837 + if (repo_get_oid(r, "HEAD", &head)) {
4838 res = error(_("cannot read HEAD"));
4839 cleanup_head_ref:
4840 strbuf_release(&head_ref);
@@ -4886,8 +4881,8 @@ cleanup_head_ref:
4881 log_tree_opt.disable_stdin = 1;
4882
4883 if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
4889 - !repo_get_oid(the_repository, buf.buf, &orig) &&
4890 - !repo_get_oid(the_repository, "HEAD", &head)) {
4884 + !repo_get_oid(r, buf.buf, &orig) &&
4885 + !repo_get_oid(r, "HEAD", &head)) {
4886 diff_tree_oid(&orig, &head, "",
4887 &log_tree_opt.diffopt);
4888 log_tree_diff_flush(&log_tree_opt);
@@ -4979,7 +4974,7 @@ static int commit_staged_changes(struct repository *r,
4974 struct strbuf rev = STRBUF_INIT;
4975 struct object_id head, to_amend;
4976
4982 - if (repo_get_oid(the_repository, "HEAD", &head))
4977 + if (repo_get_oid(r, "HEAD", &head))
4978 return error(_("cannot amend non-existing commit"));
4979 if (!read_oneliner(&rev, rebase_path_amend(), 0))
4980 return error(_("invalid file: '%s'"), rebase_path_amend());
@@ -5059,14 +5054,13 @@ static int commit_staged_changes(struct repository *r,
5054 const char *encoding = get_commit_output_encoding();
5055
5056 if (parse_head(r, &commit) ||
5062 - !(p = repo_logmsg_reencode(the_repository, commit, NULL, encoding)) ||
5057 + !(p = repo_logmsg_reencode(r, commit, NULL, encoding)) ||
5058 write_message(p, strlen(p), path, 0)) {
5064 - repo_unuse_commit_buffer(the_repository,
5065 - commit, p);
5059 + repo_unuse_commit_buffer(r, commit, p);
5060 return error(_("could not write file: "
5061 "'%s'"), path);
5062 }
5069 - repo_unuse_commit_buffer(the_repository,
5063 + repo_unuse_commit_buffer(r,
5064 commit, p);
5065 }
5066 }
@@ -5206,7 +5200,7 @@ int sequencer_pick_revisions(struct repository *r,
5200 if (!strlen(name))
5201 continue;
5202
5209 - if (!repo_get_oid(the_repository, name, &oid)) {
5203 + if (!repo_get_oid(r, name, &oid)) {
5204 if (!lookup_commit_reference_gently(r, &oid, 1)) {
5205 enum object_type type = oid_object_info(r,
5206 &oid,
@@ -5249,7 +5243,7 @@ int sequencer_pick_revisions(struct repository *r,
5243 if (walk_revs_populate_todo(&todo_list, opts) ||
5244 create_seq_dir(r) < 0)
5245 return -1;
5252 - if (repo_get_oid(the_repository, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
5246 + if (repo_get_oid(r, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
5247 return error(_("can't revert as initial commit"));
5248 if (save_head(oid_to_hex(&oid)))
5249 return -1;
@@ -5944,7 +5938,7 @@ static int skip_unnecessary_picks(struct repository *r,
5938 continue;
5939 if (item->command != TODO_PICK)
5940 break;
5947 - if (repo_parse_commit(the_repository, item->commit)) {
5941 + if (repo_parse_commit(r, item->commit)) {
5942 return error(_("could not parse commit '%s'"),
5943 oid_to_hex(&item->commit->object.oid));
5944 }
@@ -6115,7 +6109,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
6109 struct object_id oid = onto->object.oid;
6110 int res;
6111
6118 - repo_find_unique_abbrev_r(the_repository, shortonto, &oid,
6112 + repo_find_unique_abbrev_r(r, shortonto, &oid,
6113 DEFAULT_ABBREV);
6114
6115 if (buf->len == 0) {
@@ -6395,8 +6389,8 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
6389 if (file_exists(git_path_seq_dir()))
6390 *whence = FROM_CHERRY_PICK_MULTI;
6391 if (file_exists(rebase_path()) &&
6398 - !repo_get_oid(the_repository, "REBASE_HEAD", &rebase_head) &&
6399 - !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
6392 + !repo_get_oid(r, "REBASE_HEAD", &rebase_head) &&
6393 + !repo_get_oid(r, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
6394 oideq(&rebase_head, &cherry_pick_head))
6395 *whence = FROM_REBASE_PICK;
6396 else
shallow.c
+1 -1
@@ -30,7 +30,7 @@ int register_shallow(struct repository *r, const struct object_id *oid)
30 {
31 struct commit_graft *graft =
32 xmalloc(sizeof(struct commit_graft));
33 - struct commit *commit = lookup_commit(the_repository, oid);
33 + struct commit *commit = lookup_commit(r, oid);
34
35 oidcpy(&graft->oid, oid);
36 graft->nr_parent = -1;
tree.c
+1 -1
@@ -58,7 +58,7 @@ int read_tree_at(struct repository *r,
58 oid_to_hex(&entry.oid),
59 base->buf, entry.path);
60
61 - if (repo_parse_commit(the_repository, commit))
61 + if (repo_parse_commit(r, commit))
62 die("Invalid commit %s in submodule path %s%s",
63 oid_to_hex(&entry.oid),
64 base->buf, entry.path);
wt-status.c
+5 -5
@@ -1664,7 +1664,7 @@ static void wt_status_get_detached_from(struct repository *r,
1664 return;
1665 }
1666
1667 - if (repo_dwim_ref(the_repository, cb.buf.buf, cb.buf.len, &oid, &ref,
1667 + if (repo_dwim_ref(r, cb.buf.buf, cb.buf.len, &oid, &ref,
1668 1) == 1 &&
1669 /* oid is a commit? match without further lookup */
1670 (oideq(&cb.noid, &oid) ||
@@ -1677,9 +1677,9 @@ static void wt_status_get_detached_from(struct repository *r,
1677 state->detached_from = xstrdup(from);
1678 } else
1679 state->detached_from =
1680 - xstrdup(repo_find_unique_abbrev(the_repository, &cb.noid, DEFAULT_ABBREV));
1680 + xstrdup(repo_find_unique_abbrev(r, &cb.noid, DEFAULT_ABBREV));
1681 oidcpy(&state->detached_oid, &cb.noid);
1682 - state->detached_at = !repo_get_oid(the_repository, "HEAD", &oid) &&
1682 + state->detached_at = !repo_get_oid(r, "HEAD", &oid) &&
1683 oideq(&oid, &state->detached_oid);
1684
1685 free(ref);
@@ -1770,13 +1770,13 @@ void wt_status_get_state(struct repository *r,
1770 } else if (wt_status_check_rebase(NULL, state)) {
1771 ; /* all set */
1772 } else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
1773 - !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &oid)) {
1773 + !repo_get_oid(r, "CHERRY_PICK_HEAD", &oid)) {
1774 state->cherry_pick_in_progress = 1;
1775 oidcpy(&state->cherry_pick_head_oid, &oid);
1776 }
1777 wt_status_check_bisect(NULL, state);
1778 if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") &&
1779 - !repo_get_oid(the_repository, "REVERT_HEAD", &oid)) {
1779 + !repo_get_oid(r, "REVERT_HEAD", &oid)) {
1780 state->revert_in_progress = 1;
1781 oidcpy(&state->revert_head_oid, &oid);
1782 }