Skip to content

Commit e7dca80

Browse files
committed
Merge branch 'ab/remove-implicit-use-of-the-repository' into en/header-split-cache-h
* ab/remove-implicit-use-of-the-repository: libs: use "struct repository *" argument, not "the_repository" post-cocci: adjust comments for recent repo_* migration cocci: apply the "revision.h" part of "the_repository.pending" cocci: apply the "rerere.h" part of "the_repository.pending" cocci: apply the "refs.h" part of "the_repository.pending" cocci: apply the "promisor-remote.h" part of "the_repository.pending" cocci: apply the "packfile.h" part of "the_repository.pending" cocci: apply the "pretty.h" part of "the_repository.pending" cocci: apply the "object-store.h" part of "the_repository.pending" cocci: apply the "diff.h" part of "the_repository.pending" cocci: apply the "commit.h" part of "the_repository.pending" cocci: apply the "commit-reach.h" part of "the_repository.pending" cocci: apply the "cache.h" part of "the_repository.pending" cocci: add missing "the_repository" macros to "pending" cocci: sort "the_repository" rules by header cocci: fix incorrect & verbose "the_repository" rules cocci: remove dead rule from "the_repository.pending.cocci"
2 parents ec2f026 + 4a93b89 commit e7dca80

File tree

148 files changed

+958
-873
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+958
-873
lines changed

add-interactive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ static int get_modified_files(struct repository *r,
553553
opt.def = is_initial ?
554554
empty_tree_oid_hex() : oid_to_hex(&head_oid);
555555

556-
init_revisions(&rev, NULL);
556+
repo_init_revisions(r, &rev, NULL);
557557
setup_revisions(0, NULL, &rev, &opt);
558558

559559
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;

add-patch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
417417
strvec_push(&args,
418418
/* could be on an unborn branch */
419419
!strcmp("HEAD", s->revision) &&
420-
get_oid("HEAD", &oid) ?
420+
repo_get_oid(the_repository, "HEAD", &oid) ?
421421
empty_tree_oid_hex() : s->revision);
422422
}
423423
color_arg_index = args.nr;

apply.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,7 +3208,8 @@ static int apply_binary(struct apply_state *state,
32083208
unsigned long size;
32093209
char *result;
32103210

3211-
result = read_object_file(&oid, &type, &size);
3211+
result = repo_read_object_file(the_repository, &oid, &type,
3212+
&size);
32123213
if (!result)
32133214
return error(_("the necessary postimage %s for "
32143215
"'%s' cannot be read"),
@@ -3271,7 +3272,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
32713272
unsigned long sz;
32723273
char *result;
32733274

3274-
result = read_object_file(oid, &type, &sz);
3275+
result = repo_read_object_file(the_repository, oid, &type,
3276+
&sz);
32753277
if (!result)
32763278
return -1;
32773279
/* XXX read_sha1_file NUL-terminates */
@@ -3499,7 +3501,8 @@ static int resolve_to(struct image *image, const struct object_id *result_id)
34993501

35003502
clear_image(image);
35013503

3502-
image->buf = read_object_file(result_id, &type, &size);
3504+
image->buf = repo_read_object_file(the_repository, result_id, &type,
3505+
&size);
35033506
if (!image->buf || type != OBJ_BLOB)
35043507
die("unable to read blob object %s", oid_to_hex(result_id));
35053508
image->len = size;
@@ -3617,7 +3620,7 @@ static int try_threeway(struct apply_state *state,
36173620
/* Preimage the patch was prepared for */
36183621
if (patch->is_new)
36193622
write_object_file("", 0, OBJ_BLOB, &pre_oid);
3620-
else if (get_oid(patch->old_oid_prefix, &pre_oid) ||
3623+
else if (repo_get_oid(the_repository, patch->old_oid_prefix, &pre_oid) ||
36213624
read_blob_object(&buf, &pre_oid, patch->old_mode))
36223625
return error(_("repository lacks the necessary blob to perform 3-way merge."));
36233626

@@ -4134,7 +4137,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
41344137
else
41354138
return error(_("sha1 information is lacking or "
41364139
"useless for submodule %s"), name);
4137-
} else if (!get_oid_blob(patch->old_oid_prefix, &oid)) {
4140+
} else if (!repo_get_oid_blob(the_repository, patch->old_oid_prefix, &oid)) {
41384141
; /* ok */
41394142
} else if (!patch->lines_added && !patch->lines_deleted) {
41404143
/* mode-only change: update the current */

archive.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ static void format_subst(const struct commit *commit,
6565
strbuf_add(&fmt, b + 8, c - b - 8);
6666

6767
strbuf_add(buf, src, b - src);
68-
format_commit_message(commit, fmt.buf, buf, ctx);
68+
repo_format_commit_message(the_repository, commit, fmt.buf,
69+
buf, ctx);
6970
len -= c + 1 - src;
7071
src = c + 1;
7172
}
@@ -90,7 +91,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
9091
(args->tree ? &args->tree->object.oid : NULL), oid);
9192

9293
path += args->baselen;
93-
buffer = read_object_file(oid, type, sizep);
94+
buffer = repo_read_object_file(the_repository, oid, type, sizep);
9495
if (buffer && S_ISREG(mode)) {
9596
struct strbuf buf = STRBUF_INIT;
9697
size_t size = 0;
@@ -461,13 +462,14 @@ static void parse_treeish_arg(const char **argv,
461462
const char *colon = strchrnul(name, ':');
462463
int refnamelen = colon - name;
463464

464-
if (!dwim_ref(name, refnamelen, &oid, &ref, 0))
465+
if (!repo_dwim_ref(the_repository, name, refnamelen, &oid, &ref, 0))
465466
die(_("no such ref: %.*s"), refnamelen, name);
466467
} else {
467-
dwim_ref(name, strlen(name), &oid, &ref, 0);
468+
repo_dwim_ref(the_repository, name, strlen(name), &oid, &ref,
469+
0);
468470
}
469471

470-
if (get_oid(name, &oid))
472+
if (repo_get_oid(the_repository, name, &oid))
471473
die(_("not a valid object name: %s"), name);
472474

473475
commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);

bisect.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ static void show_list(const char *debug, int counted, int nr,
151151
unsigned commit_flags = commit->object.flags;
152152
enum object_type type;
153153
unsigned long size;
154-
char *buf = read_object_file(&commit->object.oid, &type,
155-
&size);
154+
char *buf = repo_read_object_file(the_repository,
155+
&commit->object.oid, &type,
156+
&size);
156157
const char *subject_start;
157158
int subject_len;
158159

@@ -754,7 +755,8 @@ enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
754755
}
755756

756757
commit = lookup_commit_reference(the_repository, bisect_rev);
757-
format_commit_message(commit, "[%H] %s%n", &commit_msg, &pp);
758+
repo_format_commit_message(the_repository, commit, "[%H] %s%n",
759+
&commit_msg, &pp);
758760
fputs(commit_msg.buf, stdout);
759761
strbuf_release(&commit_msg);
760762

@@ -849,7 +851,8 @@ static enum bisect_error check_merge_bases(int rev_nr, struct commit **rev, int
849851
enum bisect_error res = BISECT_OK;
850852
struct commit_list *result;
851853

852-
result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
854+
result = repo_get_merge_bases_many(the_repository, rev[0], rev_nr - 1,
855+
rev + 1);
853856

854857
for (; result; result = result->next) {
855858
const struct object_id *mb = &result->item->object.oid;

blame.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,8 +1031,9 @@ static void fill_origin_blob(struct diff_options *opt,
10311031
&o->blob_oid, 1, &file->ptr, &file_size))
10321032
;
10331033
else
1034-
file->ptr = read_object_file(&o->blob_oid, &type,
1035-
&file_size);
1034+
file->ptr = repo_read_object_file(the_repository,
1035+
&o->blob_oid, &type,
1036+
&file_size);
10361037
file->size = file_size;
10371038

10381039
if (!file->ptr)
@@ -2432,7 +2433,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
24322433

24332434
if (sg_origin[i])
24342435
continue;
2435-
if (parse_commit(p))
2436+
if (repo_parse_commit(the_repository, p))
24362437
continue;
24372438
porigin = find(sb->repo, p, origin, sb->bloom_data);
24382439
if (!porigin)
@@ -2595,7 +2596,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)
25952596
* so hold onto it in the meantime.
25962597
*/
25972598
blame_origin_incref(suspect);
2598-
parse_commit(commit);
2599+
repo_parse_commit(the_repository, commit);
25992600
if (sb->reverse ||
26002601
(!(commit->object.flags & UNINTERESTING) &&
26012602
!(revs->max_age != -1 && commit->date < revs->max_age)))
@@ -2841,8 +2842,10 @@ void setup_scoreboard(struct blame_scoreboard *sb,
28412842
&sb->final_buf_size))
28422843
;
28432844
else
2844-
sb->final_buf = read_object_file(&o->blob_oid, &type,
2845-
&sb->final_buf_size);
2845+
sb->final_buf = repo_read_object_file(the_repository,
2846+
&o->blob_oid,
2847+
&type,
2848+
&sb->final_buf_size);
28462849

28472850
if (!sb->final_buf)
28482851
die(_("cannot read blob %s for path %s"),

branch.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
534534
explicit_tracking = 1;
535535

536536
real_ref = NULL;
537-
if (get_oid_mb(start_name, &oid)) {
537+
if (repo_get_oid_mb(r, start_name, &oid)) {
538538
if (explicit_tracking) {
539539
int code = die_message(_(upstream_missing), start_name);
540540
advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
@@ -544,7 +544,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
544544
die(_("not a valid object name: '%s'"), start_name);
545545
}
546546

547-
switch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref, 0)) {
547+
switch (repo_dwim_ref(r, start_name, strlen(start_name), &oid,
548+
&real_ref, 0)) {
548549
case 0:
549550
/* Not branching from any existing branch */
550551
if (explicit_tracking)
@@ -775,7 +776,7 @@ void create_branches_recursively(struct repository *r, const char *name,
775776
name);
776777
}
777778

778-
create_branch(the_repository, name, start_commitish, force, 0, reflog, quiet,
779+
create_branch(r, name, start_commitish, force, 0, reflog, quiet,
779780
BRANCH_TRACK_NEVER, dry_run);
780781
if (dry_run)
781782
return;

builtin/am.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
10711071
else
10721072
write_state_text(state, "applying", "");
10731073

1074-
if (!get_oid("HEAD", &curr_head)) {
1074+
if (!repo_get_oid(the_repository, "HEAD", &curr_head)) {
10751075
write_state_text(state, "abort-safety", oid_to_hex(&curr_head));
10761076
if (!state->rebasing)
10771077
update_ref("am", "ORIG_HEAD", &curr_head, NULL, 0,
@@ -1114,7 +1114,7 @@ static void am_next(struct am_state *state)
11141114
unlink(am_path(state, "original-commit"));
11151115
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
11161116

1117-
if (!get_oid("HEAD", &head))
1117+
if (!repo_get_oid(the_repository, "HEAD", &head))
11181118
write_state_text(state, "abort-safety", oid_to_hex(&head));
11191119
else
11201120
write_state_text(state, "abort-safety", "");
@@ -1334,7 +1334,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
13341334
size_t ident_len;
13351335
struct ident_split id;
13361336

1337-
buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());
1337+
buffer = repo_logmsg_reencode(the_repository, commit, NULL,
1338+
get_commit_output_encoding());
13381339

13391340
ident_line = find_commit_header(buffer, "author", &ident_len);
13401341
if (!ident_line)
@@ -1366,7 +1367,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
13661367
die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
13671368
state->msg = xstrdup(msg + 2);
13681369
state->msg_len = strlen(state->msg);
1369-
unuse_commit_buffer(commit, buffer);
1370+
repo_unuse_commit_buffer(the_repository, commit, buffer);
13701371
}
13711372

13721373
/**
@@ -1407,9 +1408,9 @@ static void write_index_patch(const struct am_state *state)
14071408
struct rev_info rev_info;
14081409
FILE *fp;
14091410

1410-
if (!get_oid("HEAD", &head)) {
1411+
if (!repo_get_oid(the_repository, "HEAD", &head)) {
14111412
struct commit *commit = lookup_commit_or_die(&head, "HEAD");
1412-
tree = get_commit_tree(commit);
1413+
tree = repo_get_commit_tree(the_repository, commit);
14131414
} else
14141415
tree = lookup_tree(the_repository,
14151416
the_repository->hash_algo->empty_tree);
@@ -1561,7 +1562,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
15611562
struct commit *result;
15621563
char *their_tree_name;
15631564

1564-
if (get_oid("HEAD", &our_tree) < 0)
1565+
if (repo_get_oid(the_repository, "HEAD", &our_tree) < 0)
15651566
oidcpy(&our_tree, the_hash_algo->empty_tree);
15661567

15671568
if (build_fake_ancestor(state, index_path))
@@ -1651,7 +1652,7 @@ static void do_commit(const struct am_state *state)
16511652
if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL))
16521653
die(_("git write-tree failed to write a tree"));
16531654

1654-
if (!get_oid_commit("HEAD", &parent)) {
1655+
if (!repo_get_oid_commit(the_repository, "HEAD", &parent)) {
16551656
old_oid = &parent;
16561657
commit_list_insert(lookup_commit(the_repository, &parent),
16571658
&parents);
@@ -2093,7 +2094,7 @@ static void am_skip(struct am_state *state)
20932094

20942095
am_rerere_clear();
20952096

2096-
if (get_oid("HEAD", &head))
2097+
if (repo_get_oid(the_repository, "HEAD", &head))
20972098
oidcpy(&head, the_hash_algo->empty_tree);
20982099

20992100
if (clean_index(&head, &head))
@@ -2135,7 +2136,7 @@ static int safe_to_abort(const struct am_state *state)
21352136
oidclr(&abort_safety);
21362137
strbuf_release(&sb);
21372138

2138-
if (get_oid("HEAD", &head))
2139+
if (repo_get_oid(the_repository, "HEAD", &head))
21392140
oidclr(&head);
21402141

21412142
if (oideq(&head, &abort_safety))
@@ -2168,7 +2169,7 @@ static void am_abort(struct am_state *state)
21682169
if (!has_curr_head)
21692170
oidcpy(&curr_head, the_hash_algo->empty_tree);
21702171

2171-
has_orig_head = !get_oid("ORIG_HEAD", &orig_head);
2172+
has_orig_head = !repo_get_oid(the_repository, "ORIG_HEAD", &orig_head);
21722173
if (!has_orig_head)
21732174
oidcpy(&orig_head, the_hash_algo->empty_tree);
21742175

0 commit comments

Comments
 (0)