Skip to content

Commit 868e255

Browse files
committed
Merge branch 'ab/remove-implicit-use-of-the-repository' into seen
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"
2 parents 6f1bf6b + 0586c0c commit 868e255

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
@@ -552,7 +552,7 @@ static int get_modified_files(struct repository *r,
552552
opt.def = is_initial ?
553553
empty_tree_oid_hex() : oid_to_hex(&head_oid);
554554

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

558558
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;

add-patch.c

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

apply.c

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

3206-
result = read_object_file(&oid, &type, &size);
3206+
result = repo_read_object_file(the_repository, &oid, &type,
3207+
&size);
32073208
if (!result)
32083209
return error(_("the necessary postimage %s for "
32093210
"'%s' cannot be read"),
@@ -3266,7 +3267,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
32663267
unsigned long sz;
32673268
char *result;
32683269

3269-
result = read_object_file(oid, &type, &sz);
3270+
result = repo_read_object_file(the_repository, oid, &type,
3271+
&sz);
32703272
if (!result)
32713273
return -1;
32723274
/* XXX read_sha1_file NUL-terminates */
@@ -3494,7 +3496,8 @@ static int resolve_to(struct image *image, const struct object_id *result_id)
34943496

34953497
clear_image(image);
34963498

3497-
image->buf = read_object_file(result_id, &type, &size);
3499+
image->buf = repo_read_object_file(the_repository, result_id, &type,
3500+
&size);
34983501
if (!image->buf || type != OBJ_BLOB)
34993502
die("unable to read blob object %s", oid_to_hex(result_id));
35003503
image->len = size;
@@ -3612,7 +3615,7 @@ static int try_threeway(struct apply_state *state,
36123615
/* Preimage the patch was prepared for */
36133616
if (patch->is_new)
36143617
write_object_file("", 0, OBJ_BLOB, &pre_oid);
3615-
else if (get_oid(patch->old_oid_prefix, &pre_oid) ||
3618+
else if (repo_get_oid(the_repository, patch->old_oid_prefix, &pre_oid) ||
36163619
read_blob_object(&buf, &pre_oid, patch->old_mode))
36173620
return error(_("repository lacks the necessary blob to perform 3-way merge."));
36183621

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

archive.c

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

6363
strbuf_add(buf, src, b - src);
64-
format_commit_message(commit, fmt.buf, buf, ctx);
64+
repo_format_commit_message(the_repository, commit, fmt.buf,
65+
buf, ctx);
6566
len -= c + 1 - src;
6667
src = c + 1;
6768
}
@@ -86,7 +87,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
8687
(args->tree ? &args->tree->object.oid : NULL), oid);
8788

8889
path += args->baselen;
89-
buffer = read_object_file(oid, type, sizep);
90+
buffer = repo_read_object_file(the_repository, oid, type, sizep);
9091
if (buffer && S_ISREG(mode)) {
9192
struct strbuf buf = STRBUF_INIT;
9293
size_t size = 0;
@@ -457,13 +458,14 @@ static void parse_treeish_arg(const char **argv,
457458
const char *colon = strchrnul(name, ':');
458459
int refnamelen = colon - name;
459460

460-
if (!dwim_ref(name, refnamelen, &oid, &ref, 0))
461+
if (!repo_dwim_ref(the_repository, name, refnamelen, &oid, &ref, 0))
461462
die(_("no such ref: %.*s"), refnamelen, name);
462463
} else {
463-
dwim_ref(name, strlen(name), &oid, &ref, 0);
464+
repo_dwim_ref(the_repository, name, strlen(name), &oid, &ref,
465+
0);
464466
}
465467

466-
if (get_oid(name, &oid))
468+
if (repo_get_oid(the_repository, name, &oid))
467469
die(_("not a valid object name: %s"), name);
468470

469471
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
@@ -149,8 +149,9 @@ static void show_list(const char *debug, int counted, int nr,
149149
unsigned commit_flags = commit->object.flags;
150150
enum object_type type;
151151
unsigned long size;
152-
char *buf = read_object_file(&commit->object.oid, &type,
153-
&size);
152+
char *buf = repo_read_object_file(the_repository,
153+
&commit->object.oid, &type,
154+
&size);
154155
const char *subject_start;
155156
int subject_len;
156157

@@ -752,7 +753,8 @@ enum bisect_error bisect_checkout(const struct object_id *bisect_rev,
752753
}
753754

754755
commit = lookup_commit_reference(the_repository, bisect_rev);
755-
format_commit_message(commit, "[%H] %s%n", &commit_msg, &pp);
756+
repo_format_commit_message(the_repository, commit, "[%H] %s%n",
757+
&commit_msg, &pp);
756758
fputs(commit_msg.buf, stdout);
757759
strbuf_release(&commit_msg);
758760

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

850-
result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
852+
result = repo_get_merge_bases_many(the_repository, rev[0], rev_nr - 1,
853+
rev + 1);
851854

852855
for (; result; result = result->next) {
853856
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
@@ -1029,8 +1029,9 @@ static void fill_origin_blob(struct diff_options *opt,
10291029
&o->blob_oid, 1, &file->ptr, &file_size))
10301030
;
10311031
else
1032-
file->ptr = read_object_file(&o->blob_oid, &type,
1033-
&file_size);
1032+
file->ptr = repo_read_object_file(the_repository,
1033+
&o->blob_oid, &type,
1034+
&file_size);
10341035
file->size = file_size;
10351036

10361037
if (!file->ptr)
@@ -2430,7 +2431,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
24302431

24312432
if (sg_origin[i])
24322433
continue;
2433-
if (parse_commit(p))
2434+
if (repo_parse_commit(the_repository, p))
24342435
continue;
24352436
porigin = find(sb->repo, p, origin, sb->bloom_data);
24362437
if (!porigin)
@@ -2593,7 +2594,7 @@ void assign_blame(struct blame_scoreboard *sb, int opt)
25932594
* so hold onto it in the meantime.
25942595
*/
25952596
blame_origin_incref(suspect);
2596-
parse_commit(commit);
2597+
repo_parse_commit(the_repository, commit);
25972598
if (sb->reverse ||
25982599
(!(commit->object.flags & UNINTERESTING) &&
25992600
!(revs->max_age != -1 && commit->date < revs->max_age)))
@@ -2839,8 +2840,10 @@ void setup_scoreboard(struct blame_scoreboard *sb,
28392840
&sb->final_buf_size))
28402841
;
28412842
else
2842-
sb->final_buf = read_object_file(&o->blob_oid, &type,
2843-
&sb->final_buf_size);
2843+
sb->final_buf = repo_read_object_file(the_repository,
2844+
&o->blob_oid,
2845+
&type,
2846+
&sb->final_buf_size);
28442847

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

branch.c

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

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

545-
switch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref, 0)) {
545+
switch (repo_dwim_ref(r, start_name, strlen(start_name), &oid,
546+
&real_ref, 0)) {
546547
case 0:
547548
/* Not branching from any existing branch */
548549
if (explicit_tracking)
@@ -773,7 +774,7 @@ void create_branches_recursively(struct repository *r, const char *name,
773774
name);
774775
}
775776

776-
create_branch(the_repository, name, start_commitish, force, 0, reflog, quiet,
777+
create_branch(r, name, start_commitish, force, 0, reflog, quiet,
777778
BRANCH_TRACK_NEVER, dry_run);
778779
if (dry_run)
779780
return;

builtin/am.c

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

1070-
if (!get_oid("HEAD", &curr_head)) {
1070+
if (!repo_get_oid(the_repository, "HEAD", &curr_head)) {
10711071
write_state_text(state, "abort-safety", oid_to_hex(&curr_head));
10721072
if (!state->rebasing)
10731073
update_ref("am", "ORIG_HEAD", &curr_head, NULL, 0,
@@ -1110,7 +1110,7 @@ static void am_next(struct am_state *state)
11101110
unlink(am_path(state, "original-commit"));
11111111
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
11121112

1113-
if (!get_oid("HEAD", &head))
1113+
if (!repo_get_oid(the_repository, "HEAD", &head))
11141114
write_state_text(state, "abort-safety", oid_to_hex(&head));
11151115
else
11161116
write_state_text(state, "abort-safety", "");
@@ -1330,7 +1330,8 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
13301330
size_t ident_len;
13311331
struct ident_split id;
13321332

1333-
buffer = logmsg_reencode(commit, NULL, get_commit_output_encoding());
1333+
buffer = repo_logmsg_reencode(the_repository, commit, NULL,
1334+
get_commit_output_encoding());
13341335

13351336
ident_line = find_commit_header(buffer, "author", &ident_len);
13361337
if (!ident_line)
@@ -1362,7 +1363,7 @@ static void get_commit_info(struct am_state *state, struct commit *commit)
13621363
die(_("unable to parse commit %s"), oid_to_hex(&commit->object.oid));
13631364
state->msg = xstrdup(msg + 2);
13641365
state->msg_len = strlen(state->msg);
1365-
unuse_commit_buffer(commit, buffer);
1366+
repo_unuse_commit_buffer(the_repository, commit, buffer);
13661367
}
13671368

13681369
/**
@@ -1403,9 +1404,9 @@ static void write_index_patch(const struct am_state *state)
14031404
struct rev_info rev_info;
14041405
FILE *fp;
14051406

1406-
if (!get_oid("HEAD", &head)) {
1407+
if (!repo_get_oid(the_repository, "HEAD", &head)) {
14071408
struct commit *commit = lookup_commit_or_die(&head, "HEAD");
1408-
tree = get_commit_tree(commit);
1409+
tree = repo_get_commit_tree(the_repository, commit);
14091410
} else
14101411
tree = lookup_tree(the_repository,
14111412
the_repository->hash_algo->empty_tree);
@@ -1557,7 +1558,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
15571558
struct commit *result;
15581559
char *their_tree_name;
15591560

1560-
if (get_oid("HEAD", &our_tree) < 0)
1561+
if (repo_get_oid(the_repository, "HEAD", &our_tree) < 0)
15611562
oidcpy(&our_tree, the_hash_algo->empty_tree);
15621563

15631564
if (build_fake_ancestor(state, index_path))
@@ -1647,7 +1648,7 @@ static void do_commit(const struct am_state *state)
16471648
if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL))
16481649
die(_("git write-tree failed to write a tree"));
16491650

1650-
if (!get_oid_commit("HEAD", &parent)) {
1651+
if (!repo_get_oid_commit(the_repository, "HEAD", &parent)) {
16511652
old_oid = &parent;
16521653
commit_list_insert(lookup_commit(the_repository, &parent),
16531654
&parents);
@@ -2089,7 +2090,7 @@ static void am_skip(struct am_state *state)
20892090

20902091
am_rerere_clear();
20912092

2092-
if (get_oid("HEAD", &head))
2093+
if (repo_get_oid(the_repository, "HEAD", &head))
20932094
oidcpy(&head, the_hash_algo->empty_tree);
20942095

20952096
if (clean_index(&head, &head))
@@ -2131,7 +2132,7 @@ static int safe_to_abort(const struct am_state *state)
21312132
oidclr(&abort_safety);
21322133
strbuf_release(&sb);
21332134

2134-
if (get_oid("HEAD", &head))
2135+
if (repo_get_oid(the_repository, "HEAD", &head))
21352136
oidclr(&head);
21362137

21372138
if (oideq(&head, &abort_safety))
@@ -2164,7 +2165,7 @@ static void am_abort(struct am_state *state)
21642165
if (!has_curr_head)
21652166
oidcpy(&curr_head, the_hash_algo->empty_tree);
21662167

2167-
has_orig_head = !get_oid("ORIG_HEAD", &orig_head);
2168+
has_orig_head = !repo_get_oid(the_repository, "ORIG_HEAD", &orig_head);
21682169
if (!has_orig_head)
21692170
oidcpy(&orig_head, the_hash_algo->empty_tree);
21702171

0 commit comments

Comments
 (0)