Skip to content

Commit d850b7a

Browse files
avargitster
authored andcommitted
cocci: apply the "cache.h" part of "the_repository.pending"
Apply the part of "the_repository.pending.cocci" pertaining to "cache.h". Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7258e89 commit d850b7a

Some content is hidden

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

79 files changed

+332
-310
lines changed

add-patch.c

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

apply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,7 +3610,7 @@ static int try_threeway(struct apply_state *state,
36103610
/* Preimage the patch was prepared for */
36113611
if (patch->is_new)
36123612
write_object_file("", 0, OBJ_BLOB, &pre_oid);
3613-
else if (get_oid(patch->old_oid_prefix, &pre_oid) ||
3613+
else if (repo_get_oid(the_repository, patch->old_oid_prefix, &pre_oid) ||
36143614
read_blob_object(&buf, &pre_oid, patch->old_mode))
36153615
return error(_("repository lacks the necessary blob to perform 3-way merge."));
36163616

@@ -4127,7 +4127,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
41274127
else
41284128
return error(_("sha1 information is lacking or "
41294129
"useless for submodule %s"), name);
4130-
} else if (!get_oid_blob(patch->old_oid_prefix, &oid)) {
4130+
} else if (!repo_get_oid_blob(the_repository, patch->old_oid_prefix, &oid)) {
41314131
; /* ok */
41324132
} else if (!patch->lines_added && !patch->lines_deleted) {
41334133
/* mode-only change: update the current */

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static void parse_treeish_arg(const char **argv,
461461
dwim_ref(name, strlen(name), &oid, &ref, 0);
462462
}
463463

464-
if (get_oid(name, &oid))
464+
if (repo_get_oid(the_repository, name, &oid))
465465
die(_("not a valid object name: %s"), name);
466466

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

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
531531
explicit_tracking = 1;
532532

533533
real_ref = NULL;
534-
if (get_oid_mb(start_name, &oid)) {
534+
if (repo_get_oid_mb(the_repository, start_name, &oid)) {
535535
if (explicit_tracking) {
536536
int code = die_message(_(upstream_missing), start_name);
537537
advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,

builtin/am.c

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

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

1112-
if (!get_oid("HEAD", &head))
1112+
if (!repo_get_oid(the_repository, "HEAD", &head))
11131113
write_state_text(state, "abort-safety", oid_to_hex(&head));
11141114
else
11151115
write_state_text(state, "abort-safety", "");
@@ -1402,7 +1402,7 @@ static void write_index_patch(const struct am_state *state)
14021402
struct rev_info rev_info;
14031403
FILE *fp;
14041404

1405-
if (!get_oid("HEAD", &head)) {
1405+
if (!repo_get_oid(the_repository, "HEAD", &head)) {
14061406
struct commit *commit = lookup_commit_or_die(&head, "HEAD");
14071407
tree = get_commit_tree(commit);
14081408
} else
@@ -1556,7 +1556,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
15561556
struct commit *result;
15571557
char *their_tree_name;
15581558

1559-
if (get_oid("HEAD", &our_tree) < 0)
1559+
if (repo_get_oid(the_repository, "HEAD", &our_tree) < 0)
15601560
oidcpy(&our_tree, the_hash_algo->empty_tree);
15611561

15621562
if (build_fake_ancestor(state, index_path))
@@ -1646,7 +1646,7 @@ static void do_commit(const struct am_state *state)
16461646
if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL))
16471647
die(_("git write-tree failed to write a tree"));
16481648

1649-
if (!get_oid_commit("HEAD", &parent)) {
1649+
if (!repo_get_oid_commit(the_repository, "HEAD", &parent)) {
16501650
old_oid = &parent;
16511651
commit_list_insert(lookup_commit(the_repository, &parent),
16521652
&parents);
@@ -2088,7 +2088,7 @@ static void am_skip(struct am_state *state)
20882088

20892089
am_rerere_clear();
20902090

2091-
if (get_oid("HEAD", &head))
2091+
if (repo_get_oid(the_repository, "HEAD", &head))
20922092
oidcpy(&head, the_hash_algo->empty_tree);
20932093

20942094
if (clean_index(&head, &head))
@@ -2130,7 +2130,7 @@ static int safe_to_abort(const struct am_state *state)
21302130
oidclr(&abort_safety);
21312131
strbuf_release(&sb);
21322132

2133-
if (get_oid("HEAD", &head))
2133+
if (repo_get_oid(the_repository, "HEAD", &head))
21342134
oidclr(&head);
21352135

21362136
if (oideq(&head, &abort_safety))
@@ -2163,7 +2163,7 @@ static void am_abort(struct am_state *state)
21632163
if (!has_curr_head)
21642164
oidcpy(&curr_head, the_hash_algo->empty_tree);
21652165

2166-
has_orig_head = !get_oid("ORIG_HEAD", &orig_head);
2166+
has_orig_head = !repo_get_oid(the_repository, "ORIG_HEAD", &orig_head);
21672167
if (!has_orig_head)
21682168
oidcpy(&orig_head, the_hash_algo->empty_tree);
21692169

builtin/bisect.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static int bisect_reset(const char *commit)
235235
} else {
236236
struct object_id oid;
237237

238-
if (get_oid_commit(commit, &oid))
238+
if (repo_get_oid_commit(the_repository, commit, &oid))
239239
return error(_("'%s' is not a valid commit"), commit);
240240
strbuf_addstr(&branch, commit);
241241
}
@@ -292,7 +292,7 @@ static int bisect_write(const char *state, const char *rev,
292292
goto finish;
293293
}
294294

295-
if (get_oid(rev, &oid)) {
295+
if (repo_get_oid(the_repository, rev, &oid)) {
296296
res = error(_("couldn't get the oid of the rev '%s'"), rev);
297297
goto finish;
298298
}
@@ -775,7 +775,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
775775
*/
776776
head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags);
777777
if (!head)
778-
if (get_oid("HEAD", &head_oid))
778+
if (repo_get_oid(the_repository, "HEAD", &head_oid))
779779
return error(_("bad HEAD - I need a HEAD"));
780780

781781
/*
@@ -801,11 +801,11 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
801801
}
802802
} else {
803803
/* Get the rev from where we start. */
804-
if (!get_oid(head, &head_oid) &&
804+
if (!repo_get_oid(the_repository, head, &head_oid) &&
805805
!starts_with(head, "refs/heads/")) {
806806
strbuf_reset(&start_head);
807807
strbuf_addstr(&start_head, oid_to_hex(&head_oid));
808-
} else if (!get_oid(head, &head_oid) &&
808+
} else if (!repo_get_oid(the_repository, head, &head_oid) &&
809809
skip_prefix(head, "refs/heads/", &head)) {
810810
strbuf_addstr(&start_head, head);
811811
} else {
@@ -828,7 +828,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
828828
write_file(git_path_bisect_first_parent(), "\n");
829829

830830
if (no_checkout) {
831-
if (get_oid(start_head.buf, &oid) < 0) {
831+
if (repo_get_oid(the_repository, start_head.buf, &oid) < 0) {
832832
res = error(_("invalid ref: '%s'"), start_head.buf);
833833
goto finish;
834834
}
@@ -933,11 +933,12 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
933933

934934
if (argc == 0) {
935935
const char *head = "BISECT_HEAD";
936-
enum get_oid_result res_head = get_oid(head, &oid);
936+
enum get_oid_result res_head = repo_get_oid(the_repository,
937+
head, &oid);
937938

938939
if (res_head == MISSING_OBJECT) {
939940
head = "HEAD";
940-
res_head = get_oid(head, &oid);
941+
res_head = repo_get_oid(the_repository, head, &oid);
941942
}
942943

943944
if (res_head)
@@ -953,7 +954,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
953954
for (; argc; argc--, argv++) {
954955
struct commit *commit;
955956

956-
if (get_oid(*argv, &oid)){
957+
if (repo_get_oid(the_repository, *argv, &oid)){
957958
error(_("Bad rev input: %s"), *argv);
958959
oid_array_clear(&revs);
959960
return BISECT_FAILED;

builtin/blame.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,9 @@ static int read_ancestry(const char *graft_file)
601601

602602
static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect)
603603
{
604-
const char *uniq = find_unique_abbrev(&suspect->commit->object.oid,
605-
auto_abbrev);
604+
const char *uniq = repo_find_unique_abbrev(the_repository,
605+
&suspect->commit->object.oid,
606+
auto_abbrev);
606607
int len = strlen(uniq);
607608
if (auto_abbrev < len)
608609
return len;
@@ -802,7 +803,7 @@ static int is_a_rev(const char *name)
802803
{
803804
struct object_id oid;
804805

805-
if (get_oid(name, &oid))
806+
if (repo_get_oid(the_repository, name, &oid))
806807
return 0;
807808
return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
808809
}
@@ -845,7 +846,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,
845846
peel_to_commit_oid, sb);
846847
}
847848
for_each_string_list_item(i, ignore_rev_list) {
848-
if (get_oid_committish(i->string, &oid) ||
849+
if (repo_get_oid_committish(the_repository, i->string, &oid) ||
849850
peel_to_commit_oid(&oid, sb))
850851
die(_("cannot find revision %s to ignore"), i->string);
851852
oidset_insert(&sb->ignore_list, &oid);

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
280280
item = string_list_append(&refs_to_delete, name);
281281
item->util = xstrdup((flags & REF_ISBROKEN) ? "broken"
282282
: (flags & REF_ISSYMREF) ? target
283-
: find_unique_abbrev(&oid, DEFAULT_ABBREV));
283+
: repo_find_unique_abbrev(the_repository, &oid, DEFAULT_ABBREV));
284284

285285
next:
286286
free(target);

builtin/checkout.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ static int checkout_worktree(const struct checkout_opts *opts,
432432
"Updated %d paths from %s",
433433
nr_checkouts),
434434
nr_checkouts,
435-
find_unique_abbrev(&opts->source_tree->object.oid,
436-
DEFAULT_ABBREV));
435+
repo_find_unique_abbrev(the_repository, &opts->source_tree->object.oid,
436+
DEFAULT_ABBREV));
437437
else if (!nr_unmerged || nr_checkouts)
438438
fprintf_ln(stderr, Q_("Updated %d path from the index",
439439
"Updated %d paths from the index",
@@ -644,10 +644,12 @@ static void describe_detached_head(const char *msg, struct commit *commit)
644644
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
645645
if (print_sha1_ellipsis()) {
646646
fprintf(stderr, "%s %s... %s\n", msg,
647-
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
647+
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
648+
sb.buf);
648649
} else {
649650
fprintf(stderr, "%s %s %s\n", msg,
650-
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
651+
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
652+
sb.buf);
651653
}
652654
strbuf_release(&sb);
653655
}
@@ -1060,7 +1062,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
10601062
" git branch <new-branch-name> %s\n\n",
10611063
/* Give ngettext() the count */
10621064
lost),
1063-
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
1065+
repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
10641066
}
10651067

10661068
/*
@@ -1322,7 +1324,7 @@ static int parse_branchname_arg(int argc, const char **argv,
13221324
if (!strcmp(arg, "-"))
13231325
arg = "@{-1}";
13241326

1325-
if (get_oid_mb(arg, rev)) {
1327+
if (repo_get_oid_mb(the_repository, arg, rev)) {
13261328
/*
13271329
* Either case (3) or (4), with <something> not being
13281330
* a commit, or an attempt to use case (1) with an
@@ -1748,7 +1750,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
17481750
} else if (!opts->accept_ref && opts->from_treeish) {
17491751
struct object_id rev;
17501752

1751-
if (get_oid_mb(opts->from_treeish, &rev))
1753+
if (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))
17521754
die(_("could not resolve %s"), opts->from_treeish);
17531755

17541756
setup_new_branch_info_and_source_tree(new_branch_info,

builtin/commit-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int parse_parent_arg_callback(const struct option *opt,
5353

5454
BUG_ON_OPT_NEG_NOARG(unset, arg);
5555

56-
if (get_oid_commit(arg, &oid))
56+
if (repo_get_oid_commit(the_repository, arg, &oid))
5757
die(_("not a valid object name %s"), arg);
5858

5959
assert_oid_type(&oid, OBJ_COMMIT);
@@ -131,7 +131,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
131131
if (argc != 1)
132132
die(_("must give exactly one tree"));
133133

134-
if (get_oid_tree(argv[0], &tree_oid))
134+
if (repo_get_oid_tree(the_repository, argv[0], &tree_oid))
135135
die(_("not a valid object name %s"), argv[0]);
136136

137137
if (!buffer.len) {

0 commit comments

Comments
 (0)