Skip to content

Commit c9e9723

Browse files
pks-tgitster
authored andcommitted
refs/files: use correct repository
There are several places in the "files" backend where we use `the_repository` instead of the repository associated with the ref store itself. Adapt those to use the correct repository. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2bb444b commit c9e9723

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

refs/files-backend.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,8 @@ static void prune_refs(struct files_ref_store *refs, struct ref_to_prune **refs_
12371237
/*
12381238
* Return true if the specified reference should be packed.
12391239
*/
1240-
static int should_pack_ref(const char *refname,
1240+
static int should_pack_ref(struct files_ref_store *refs,
1241+
const char *refname,
12411242
const struct object_id *oid, unsigned int ref_flags,
12421243
struct pack_refs_opts *opts)
12431244
{
@@ -1253,7 +1254,7 @@ static int should_pack_ref(const char *refname,
12531254
return 0;
12541255

12551256
/* Do not pack broken refs: */
1256-
if (!ref_resolves_to_object(refname, the_repository, oid, ref_flags))
1257+
if (!ref_resolves_to_object(refname, refs->base.repo, oid, ref_flags))
12571258
return 0;
12581259

12591260
if (ref_excluded(opts->exclusions, refname))
@@ -1285,14 +1286,14 @@ static int files_pack_refs(struct ref_store *ref_store,
12851286
packed_refs_lock(refs->packed_ref_store, LOCK_DIE_ON_ERROR, &err);
12861287

12871288
iter = cache_ref_iterator_begin(get_loose_ref_cache(refs, 0), NULL,
1288-
the_repository, 0);
1289+
refs->base.repo, 0);
12891290
while ((ok = ref_iterator_advance(iter)) == ITER_OK) {
12901291
/*
12911292
* If the loose reference can be packed, add an entry
12921293
* in the packed ref cache. If the reference should be
12931294
* pruned, also add it to refs_to_prune.
12941295
*/
1295-
if (!should_pack_ref(iter->refname, iter->oid, iter->flags, opts))
1296+
if (!should_pack_ref(refs, iter->refname, iter->oid, iter->flags, opts))
12961297
continue;
12971298

12981299
/*
@@ -1389,7 +1390,8 @@ static int rename_tmp_log(struct files_ref_store *refs, const char *newrefname)
13891390
return ret;
13901391
}
13911392

1392-
static int write_ref_to_lockfile(struct ref_lock *lock,
1393+
static int write_ref_to_lockfile(struct files_ref_store *refs,
1394+
struct ref_lock *lock,
13931395
const struct object_id *oid,
13941396
int skip_oid_verification, struct strbuf *err);
13951397
static int commit_ref_update(struct files_ref_store *refs,
@@ -1537,7 +1539,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
15371539
}
15381540
oidcpy(&lock->old_oid, &orig_oid);
15391541

1540-
if (write_ref_to_lockfile(lock, &orig_oid, 0, &err) ||
1542+
if (write_ref_to_lockfile(refs, lock, &orig_oid, 0, &err) ||
15411543
commit_ref_update(refs, lock, &orig_oid, logmsg, &err)) {
15421544
error("unable to write current sha1 into %s: %s", newrefname, err.buf);
15431545
strbuf_release(&err);
@@ -1557,7 +1559,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
15571559

15581560
flag = log_all_ref_updates;
15591561
log_all_ref_updates = LOG_REFS_NONE;
1560-
if (write_ref_to_lockfile(lock, &orig_oid, 0, &err) ||
1562+
if (write_ref_to_lockfile(refs, lock, &orig_oid, 0, &err) ||
15611563
commit_ref_update(refs, lock, &orig_oid, NULL, &err)) {
15621564
error("unable to write current sha1 into %s: %s", oldrefname, err.buf);
15631565
strbuf_release(&err);
@@ -1791,7 +1793,8 @@ static int files_log_ref_write(struct files_ref_store *refs,
17911793
* Write oid into the open lockfile, then close the lockfile. On
17921794
* errors, rollback the lockfile, fill in *err and return -1.
17931795
*/
1794-
static int write_ref_to_lockfile(struct ref_lock *lock,
1796+
static int write_ref_to_lockfile(struct files_ref_store *refs,
1797+
struct ref_lock *lock,
17951798
const struct object_id *oid,
17961799
int skip_oid_verification, struct strbuf *err)
17971800
{
@@ -1800,7 +1803,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
18001803
int fd;
18011804

18021805
if (!skip_oid_verification) {
1803-
o = parse_object(the_repository, oid);
1806+
o = parse_object(refs->base.repo, oid);
18041807
if (!o) {
18051808
strbuf_addf(
18061809
err,
@@ -2571,7 +2574,7 @@ static int lock_ref_for_update(struct files_ref_store *refs,
25712574
* value, so we don't need to write it.
25722575
*/
25732576
} else if (write_ref_to_lockfile(
2574-
lock, &update->new_oid,
2577+
refs, lock, &update->new_oid,
25752578
update->flags & REF_SKIP_OID_VERIFICATION,
25762579
err)) {
25772580
char *write_err = strbuf_detach(err, NULL);

0 commit comments

Comments
 (0)