reset: drop `USE_THE_REPOSITORY_VARIABLE`

In "reset.c" we still have references to `the_repository`, even though the only entry point into the file already receives a repository as parameter. Update all uses of `the_repository` to instead use the passed-in repo and drop `USE_THE_REPOSITORY_VARIABLE`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jul 1, 2026 at 13:35 UTC 5ce540bed335005046aad5969e1ae3bb1fc6cde5
1 file changed +13 -14
reset.c
+13 -14
@@ -1,5 +1,3 @@
1 -#define USE_THE_REPOSITORY_VARIABLE
2 -
1 #include "git-compat-util.h"
2 #include "cache-tree.h"
3 #include "gettext.h"
@@ -13,7 +11,8 @@
11 #include "unpack-trees.h"
12 #include "hook.h"
13
16 -static int update_refs(const struct reset_head_opts *opts,
14 +static int update_refs(struct repository *repo,
15 + const struct reset_head_opts *opts,
16 const struct object_id *oid,
17 const struct object_id *head)
18 {
@@ -42,19 +41,19 @@ static int update_refs(const struct reset_head_opts *opts,
41 prefix_len = msg.len;
42
43 if (update_orig_head) {
45 - if (!repo_get_oid(the_repository, "ORIG_HEAD", &oid_old_orig))
44 + if (!repo_get_oid(repo, "ORIG_HEAD", &oid_old_orig))
45 old_orig = &oid_old_orig;
46 if (head) {
47 if (!reflog_orig_head) {
48 strbuf_addstr(&msg, "updating ORIG_HEAD");
49 reflog_orig_head = msg.buf;
50 }
52 - refs_update_ref(get_main_ref_store(the_repository),
51 + refs_update_ref(get_main_ref_store(repo),
52 reflog_orig_head, "ORIG_HEAD",
53 orig_head ? orig_head : head,
54 old_orig, 0, UPDATE_REFS_MSG_ON_ERR);
55 } else if (old_orig)
57 - refs_delete_ref(get_main_ref_store(the_repository),
56 + refs_delete_ref(get_main_ref_store(repo),
57 NULL, "ORIG_HEAD", old_orig, 0);
58 }
59
@@ -64,23 +63,23 @@ static int update_refs(const struct reset_head_opts *opts,
63 reflog_head = msg.buf;
64 }
65 if (!switch_to_branch)
67 - ret = refs_update_ref(get_main_ref_store(the_repository),
66 + ret = refs_update_ref(get_main_ref_store(repo),
67 reflog_head, "HEAD", oid, head,
68 detach_head ? REF_NO_DEREF : 0,
69 UPDATE_REFS_MSG_ON_ERR);
70 else {
72 - ret = refs_update_ref(get_main_ref_store(the_repository),
71 + ret = refs_update_ref(get_main_ref_store(repo),
72 reflog_branch ? reflog_branch : reflog_head,
73 switch_to_branch, oid, NULL, 0,
74 UPDATE_REFS_MSG_ON_ERR);
75 if (!ret)
77 - ret = refs_update_symref(get_main_ref_store(the_repository),
76 + ret = refs_update_symref(get_main_ref_store(repo),
77 "HEAD", switch_to_branch,
78 reflog_head);
79 }
80 if (!ret && run_hook)
82 - run_hooks_l(the_repository, "post-checkout",
83 - oid_to_hex(head ? head : null_oid(the_hash_algo)),
81 + run_hooks_l(repo, "post-checkout",
82 + oid_to_hex(head ? head : null_oid(repo->hash_algo)),
83 oid_to_hex(oid), "1", NULL);
84 strbuf_release(&msg);
85 return ret;
@@ -126,7 +125,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
125 oid = &head_oid;
126
127 if (refs_only)
129 - return update_refs(opts, oid, head);
128 + return update_refs(r, opts, oid, head);
129
130 action = reset_hard ? "reset" : "checkout";
131 setup_unpack_trees_porcelain(&unpack_tree_opts, action);
@@ -163,7 +162,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
162 goto leave_reset_head;
163 }
164
166 - tree = repo_parse_tree_indirect(the_repository, oid);
165 + tree = repo_parse_tree_indirect(r, oid);
166 if (!tree) {
167 ret = error(_("unable to read tree (%s)"), oid_to_hex(oid));
168 goto leave_reset_head;
@@ -177,7 +176,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
176 }
177
178 if (oid != &head_oid || update_orig_head || switch_to_branch)
180 - ret = update_refs(opts, oid, head);
179 + ret = update_refs(r, opts, oid, head);
180
181 leave_reset_head:
182 rollback_lock_file(&lock);