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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Mar 28, 2023 at 15:58 UTC
d850b7a545fcfbd97460a921c7f7c59d933eb0f7
79 files changed
+332
-310
add-patch.c
+1
-1
@@ -414,7 +414,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
414
strvec_push(&args,
415
/* could be on an unborn branch */
416
!strcmp("HEAD", s->revision) &&
417
- get_oid("HEAD", &oid) ?
417
+ repo_get_oid(the_repository, "HEAD", &oid) ?
418
empty_tree_oid_hex() : s->revision);
419
}
420
color_arg_index = args.nr;
apply.c
+2
-2
@@ -3610,7 +3610,7 @@ static int try_threeway(struct apply_state *state,
3610
/* Preimage the patch was prepared for */
3611
if (patch->is_new)
3612
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) ||
3614
read_blob_object(&buf, &pre_oid, patch->old_mode))
3615
return error(_("repository lacks the necessary blob to perform 3-way merge."));
3616
@@ -4127,7 +4127,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
4127
else
4128
return error(_("sha1 information is lacking or "
4129
"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)) {
4131
; /* ok */
4132
} else if (!patch->lines_added && !patch->lines_deleted) {
4133
/* mode-only change: update the current */
archive.c
+1
-1
@@ -461,7 +461,7 @@ static void parse_treeish_arg(const char **argv,
461
dwim_ref(name, strlen(name), &oid, &ref, 0);
462
}
463
464
- if (get_oid(name, &oid))
464
+ if (repo_get_oid(the_repository, name, &oid))
465
die(_("not a valid object name: %s"), name);
466
467
commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);
branch.c
+1
-1
@@ -531,7 +531,7 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
531
explicit_tracking = 1;
532
533
real_ref = NULL;
534
- if (get_oid_mb(start_name, &oid)) {
534
+ if (repo_get_oid_mb(the_repository, start_name, &oid)) {
535
if (explicit_tracking) {
536
int code = die_message(_(upstream_missing), start_name);
537
advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
builtin/am.c
+8
-8
@@ -1066,7 +1066,7 @@ static void am_setup(struct am_state *state, enum patch_format patch_format,
1066
else
1067
write_state_text(state, "applying", "");
1068
1069
- if (!get_oid("HEAD", &curr_head)) {
1069
+ if (!repo_get_oid(the_repository, "HEAD", &curr_head)) {
1070
write_state_text(state, "abort-safety", oid_to_hex(&curr_head));
1071
if (!state->rebasing)
1072
update_ref("am", "ORIG_HEAD", &curr_head, NULL, 0,
@@ -1109,7 +1109,7 @@ static void am_next(struct am_state *state)
1109
unlink(am_path(state, "original-commit"));
1110
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
1111
1112
- if (!get_oid("HEAD", &head))
1112
+ if (!repo_get_oid(the_repository, "HEAD", &head))
1113
write_state_text(state, "abort-safety", oid_to_hex(&head));
1114
else
1115
write_state_text(state, "abort-safety", "");
@@ -1402,7 +1402,7 @@ static void write_index_patch(const struct am_state *state)
1402
struct rev_info rev_info;
1403
FILE *fp;
1404
1405
- if (!get_oid("HEAD", &head)) {
1405
+ if (!repo_get_oid(the_repository, "HEAD", &head)) {
1406
struct commit *commit = lookup_commit_or_die(&head, "HEAD");
1407
tree = get_commit_tree(commit);
1408
} else
@@ -1556,7 +1556,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
1556
struct commit *result;
1557
char *their_tree_name;
1558
1559
- if (get_oid("HEAD", &our_tree) < 0)
1559
+ if (repo_get_oid(the_repository, "HEAD", &our_tree) < 0)
1560
oidcpy(&our_tree, the_hash_algo->empty_tree);
1561
1562
if (build_fake_ancestor(state, index_path))
@@ -1646,7 +1646,7 @@ static void do_commit(const struct am_state *state)
1646
if (write_index_as_tree(&tree, &the_index, get_index_file(), 0, NULL))
1647
die(_("git write-tree failed to write a tree"));
1648
1649
- if (!get_oid_commit("HEAD", &parent)) {
1649
+ if (!repo_get_oid_commit(the_repository, "HEAD", &parent)) {
1650
old_oid = &parent;
1651
commit_list_insert(lookup_commit(the_repository, &parent),
1652
&parents);
@@ -2088,7 +2088,7 @@ static void am_skip(struct am_state *state)
2088
2089
am_rerere_clear();
2090
2091
- if (get_oid("HEAD", &head))
2091
+ if (repo_get_oid(the_repository, "HEAD", &head))
2092
oidcpy(&head, the_hash_algo->empty_tree);
2093
2094
if (clean_index(&head, &head))
@@ -2130,7 +2130,7 @@ static int safe_to_abort(const struct am_state *state)
2130
oidclr(&abort_safety);
2131
strbuf_release(&sb);
2132
2133
- if (get_oid("HEAD", &head))
2133
+ if (repo_get_oid(the_repository, "HEAD", &head))
2134
oidclr(&head);
2135
2136
if (oideq(&head, &abort_safety))
@@ -2163,7 +2163,7 @@ static void am_abort(struct am_state *state)
2163
if (!has_curr_head)
2164
oidcpy(&curr_head, the_hash_algo->empty_tree);
2165
2166
- has_orig_head = !get_oid("ORIG_HEAD", &orig_head);
2166
+ has_orig_head = !repo_get_oid(the_repository, "ORIG_HEAD", &orig_head);
2167
if (!has_orig_head)
2168
oidcpy(&orig_head, the_hash_algo->empty_tree);
2169
builtin/bisect.c
+10
-9
@@ -235,7 +235,7 @@ static int bisect_reset(const char *commit)
235
} else {
236
struct object_id oid;
237
238
- if (get_oid_commit(commit, &oid))
238
+ if (repo_get_oid_commit(the_repository, commit, &oid))
239
return error(_("'%s' is not a valid commit"), commit);
240
strbuf_addstr(&branch, commit);
241
}
@@ -292,7 +292,7 @@ static int bisect_write(const char *state, const char *rev,
292
goto finish;
293
}
294
295
- if (get_oid(rev, &oid)) {
295
+ if (repo_get_oid(the_repository, rev, &oid)) {
296
res = error(_("couldn't get the oid of the rev '%s'"), rev);
297
goto finish;
298
}
@@ -775,7 +775,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
775
*/
776
head = resolve_ref_unsafe("HEAD", 0, &head_oid, &flags);
777
if (!head)
778
- if (get_oid("HEAD", &head_oid))
778
+ if (repo_get_oid(the_repository, "HEAD", &head_oid))
779
return error(_("bad HEAD - I need a HEAD"));
780
781
/*
@@ -801,11 +801,11 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
801
}
802
} else {
803
/* Get the rev from where we start. */
804
- if (!get_oid(head, &head_oid) &&
804
+ if (!repo_get_oid(the_repository, head, &head_oid) &&
805
!starts_with(head, "refs/heads/")) {
806
strbuf_reset(&start_head);
807
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) &&
809
skip_prefix(head, "refs/heads/", &head)) {
810
strbuf_addstr(&start_head, head);
811
} else {
@@ -828,7 +828,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
828
write_file(git_path_bisect_first_parent(), "\n");
829
830
if (no_checkout) {
831
- if (get_oid(start_head.buf, &oid) < 0) {
831
+ if (repo_get_oid(the_repository, start_head.buf, &oid) < 0) {
832
res = error(_("invalid ref: '%s'"), start_head.buf);
833
goto finish;
834
}
@@ -933,11 +933,12 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
933
934
if (argc == 0) {
935
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);
938
939
if (res_head == MISSING_OBJECT) {
940
head = "HEAD";
940
- res_head = get_oid(head, &oid);
941
+ res_head = repo_get_oid(the_repository, head, &oid);
942
}
943
944
if (res_head)
@@ -953,7 +954,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, int argc,
954
for (; argc; argc--, argv++) {
955
struct commit *commit;
956
956
- if (get_oid(*argv, &oid)){
957
+ if (repo_get_oid(the_repository, *argv, &oid)){
958
error(_("Bad rev input: %s"), *argv);
959
oid_array_clear(&revs);
960
return BISECT_FAILED;
builtin/blame.c
+5
-4
@@ -601,8 +601,9 @@ static int read_ancestry(const char *graft_file)
601
602
static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect)
603
{
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);
607
int len = strlen(uniq);
608
if (auto_abbrev < len)
609
return len;
@@ -802,7 +803,7 @@ static int is_a_rev(const char *name)
803
{
804
struct object_id oid;
805
805
- if (get_oid(name, &oid))
806
+ if (repo_get_oid(the_repository, name, &oid))
807
return 0;
808
return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
809
}
@@ -845,7 +846,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,
846
peel_to_commit_oid, sb);
847
}
848
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) ||
850
peel_to_commit_oid(&oid, sb))
851
die(_("cannot find revision %s to ignore"), i->string);
852
oidset_insert(&sb->ignore_list, &oid);
builtin/branch.c
+1
-1
@@ -280,7 +280,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
280
item = string_list_append(&refs_to_delete, name);
281
item->util = xstrdup((flags & REF_ISBROKEN) ? "broken"
282
: (flags & REF_ISSYMREF) ? target
283
- : find_unique_abbrev(&oid, DEFAULT_ABBREV));
283
+ : repo_find_unique_abbrev(the_repository, &oid, DEFAULT_ABBREV));
284
285
next:
286
free(target);
builtin/checkout.c
+9
-7
@@ -432,8 +432,8 @@ static int checkout_worktree(const struct checkout_opts *opts,
432
"Updated %d paths from %s",
433
nr_checkouts),
434
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));
437
else if (!nr_unmerged || nr_checkouts)
438
fprintf_ln(stderr, Q_("Updated %d path from the index",
439
"Updated %d paths from the index",
@@ -644,10 +644,12 @@ static void describe_detached_head(const char *msg, struct commit *commit)
644
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
645
if (print_sha1_ellipsis()) {
646
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);
649
} else {
650
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);
653
}
654
strbuf_release(&sb);
655
}
@@ -1060,7 +1062,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
1062
" git branch <new-branch-name> %s\n\n",
1063
/* Give ngettext() the count */
1064
lost),
1063
- find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
1065
+ repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
1066
}
1067
1068
/*
@@ -1322,7 +1324,7 @@ static int parse_branchname_arg(int argc, const char **argv,
1324
if (!strcmp(arg, "-"))
1325
arg = "@{-1}";
1326
1325
- if (get_oid_mb(arg, rev)) {
1327
+ if (repo_get_oid_mb(the_repository, arg, rev)) {
1328
/*
1329
* Either case (3) or (4), with <something> not being
1330
* 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,
1750
} else if (!opts->accept_ref && opts->from_treeish) {
1751
struct object_id rev;
1752
1751
- if (get_oid_mb(opts->from_treeish, &rev))
1753
+ if (repo_get_oid_mb(the_repository, opts->from_treeish, &rev))
1754
die(_("could not resolve %s"), opts->from_treeish);
1755
1756
setup_new_branch_info_and_source_tree(new_branch_info,
builtin/commit-tree.c
+2
-2
@@ -53,7 +53,7 @@ static int parse_parent_arg_callback(const struct option *opt,
53
54
BUG_ON_OPT_NEG_NOARG(unset, arg);
55
56
- if (get_oid_commit(arg, &oid))
56
+ if (repo_get_oid_commit(the_repository, arg, &oid))
57
die(_("not a valid object name %s"), arg);
58
59
assert_oid_type(&oid, OBJ_COMMIT);
@@ -131,7 +131,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
131
if (argc != 1)
132
die(_("must give exactly one tree"));
133
134
- if (get_oid_tree(argv[0], &tree_oid))
134
+ if (repo_get_oid_tree(the_repository, argv[0], &tree_oid))
135
die(_("not a valid object name %s"), argv[0]);
136
137
if (!buffer.len) {
builtin/commit.c
+4
-4
@@ -557,7 +557,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
557
s->index_file = index_file;
558
s->fp = fp;
559
s->nowarn = nowarn;
560
- s->is_initial = get_oid(s->reference, &oid) ? 1 : 0;
560
+ s->is_initial = repo_get_oid(the_repository, s->reference, &oid) ? 1 : 0;
561
if (!s->is_initial)
562
oidcpy(&s->oid_commit, &oid);
563
s->status_format = status_format;
@@ -1000,7 +1000,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
1000
if (amend)
1001
parent = "HEAD^1";
1002
1003
- if (get_oid(parent, &oid)) {
1003
+ if (repo_get_oid(the_repository, parent, &oid)) {
1004
int i, ita_nr = 0;
1005
1006
/* TODO: audit for interaction with sparse-index. */
@@ -1567,7 +1567,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1567
else
1568
fd = -1;
1569
1570
- s.is_initial = get_oid(s.reference, &oid) ? 1 : 0;
1570
+ s.is_initial = repo_get_oid(the_repository, s.reference, &oid) ? 1 : 0;
1571
if (!s.is_initial)
1572
oidcpy(&s.oid_commit, &oid);
1573
@@ -1714,7 +1714,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1714
status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
1715
s.colopts = 0;
1716
1717
- if (get_oid("HEAD", &oid))
1717
+ if (repo_get_oid(the_repository, "HEAD", &oid))
1718
current_head = NULL;
1719
else {
1720
current_head = lookup_commit_or_die(&oid, "HEAD");
builtin/describe.c
+3
-2
@@ -298,7 +298,8 @@ static void append_name(struct commit_name *n, struct strbuf *dst)
298
299
static void append_suffix(int depth, const struct object_id *oid, struct strbuf *dst)
300
{
301
- strbuf_addf(dst, "-%d-g%s", depth, find_unique_abbrev(oid, abbrev));
301
+ strbuf_addf(dst, "-%d-g%s", depth,
302
+ repo_find_unique_abbrev(the_repository, oid, abbrev));
303
}
304
305
static void describe_commit(struct object_id *oid, struct strbuf *dst)
@@ -531,7 +532,7 @@ static void describe(const char *arg, int last_one)
532
if (debug)
533
fprintf(stderr, _("describe %s\n"), arg);
534
534
- if (get_oid(arg, &oid))
535
+ if (repo_get_oid(the_repository, arg, &oid))
536
die(_("Not a valid object name %s"), arg);
537
cmit = lookup_commit_reference_gently(the_repository, &oid, 1);
538
builtin/fast-import.c
+4
-4
@@ -2486,7 +2486,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
2486
if (commit_oe->type != OBJ_COMMIT)
2487
die("Mark :%" PRIuMAX " not a commit", commit_mark);
2488
oidcpy(&commit_oid, &commit_oe->idx.oid);
2489
- } else if (!get_oid(p, &commit_oid)) {
2489
+ } else if (!repo_get_oid(the_repository, p, &commit_oid)) {
2490
unsigned long size;
2491
char *buf = read_object_with_reference(the_repository,
2492
&commit_oid,
@@ -2599,7 +2599,7 @@ static int parse_objectish(struct branch *b, const char *objectish)
2599
} else
2600
parse_from_existing(b);
2601
}
2602
- } else if (!get_oid(objectish, &b->oid)) {
2602
+ } else if (!repo_get_oid(the_repository, objectish, &b->oid)) {
2603
parse_from_existing(b);
2604
if (is_null_oid(&b->oid))
2605
b->delete = 1;
@@ -2654,7 +2654,7 @@ static struct hash_list *parse_merge(unsigned int *count)
2654
if (oe->type != OBJ_COMMIT)
2655
die("Mark :%" PRIuMAX " not a commit", idnum);
2656
oidcpy(&n->oid, &oe->idx.oid);
2657
- } else if (!get_oid(from, &n->oid)) {
2657
+ } else if (!repo_get_oid(the_repository, from, &n->oid)) {
2658
unsigned long size;
2659
char *buf = read_object_with_reference(the_repository,
2660
&n->oid,
@@ -2827,7 +2827,7 @@ static void parse_new_tag(const char *arg)
2827
oe = find_mark(marks, from_mark);
2828
type = oe->type;
2829
oidcpy(&oid, &oe->idx.oid);
2830
- } else if (!get_oid(from, &oid)) {
2830
+ } else if (!repo_get_oid(the_repository, from, &oid)) {
2831
struct object_entry *oe = find_object(&oid);
2832
if (!oe) {
2833
type = oid_object_info(the_repository, &oid, NULL);
builtin/fetch.c
+1
-1
@@ -1487,7 +1487,7 @@ static void add_negotiation_tips(struct git_transport_options *smart_options)
1487
int old_nr;
1488
if (!has_glob_specials(s)) {
1489
struct object_id oid;
1490
- if (get_oid(s, &oid))
1490
+ if (repo_get_oid(the_repository, s, &oid))
1491
die(_("%s is not a valid object"), s);
1492
if (!has_object(the_repository, &oid, 0))
1493
die(_("the object %s does not exist"), s);
builtin/fsck.c
+1
-1
@@ -923,7 +923,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
923
for (i = 0; i < argc; i++) {
924
const char *arg = argv[i];
925
struct object_id oid;
926
- if (!get_oid(arg, &oid)) {
926
+ if (!repo_get_oid(the_repository, arg, &oid)) {
927
struct object *obj = lookup_object(the_repository,
928
&oid);
929
builtin/log.c
+4
-4
@@ -1642,7 +1642,7 @@ static struct commit *get_base_commit(const char *base_commit,
1642
struct commit *commit;
1643
struct object_id oid;
1644
1645
- if (get_oid(upstream, &oid)) {
1645
+ if (repo_get_oid(the_repository, upstream, &oid)) {
1646
if (die_on_failure)
1647
die(_("failed to resolve '%s' as a valid ref"), upstream);
1648
else
@@ -2396,7 +2396,7 @@ done:
2396
static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
2397
{
2398
struct object_id oid;
2399
- if (get_oid(arg, &oid) == 0) {
2399
+ if (repo_get_oid(the_repository, arg, &oid) == 0) {
2400
struct commit *commit = lookup_commit_reference(the_repository,
2401
&oid);
2402
if (commit) {
@@ -2418,12 +2418,12 @@ static void print_commit(char sign, struct commit *commit, int verbose,
2418
{
2419
if (!verbose) {
2420
fprintf(file, "%c %s\n", sign,
2421
- find_unique_abbrev(&commit->object.oid, abbrev));
2421
+ repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev));
2422
} else {
2423
struct strbuf buf = STRBUF_INIT;
2424
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
2425
fprintf(file, "%c %s %s\n", sign,
2426
- find_unique_abbrev(&commit->object.oid, abbrev),
2426
+ repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev),
2427
buf.buf);
2428
strbuf_release(&buf);
2429
}
builtin/ls-files.c
+2
-2
@@ -360,7 +360,7 @@ static void show_ru_info(struct index_state *istate)
360
if (!ui->mode[i])
361
continue;
362
printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
363
- find_unique_abbrev(&ui->oid[i], abbrev),
363
+ repo_find_unique_abbrev(the_repository, &ui->oid[i], abbrev),
364
i + 1);
365
write_name(path);
366
}
@@ -575,7 +575,7 @@ void overlay_tree_on_index(struct index_state *istate,
575
read_tree_fn_t fn = NULL;
576
int err;
577
578
- if (get_oid(tree_name, &oid))
578
+ if (repo_get_oid(the_repository, tree_name, &oid))
579
die("tree-ish %s not found.", tree_name);
580
tree = parse_tree_indirect(&oid);
581
if (!tree)
builtin/ls-tree.c
+5
-4
@@ -228,7 +228,7 @@ static int show_tree_default(const struct object_id *oid, struct strbuf *base,
228
return early;
229
230
printf("%06o %s %s\t", mode, type_name(object_type(mode)),
231
- find_unique_abbrev(oid, options->abbrev));
231
+ repo_find_unique_abbrev(the_repository, oid, options->abbrev));
232
show_tree_common_default_long(options, base, pathname, base->len);
233
return recurse;
234
}
@@ -259,7 +259,8 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
259
}
260
261
printf("%06o %s %s %7s\t", mode, type_name(type),
262
- find_unique_abbrev(oid, options->abbrev), size_text);
262
+ repo_find_unique_abbrev(the_repository, oid, options->abbrev),
263
+ size_text);
264
show_tree_common_default_long(options, base, pathname, base->len);
265
return recurse;
266
}
@@ -310,7 +311,7 @@ static int show_tree_object(const struct object_id *oid, struct strbuf *base,
311
if (early >= 0)
312
return early;
313
313
- str = find_unique_abbrev(oid, options->abbrev);
314
+ str = repo_find_unique_abbrev(the_repository, oid, options->abbrev);
315
if (options->null_termination) {
316
fputs(str, stdout);
317
fputc('\0', stdout);
@@ -433,7 +434,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
434
ls_tree_usage, ls_tree_options);
435
if (argc < 1)
436
usage_with_options(ls_tree_usage, ls_tree_options);
436
- if (get_oid(argv[0], &oid))
437
+ if (repo_get_oid(the_repository, argv[0], &oid))
438
die("Not a valid object name %s", argv[0]);
439
440
/*
builtin/merge-base.c
+2
-2
@@ -42,7 +42,7 @@ static struct commit *get_commit_reference(const char *arg)
42
struct object_id revkey;
43
struct commit *r;
44
45
- if (get_oid(arg, &revkey))
45
+ if (repo_get_oid(the_repository, arg, &revkey))
46
die("Not a valid object name %s", arg);
47
r = lookup_commit_reference(the_repository, &revkey);
48
if (!r)
@@ -118,7 +118,7 @@ static int handle_fork_point(int argc, const char **argv)
118
const char *commitname;
119
120
commitname = (argc == 2) ? argv[1] : "HEAD";
121
- if (get_oid(commitname, &oid))
121
+ if (repo_get_oid(the_repository, commitname, &oid))
122
die("Not a valid object name: '%s'", commitname);
123
124
derived = lookup_commit_reference(the_repository, &oid);
builtin/merge-recursive.c
+3
-3
@@ -49,7 +49,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
49
}
50
if (bases_count < ARRAY_SIZE(bases)-1) {
51
struct object_id *oid = xmalloc(sizeof(struct object_id));
52
- if (get_oid(argv[i], oid))
52
+ if (repo_get_oid(the_repository, argv[i], oid))
53
die(_("could not parse object '%s'"), argv[i]);
54
bases[bases_count++] = oid;
55
}
@@ -70,9 +70,9 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
70
o.branch1 = argv[++i];
71
o.branch2 = argv[++i];
72
73
- if (get_oid(o.branch1, &h1))
73
+ if (repo_get_oid(the_repository, o.branch1, &h1))
74
die(_("could not resolve ref '%s'"), o.branch1);
75
- if (get_oid(o.branch2, &h2))
75
+ if (repo_get_oid(the_repository, o.branch2, &h2))
76
die(_("could not resolve ref '%s'"), o.branch2);
77
78
o.branch1 = better1 = better_branch_name(o.branch1);
builtin/merge.c
+5
-5
@@ -337,7 +337,7 @@ static int save_state(struct object_id *stash)
337
else if (!len) /* no changes */
338
goto out;
339
strbuf_setlen(&buffer, buffer.len-1);
340
- if (get_oid(buffer.buf, stash))
340
+ if (repo_get_oid(the_repository, buffer.buf, stash))
341
die(_("not a valid object: %s"), buffer.buf);
342
rc = 0;
343
out:
@@ -1567,10 +1567,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1567
1568
if (verbosity >= 0) {
1569
printf(_("Updating %s..%s\n"),
1570
- find_unique_abbrev(&head_commit->object.oid,
1571
- DEFAULT_ABBREV),
1572
- find_unique_abbrev(&remoteheads->item->object.oid,
1573
- DEFAULT_ABBREV));
1570
+ repo_find_unique_abbrev(the_repository, &head_commit->object.oid,
1571
+ DEFAULT_ABBREV),
1572
+ repo_find_unique_abbrev(the_repository, &remoteheads->item->object.oid,
1573
+ DEFAULT_ABBREV));
1574
}
1575
commit = remoteheads->item;
1576
if (!commit) {
builtin/name-rev.c
+4
-3
@@ -493,7 +493,8 @@ static void show_name(const struct object *obj,
493
else if (allow_undefined)
494
printf("undefined\n");
495
else if (always)
496
- printf("%s\n", find_unique_abbrev(oid, DEFAULT_ABBREV));
496
+ printf("%s\n",
497
+ repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
498
else
499
die("cannot describe '%s'", oid_to_hex(oid));
500
strbuf_release(&buf);
@@ -527,7 +528,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)
528
counter = 0;
529
530
*(p+1) = 0;
530
- if (!get_oid(p - (hexsz - 1), &oid)) {
531
+ if (!repo_get_oid(the_repository, p - (hexsz - 1), &oid)) {
532
struct object *o =
533
lookup_object(the_repository, &oid);
534
if (o)
@@ -604,7 +605,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
605
struct object *object;
606
struct commit *commit;
607
607
- if (get_oid(*argv, &oid)) {
608
+ if (repo_get_oid(the_repository, *argv, &oid)) {
609
fprintf(stderr, "Could not get sha1 for %s. Skipping.\n",
610
*argv);
611
continue;
builtin/notes.c
+11
-11
@@ -257,7 +257,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
257
if (d->buf.len)
258
strbuf_addch(&d->buf, '\n');
259
260
- if (get_oid(arg, &object))
260
+ if (repo_get_oid(the_repository, arg, &object))
261
die(_("failed to resolve '%s' as a valid ref."), arg);
262
if (!(buf = read_object_file(&object, &type, &len)))
263
die(_("failed to read object '%s'."), arg);
@@ -307,9 +307,9 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
307
die(_("malformed input line: '%s'."), buf.buf);
308
strbuf_rtrim(split[0]);
309
strbuf_rtrim(split[1]);
310
- if (get_oid(split[0]->buf, &from_obj))
310
+ if (repo_get_oid(the_repository, split[0]->buf, &from_obj))
311
die(_("failed to resolve '%s' as a valid ref."), split[0]->buf);
312
- if (get_oid(split[1]->buf, &to_obj))
312
+ if (repo_get_oid(the_repository, split[1]->buf, &to_obj))
313
die(_("failed to resolve '%s' as a valid ref."), split[1]->buf);
314
315
if (rewrite_cmd)
@@ -377,7 +377,7 @@ static int list(int argc, const char **argv, const char *prefix)
377
378
t = init_notes_check("list", 0);
379
if (argc) {
380
- if (get_oid(argv[0], &object))
380
+ if (repo_get_oid(the_repository, argv[0], &object))
381
die(_("failed to resolve '%s' as a valid ref."), argv[0]);
382
note = get_note(t, &object);
383
if (note) {
@@ -432,7 +432,7 @@ static int add(int argc, const char **argv, const char *prefix)
432
433
object_ref = argc > 1 ? argv[1] : "HEAD";
434
435
- if (get_oid(object_ref, &object))
435
+ if (repo_get_oid(the_repository, object_ref, &object))
436
die(_("failed to resolve '%s' as a valid ref."), object_ref);
437
438
t = init_notes_check("add", NOTES_INIT_WRITABLE);
@@ -520,12 +520,12 @@ static int copy(int argc, const char **argv, const char *prefix)
520
usage_with_options(git_notes_copy_usage, options);
521
}
522
523
- if (get_oid(argv[0], &from_obj))
523
+ if (repo_get_oid(the_repository, argv[0], &from_obj))
524
die(_("failed to resolve '%s' as a valid ref."), argv[0]);
525
526
object_ref = 1 < argc ? argv[1] : "HEAD";
527
528
- if (get_oid(object_ref, &object))
528
+ if (repo_get_oid(the_repository, object_ref, &object))
529
die(_("failed to resolve '%s' as a valid ref."), object_ref);
530
531
t = init_notes_check("copy", NOTES_INIT_WRITABLE);
@@ -604,7 +604,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)
604
605
object_ref = 1 < argc ? argv[1] : "HEAD";
606
607
- if (get_oid(object_ref, &object))
607
+ if (repo_get_oid(the_repository, object_ref, &object))
608
die(_("failed to resolve '%s' as a valid ref."), object_ref);
609
610
t = init_notes_check(argv[0], NOTES_INIT_WRITABLE);
@@ -666,7 +666,7 @@ static int show(int argc, const char **argv, const char *prefix)
666
667
object_ref = argc ? argv[0] : "HEAD";
668
669
- if (get_oid(object_ref, &object))
669
+ if (repo_get_oid(the_repository, object_ref, &object))
670
die(_("failed to resolve '%s' as a valid ref."), object_ref);
671
672
t = init_notes_check("show", 0);
@@ -716,7 +716,7 @@ static int merge_commit(struct notes_merge_options *o)
716
* and target notes ref from .git/NOTES_MERGE_REF.
717
*/
718
719
- if (get_oid("NOTES_MERGE_PARTIAL", &oid))
719
+ if (repo_get_oid(the_repository, "NOTES_MERGE_PARTIAL", &oid))
720
die(_("failed to read ref NOTES_MERGE_PARTIAL"));
721
else if (!(partial = lookup_commit_reference(the_repository, &oid)))
722
die(_("could not find commit from NOTES_MERGE_PARTIAL."));
@@ -895,7 +895,7 @@ static int remove_one_note(struct notes_tree *t, const char *name, unsigned flag
895
{
896
int status;
897
struct object_id oid;
898
- if (get_oid(name, &oid))
898
+ if (repo_get_oid(the_repository, name, &oid))
899
return error(_("Failed to resolve '%s' as a valid ref."), name);
900
status = remove_note(t, oid.hash);
901
if (status)
builtin/prune.c
+1
-1
@@ -168,7 +168,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
168
struct object_id oid;
169
const char *name = *argv++;
170
171
- if (!get_oid(name, &oid)) {
171
+ if (!repo_get_oid(the_repository, name, &oid)) {
172
struct object *object = parse_object_or_die(&oid,
173
name);
174
add_pending_object(&revs, object, "");
builtin/pull.c
+2
-2
@@ -1036,7 +1036,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
1036
if (file_exists(git_path_merge_head(the_repository)))
1037
die_conclude_merge();
1038
1039
- if (get_oid("HEAD", &orig_head))
1039
+ if (repo_get_oid(the_repository, "HEAD", &orig_head))
1040
oidclr(&orig_head);
1041
1042
if (opt_rebase) {
@@ -1061,7 +1061,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
1061
if (opt_dry_run)
1062
return 0;
1063
1064
- if (get_oid("HEAD", &curr_head))
1064
+ if (repo_get_oid(the_repository, "HEAD", &curr_head))
1065
oidclr(&curr_head);
1066
1067
if (!is_null_oid(&orig_head) && !is_null_oid(&curr_head) &&
builtin/range-diff.c
+6
-6
@@ -65,20 +65,20 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
65
66
if (dash_dash == 3 ||
67
(dash_dash < 0 && argc > 2 &&
68
- !get_oid_committish(argv[0], &oid) &&
69
- !get_oid_committish(argv[1], &oid) &&
70
- !get_oid_committish(argv[2], &oid))) {
68
+ !repo_get_oid_committish(the_repository, argv[0], &oid) &&
69
+ !repo_get_oid_committish(the_repository, argv[1], &oid) &&
70
+ !repo_get_oid_committish(the_repository, argv[2], &oid))) {
71
if (dash_dash < 0)
72
; /* already validated arguments */
73
- else if (get_oid_committish(argv[0], &oid))
73
+ else if (repo_get_oid_committish(the_repository, argv[0], &oid))
74
usage_msg_optf(_("not a revision: '%s'"),
75
builtin_range_diff_usage, options,
76
argv[0]);
77
- else if (get_oid_committish(argv[1], &oid))
77
+ else if (repo_get_oid_committish(the_repository, argv[1], &oid))
78
usage_msg_optf(_("not a revision: '%s'"),
79
builtin_range_diff_usage, options,
80
argv[1]);
81
- else if (get_oid_committish(argv[2], &oid))
81
+ else if (repo_get_oid_committish(the_repository, argv[2], &oid))
82
usage_msg_optf(_("not a revision: '%s'"),
83
builtin_range_diff_usage, options,
84
argv[2]);
builtin/read-tree.c
+1
-1
@@ -198,7 +198,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
198
for (i = 0; i < argc; i++) {
199
const char *arg = argv[i];
200
201
- if (get_oid(arg, &oid))
201
+ if (repo_get_oid(the_repository, arg, &oid))
202
die("Not a valid object name %s", arg);
203
if (list_tree(&oid) < 0)
204
die("failed to unpack tree object %s", arg);
builtin/rebase.c
+7
-5
@@ -218,13 +218,15 @@ static int get_revision_ranges(struct commit *upstream, struct commit *onto,
218
*revisions = xstrfmt("%s...%s", oid_to_hex(&base_rev->object.oid),
219
oid_to_hex(orig_head));
220
221
- shorthead = find_unique_abbrev(orig_head, DEFAULT_ABBREV);
221
+ shorthead = repo_find_unique_abbrev(the_repository, orig_head,
222
+ DEFAULT_ABBREV);
223
224
if (upstream) {
225
const char *shortrev;
226
226
- shortrev = find_unique_abbrev(&base_rev->object.oid,
227
- DEFAULT_ABBREV);
227
+ shortrev = repo_find_unique_abbrev(the_repository,
228
+ &base_rev->object.oid,
229
+ DEFAULT_ABBREV);
230
231
*shortrevisions = xstrfmt("%s..%s", shortrev, shorthead);
232
} else
@@ -1261,7 +1263,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1263
int fd;
1264
1265
/* Sanity check */
1264
- if (get_oid("HEAD", &head))
1266
+ if (repo_get_oid(the_repository, "HEAD", &head))
1267
die(_("Cannot read HEAD"));
1268
1269
fd = repo_hold_locked_index(the_repository, &lock_file, 0);
@@ -1680,7 +1682,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1682
} else if (!options.onto_name)
1683
options.onto_name = options.upstream_name;
1684
if (strstr(options.onto_name, "...")) {
1683
- if (get_oid_mb(options.onto_name, &branch_base) < 0) {
1685
+ if (repo_get_oid_mb(the_repository, options.onto_name, &branch_base) < 0) {
1686
if (keep_base)
1687
die(_("'%s': need exactly one merge base with branch"),
1688
options.upstream_name);
builtin/receive-pack.c
+5
-5
@@ -1347,7 +1347,7 @@ static int head_has_history(void)
1347
{
1348
struct object_id oid;
1349
1350
- return !get_oid("HEAD", &oid);
1350
+ return !repo_get_oid(the_repository, "HEAD", &oid);
1351
}
1352
1353
static const char *push_to_deploy(unsigned char *sha1,
@@ -1681,11 +1681,11 @@ static void check_aliased_update_internal(struct command *cmd,
1681
rp_error("refusing inconsistent update between symref '%s' (%s..%s) and"
1682
" its target '%s' (%s..%s)",
1683
cmd->ref_name,
1684
- find_unique_abbrev(&cmd->old_oid, DEFAULT_ABBREV),
1685
- find_unique_abbrev(&cmd->new_oid, DEFAULT_ABBREV),
1684
+ repo_find_unique_abbrev(the_repository, &cmd->old_oid, DEFAULT_ABBREV),
1685
+ repo_find_unique_abbrev(the_repository, &cmd->new_oid, DEFAULT_ABBREV),
1686
dst_cmd->ref_name,
1687
- find_unique_abbrev(&dst_cmd->old_oid, DEFAULT_ABBREV),
1688
- find_unique_abbrev(&dst_cmd->new_oid, DEFAULT_ABBREV));
1687
+ repo_find_unique_abbrev(the_repository, &dst_cmd->old_oid, DEFAULT_ABBREV),
1688
+ repo_find_unique_abbrev(the_repository, &dst_cmd->new_oid, DEFAULT_ABBREV));
1689
1690
cmd->error_string = dst_cmd->error_string =
1691
"inconsistent aliased update";
builtin/replace.c
+8
-8
@@ -54,7 +54,7 @@ static int show_reference(struct repository *r, const char *refname,
54
struct object_id object;
55
enum object_type obj_type, repl_type;
56
57
- if (get_oid(refname, &object))
57
+ if (repo_get_oid(the_repository, refname, &object))
58
return error(_("failed to resolve '%s' as a valid ref"), refname);
59
60
obj_type = oid_object_info(r, &object, NULL);
@@ -112,7 +112,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
112
base_len = ref.len;
113
114
for (p = argv; *p; p++) {
115
- if (get_oid(*p, &oid)) {
115
+ if (repo_get_oid(the_repository, *p, &oid)) {
116
error("failed to resolve '%s' as a valid ref", *p);
117
had_error = 1;
118
continue;
@@ -206,10 +206,10 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
206
{
207
struct object_id object, repl;
208
209
- if (get_oid(object_ref, &object))
209
+ if (repo_get_oid(the_repository, object_ref, &object))
210
return error(_("failed to resolve '%s' as a valid ref"),
211
object_ref);
212
- if (get_oid(replace_ref, &repl))
212
+ if (repo_get_oid(the_repository, replace_ref, &repl))
213
return error(_("failed to resolve '%s' as a valid ref"),
214
replace_ref);
215
@@ -320,7 +320,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
320
struct object_id old_oid, new_oid, prev;
321
struct strbuf ref = STRBUF_INIT;
322
323
- if (get_oid(object_ref, &old_oid) < 0)
323
+ if (repo_get_oid(the_repository, object_ref, &old_oid) < 0)
324
return error(_("not a valid object name: '%s'"), object_ref);
325
326
type = oid_object_info(the_repository, &old_oid, NULL);
@@ -375,7 +375,7 @@ static int replace_parents(struct strbuf *buf, int argc, const char **argv)
375
struct object_id oid;
376
struct commit *commit;
377
378
- if (get_oid(argv[i], &oid) < 0) {
378
+ if (repo_get_oid(the_repository, argv[i], &oid) < 0) {
379
strbuf_release(&new_parents);
380
return error(_("not a valid object name: '%s'"),
381
argv[i]);
@@ -422,7 +422,7 @@ static int check_one_mergetag(struct commit *commit,
422
/* iterate over new parents */
423
for (i = 1; i < mergetag_data->argc; i++) {
424
struct object_id oid;
425
- if (get_oid(mergetag_data->argv[i], &oid) < 0)
425
+ if (repo_get_oid(the_repository, mergetag_data->argv[i], &oid) < 0)
426
return error(_("not a valid object name: '%s'"),
427
mergetag_data->argv[i]);
428
if (oideq(get_tagged_oid(tag), &oid))
@@ -452,7 +452,7 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
452
const char *buffer;
453
unsigned long size;
454
455
- if (get_oid(old_ref, &old_oid) < 0)
455
+ if (repo_get_oid(the_repository, old_ref, &old_oid) < 0)
456
return error(_("not a valid object name: '%s'"), old_ref);
457
commit = lookup_commit_reference(the_repository, &old_oid);
458
if (!commit)
builtin/reset.c
+10
-9
@@ -89,7 +89,7 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t
89
90
if (reset_type == KEEP) {
91
struct object_id head_oid;
92
- if (get_oid("HEAD", &head_oid))
92
+ if (repo_get_oid(the_repository, "HEAD", &head_oid))
93
return error(_("You do not have a valid HEAD."));
94
if (!fill_tree_descriptor(the_repository, desc + nr, &head_oid))
95
return error(_("Failed to find tree of HEAD."));
@@ -124,7 +124,7 @@ static void print_new_head_line(struct commit *commit)
124
struct strbuf buf = STRBUF_INIT;
125
126
printf(_("HEAD is now at %s"),
127
- find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
127
+ repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
128
129
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
130
if (buf.len > 0)
@@ -260,8 +260,8 @@ static void parse_args(struct pathspec *pathspec,
260
* has to be unambiguous. If there is a single argument, it
261
* can not be a tree
262
*/
263
- else if ((!argv[1] && !get_oid_committish(argv[0], &unused)) ||
264
- (argv[1] && !get_oid_treeish(argv[0], &unused))) {
263
+ else if ((!argv[1] && !repo_get_oid_committish(the_repository, argv[0], &unused)) ||
264
+ (argv[1] && !repo_get_oid_treeish(the_repository, argv[0], &unused))) {
265
/*
266
* Ok, argv[0] looks like a commit/tree; it should not
267
* be a filename.
@@ -288,9 +288,9 @@ static int reset_refs(const char *rev, const struct object_id *oid)
288
struct object_id *orig = NULL, oid_orig,
289
*old_orig = NULL, oid_old_orig;
290
291
- if (!get_oid("ORIG_HEAD", &oid_old_orig))
291
+ if (!repo_get_oid(the_repository, "ORIG_HEAD", &oid_old_orig))
292
old_orig = &oid_old_orig;
293
- if (!get_oid("HEAD", &oid_orig)) {
293
+ if (!repo_get_oid(the_repository, "HEAD", &oid_orig)) {
294
orig = &oid_orig;
295
set_reflog_message(&msg, "updating ORIG_HEAD", NULL);
296
update_ref(msg.buf, "ORIG_HEAD", orig, old_orig, 0,
@@ -365,13 +365,14 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
365
die(_("the option '%s' requires '%s'"), "--pathspec-file-nul", "--pathspec-from-file");
366
}
367
368
- unborn = !strcmp(rev, "HEAD") && get_oid("HEAD", &oid);
368
+ unborn = !strcmp(rev, "HEAD") && repo_get_oid(the_repository, "HEAD",
369
+ &oid);
370
if (unborn) {
371
/* reset on unborn branch: treat as reset to empty tree */
372
oidcpy(&oid, the_hash_algo->empty_tree);
373
} else if (!pathspec.nr && !patch_mode) {
374
struct commit *commit;
374
- if (get_oid_committish(rev, &oid))
375
+ if (repo_get_oid_committish(the_repository, rev, &oid))
376
die(_("Failed to resolve '%s' as a valid revision."), rev);
377
commit = lookup_commit_reference(the_repository, &oid);
378
if (!commit)
@@ -379,7 +380,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
380
oidcpy(&oid, &commit->object.oid);
381
} else {
382
struct tree *tree;
382
- if (get_oid_treeish(rev, &oid))
383
+ if (repo_get_oid_treeish(the_repository, rev, &oid))
384
die(_("Failed to resolve '%s' as a valid tree."), rev);
385
tree = parse_tree_indirect(&oid);
386
if (!tree)
builtin/rev-list.c
+1
-1
@@ -134,7 +134,7 @@ static void show_commit(struct commit *commit, void *data)
134
if (!revs->graph)
135
fputs(get_revision_mark(revs, commit), stdout);
136
if (revs->abbrev_commit && revs->abbrev)
137
- fputs(find_unique_abbrev(&commit->object.oid, revs->abbrev),
137
+ fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, revs->abbrev),
138
stdout);
139
else
140
fputs(oid_to_hex(&commit->object.oid), stdout);
builtin/rev-parse.c
+7
-5
@@ -162,7 +162,8 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
162
}
163
}
164
else if (abbrev)
165
- show_with_type(type, find_unique_abbrev(oid, abbrev));
165
+ show_with_type(type,
166
+ repo_find_unique_abbrev(the_repository, oid, abbrev));
167
else
168
show_with_type(type, oid_to_hex(oid));
169
}
@@ -187,7 +188,7 @@ static int show_default(void)
188
struct object_id oid;
189
190
def = NULL;
190
- if (!get_oid(s, &oid)) {
191
+ if (!repo_get_oid(the_repository, s, &oid)) {
192
show_rev(NORMAL, &oid, s);
193
return 1;
194
}
@@ -279,7 +280,7 @@ static int try_difference(const char *arg)
280
return 0;
281
}
282
282
- if (!get_oid_committish(start, &start_oid) && !get_oid_committish(end, &end_oid)) {
283
+ if (!repo_get_oid_committish(the_repository, start, &start_oid) && !repo_get_oid_committish(the_repository, end, &end_oid)) {
284
show_rev(NORMAL, &end_oid, end);
285
show_rev(symmetric ? NORMAL : REVERSED, &start_oid, start);
286
if (symmetric) {
@@ -337,7 +338,7 @@ static int try_parent_shorthands(const char *arg)
338
return 0;
339
340
*dotdot = 0;
340
- if (get_oid_committish(arg, &oid) ||
341
+ if (repo_get_oid_committish(the_repository, arg, &oid) ||
342
!(commit = lookup_commit_reference(the_repository, &oid))) {
343
*dotdot = '^';
344
return 0;
@@ -868,7 +869,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
869
continue;
870
}
871
if (skip_prefix(arg, "--disambiguate=", &arg)) {
871
- for_each_abbrev(arg, show_abbrev, NULL);
872
+ repo_for_each_abbrev(the_repository, arg,
873
+ show_abbrev, NULL);
874
continue;
875
}
876
if (!strcmp(arg, "--bisect")) {
builtin/rm.c
+1
-1
@@ -370,7 +370,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
370
*/
371
if (!force) {
372
struct object_id oid;
373
- if (get_oid("HEAD", &oid))
373
+ if (repo_get_oid(the_repository, "HEAD", &oid))
374
oidclr(&oid);
375
if (check_local_mod(&oid, index_only))
376
exit(1);
builtin/show-branch.c
+6
-6
@@ -312,8 +312,8 @@ static void show_one_commit(struct commit *commit, int no_name)
312
}
313
else
314
printf("[%s] ",
315
- find_unique_abbrev(&commit->object.oid,
316
- DEFAULT_ABBREV));
315
+ repo_find_unique_abbrev(the_repository, &commit->object.oid,
316
+ DEFAULT_ABBREV));
317
}
318
puts(pretty_str);
319
strbuf_release(&pretty);
@@ -414,7 +414,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
414
/* If both heads/foo and tags/foo exists, get_sha1 would
415
* get confused.
416
*/
417
- if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
417
+ if (repo_get_oid(the_repository, refname + ofs, &tmp) || !oideq(&tmp, oid))
418
ofs = 5;
419
return append_ref(refname + ofs, oid, 0);
420
}
@@ -429,7 +429,7 @@ static int append_remote_ref(const char *refname, const struct object_id *oid,
429
/* If both heads/foo and tags/foo exists, get_sha1 would
430
* get confused.
431
*/
432
- if (get_oid(refname + ofs, &tmp) || !oideq(&tmp, oid))
432
+ if (repo_get_oid(the_repository, refname + ofs, &tmp) || !oideq(&tmp, oid))
433
ofs = 5;
434
return append_ref(refname + ofs, oid, 0);
435
}
@@ -533,7 +533,7 @@ static int show_independent(struct commit **rev,
533
static void append_one_rev(const char *av)
534
{
535
struct object_id revkey;
536
- if (!get_oid(av, &revkey)) {
536
+ if (!repo_get_oid(the_repository, av, &revkey)) {
537
append_ref(av, &revkey, 0);
538
return;
539
}
@@ -836,7 +836,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
836
die(Q_("cannot handle more than %d rev.",
837
"cannot handle more than %d revs.",
838
MAX_REVS), MAX_REVS);
839
- if (get_oid(ref_name[num_rev], &revkey))
839
+ if (repo_get_oid(the_repository, ref_name[num_rev], &revkey))
840
die(_("'%s' is not a valid ref."), ref_name[num_rev]);
841
commit = lookup_commit_reference(the_repository, &revkey);
842
if (!commit)
builtin/show-ref.c
+2
-2
@@ -33,7 +33,7 @@ static void show_one(const char *refname, const struct object_id *oid)
33
if (quiet)
34
return;
35
36
- hex = find_unique_abbrev(oid, abbrev);
36
+ hex = repo_find_unique_abbrev(the_repository, oid, abbrev);
37
if (hash_only)
38
printf("%s\n", hex);
39
else
@@ -43,7 +43,7 @@ static void show_one(const char *refname, const struct object_id *oid)
43
return;
44
45
if (!peel_iterated_oid(oid, &peeled)) {
46
- hex = find_unique_abbrev(&peeled, abbrev);
46
+ hex = repo_find_unique_abbrev(the_repository, &peeled, abbrev);
47
printf("%s %s^{}\n", hex, refname);
48
}
49
}
builtin/sparse-checkout.c
+1
-1
@@ -471,7 +471,7 @@ static int sparse_checkout_init(int argc, const char **argv, const char *prefix)
471
return update_working_directory(NULL);
472
}
473
474
- if (get_oid("HEAD", &oid)) {
474
+ if (repo_get_oid(the_repository, "HEAD", &oid)) {
475
FILE *fp;
476
477
/* assume we are in a fresh repo, but update the sparse-checkout file */
builtin/stash.c
+7
-6
@@ -201,7 +201,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
201
202
revision = info->revision.buf;
203
204
- if (get_oid(revision, &info->w_commit))
204
+ if (repo_get_oid(the_repository, revision, &info->w_commit))
205
return error(_("%s is not a valid reference"), revision);
206
207
assert_stash_like(info, revision);
@@ -231,7 +231,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
231
static int do_clear_stash(void)
232
{
233
struct object_id obj;
234
- if (get_oid(ref_stash, &obj))
234
+ if (repo_get_oid(the_repository, ref_stash, &obj))
235
return 0;
236
237
return delete_ref(NULL, ref_stash, &obj, 0);
@@ -1083,7 +1083,7 @@ static int check_changes_tracked_files(const struct pathspec *ps)
1083
int ret = 0;
1084
1085
/* No initial commit. */
1086
- if (get_oid("HEAD", &dummy))
1086
+ if (repo_get_oid(the_repository, "HEAD", &dummy))
1087
return -1;
1088
1089
if (repo_read_index(the_repository) < 0)
@@ -1355,7 +1355,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
1355
goto done;
1356
}
1357
1358
- if (get_oid("HEAD", &info->b_commit)) {
1358
+ if (repo_get_oid(the_repository, "HEAD", &info->b_commit)) {
1359
if (!quiet)
1360
fprintf_ln(stderr, _("You do not have "
1361
"the initial commit yet"));
@@ -1373,8 +1373,9 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
1373
branch_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
1374
if (flags & REF_ISSYMREF)
1375
skip_prefix(branch_ref, "refs/heads/", &branch_name);
1376
- head_short_sha1 = find_unique_abbrev(&head_commit->object.oid,
1377
- DEFAULT_ABBREV);
1376
+ head_short_sha1 = repo_find_unique_abbrev(the_repository,
1377
+ &head_commit->object.oid,
1378
+ DEFAULT_ABBREV);
1379
strbuf_addf(&msg, "%s: %s ", branch_name, head_short_sha1);
1380
pp_commit_easy(CMIT_FMT_ONELINE, head_commit, &msg);
1381
builtin/submodule--helper.c
+2
-2
@@ -1174,7 +1174,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
1174
if (!summary_limit)
1175
return 0;
1176
1177
- if (!get_oid(argc ? argv[0] : "HEAD", &head_oid)) {
1177
+ if (!repo_get_oid(the_repository, argc ? argv[0] : "HEAD", &head_oid)) {
1178
if (argc) {
1179
argv++;
1180
argc--;
@@ -1187,7 +1187,7 @@ static int module_summary(int argc, const char **argv, const char *prefix)
1187
argc--;
1188
}
1189
} else {
1190
- if (get_oid("HEAD", &head_oid))
1190
+ if (repo_get_oid(the_repository, "HEAD", &head_oid))
1191
die(_("could not fetch a revision for HEAD"));
1192
}
1193
builtin/tag.c
+3
-3
@@ -137,7 +137,7 @@ static int delete_tags(const char **argv)
137
if (!ref_exists(name))
138
printf(_("Deleted tag '%s' (was %s)\n"),
139
item->string + 10,
140
- find_unique_abbrev(oid, DEFAULT_ABBREV));
140
+ repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
141
142
free(oid);
143
}
@@ -593,7 +593,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
593
if (argc > 2)
594
die(_("too many arguments"));
595
596
- if (get_oid(object_ref, &object))
596
+ if (repo_get_oid(the_repository, object_ref, &object))
597
die(_("Failed to resolve '%s' as a valid ref."), object_ref);
598
599
if (strbuf_check_tag_ref(&ref, tag))
@@ -634,7 +634,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
634
ref_transaction_free(transaction);
635
if (force && !is_null_oid(&prev) && !oideq(&prev, &object))
636
printf(_("Updated tag '%s' (was %s)\n"), tag,
637
- find_unique_abbrev(&prev, DEFAULT_ABBREV));
637
+ repo_find_unique_abbrev(the_repository, &prev, DEFAULT_ABBREV));
638
639
cleanup:
640
ref_sorting_release(sorting);
builtin/unpack-file.c
+1
-1
@@ -29,7 +29,7 @@ int cmd_unpack_file(int argc, const char **argv, const char *prefix)
29
30
if (argc != 2 || !strcmp(argv[1], "-h"))
31
usage("git unpack-file <blob>");
32
- if (get_oid(argv[1], &oid))
32
+ if (repo_get_oid(the_repository, argv[1], &oid))
33
die("Not a valid object name %s", argv[1]);
34
35
git_config(git_default_config, NULL);
builtin/update-ref.c
+4
-4
@@ -116,7 +116,7 @@ static int parse_next_oid(const char **next, const char *end,
116
(*next)++;
117
*next = parse_arg(*next, &arg);
118
if (arg.len) {
119
- if (get_oid(arg.buf, oid))
119
+ if (repo_get_oid(the_repository, arg.buf, oid))
120
goto invalid;
121
} else {
122
/* Without -z, an empty value means all zeros: */
@@ -134,7 +134,7 @@ static int parse_next_oid(const char **next, const char *end,
134
*next += arg.len;
135
136
if (arg.len) {
137
- if (get_oid(arg.buf, oid))
137
+ if (repo_get_oid(the_repository, arg.buf, oid))
138
goto invalid;
139
} else if (flags & PARSE_SHA1_ALLOW_EMPTY) {
140
/* With -z, treat an empty value as all zeros: */
@@ -549,7 +549,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
549
refname = argv[0];
550
value = argv[1];
551
oldval = argv[2];
552
- if (get_oid(value, &oid))
552
+ if (repo_get_oid(the_repository, value, &oid))
553
die("%s: not a valid SHA1", value);
554
}
555
@@ -560,7 +560,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
560
* must not already exist:
561
*/
562
oidclr(&oldoid);
563
- else if (get_oid(oldval, &oldoid))
563
+ else if (repo_get_oid(the_repository, oldval, &oldoid))
564
die("%s: not a valid old SHA1", oldval);
565
}
566
builtin/verify-commit.c
+1
-1
@@ -39,7 +39,7 @@ static int verify_commit(const char *name, unsigned flags)
39
struct object_id oid;
40
struct object *obj;
41
42
- if (get_oid(name, &oid))
42
+ if (repo_get_oid(the_repository, name, &oid))
43
return error("commit '%s' not found.", name);
44
45
obj = parse_object(the_repository, &oid);
builtin/verify-tag.c
+1
-1
@@ -60,7 +60,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
60
struct object_id oid;
61
const char *name = argv[i++];
62
63
- if (get_oid(name, &oid)) {
63
+ if (repo_get_oid(the_repository, name, &oid)) {
64
had_error = !!error("tag '%s' not found.", name);
65
continue;
66
}
builtin/worktree.c
+4
-4
@@ -552,7 +552,7 @@ static void print_preparing_worktree_line(int detach,
552
else
553
fprintf_ln(stderr, _("Preparing worktree (resetting branch '%s'; was at %s)"),
554
new_branch,
555
- find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
555
+ repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
556
} else if (new_branch) {
557
fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch);
558
} else {
@@ -566,7 +566,7 @@ static void print_preparing_worktree_line(int detach,
566
if (!commit)
567
die(_("invalid reference: %s"), branch);
568
fprintf_ln(stderr, _("Preparing worktree (detached HEAD %s)"),
569
- find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
569
+ repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV));
570
}
571
strbuf_release(&s);
572
}
@@ -756,7 +756,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)
756
strbuf_addstr(&sb, "(bare)");
757
else {
758
strbuf_addf(&sb, "%-*s ", abbrev_len,
759
- find_unique_abbrev(&wt->head_oid, DEFAULT_ABBREV));
759
+ repo_find_unique_abbrev(the_repository, &wt->head_oid, DEFAULT_ABBREV));
760
if (wt->is_detached)
761
strbuf_addstr(&sb, "(detached HEAD)");
762
else if (wt->head_ref) {
@@ -793,7 +793,7 @@ static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)
793
794
if (path_len > *maxlen)
795
*maxlen = path_len;
796
- sha1_len = strlen(find_unique_abbrev(&wt[i]->head_oid, *abbrev));
796
+ sha1_len = strlen(repo_find_unique_abbrev(the_repository, &wt[i]->head_oid, *abbrev));
797
if (sha1_len > *abbrev)
798
*abbrev = sha1_len;
799
}
cache.h
-15
@@ -1211,9 +1211,7 @@ void check_repository_format(struct repository_format *fmt);
1211
* reentrant, as it calls into other non-reentrant git code.
1212
*/
1213
const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
1214
-#define find_unique_abbrev(oid, len) repo_find_unique_abbrev(the_repository, oid, len)
1214
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
1216
-#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
1215
1216
/* set default permissions by passing mode arguments to open(2) */
1217
int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
@@ -1488,17 +1486,8 @@ enum get_oid_result get_oid_with_context(struct repository *repo, const char *st
1486
unsigned flags, struct object_id *oid,
1487
struct object_context *oc);
1488
1491
-#define get_oid(str, oid) repo_get_oid(the_repository, str, oid)
1492
-#define get_oid_commit(str, oid) repo_get_oid_commit(the_repository, str, oid)
1493
-#define get_oid_committish(str, oid) repo_get_oid_committish(the_repository, str, oid)
1494
-#define get_oid_tree(str, oid) repo_get_oid_tree(the_repository, str, oid)
1495
-#define get_oid_treeish(str, oid) repo_get_oid_treeish(the_repository, str, oid)
1496
-#define get_oid_blob(str, oid) repo_get_oid_blob(the_repository, str, oid)
1497
-#define get_oid_mb(str, oid) repo_get_oid_mb(the_repository, str, oid)
1498
-
1489
typedef int each_abbrev_fn(const struct object_id *oid, void *);
1490
int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
1501
-#define for_each_abbrev(prefix, fn, data) repo_for_each_abbrev(the_repository, prefix, fn, data)
1491
1492
int set_disambiguate_hint_config(const char *var, const char *value);
1493
@@ -1608,8 +1597,6 @@ int repo_interpret_branch_name(struct repository *r,
1597
const char *str, int len,
1598
struct strbuf *buf,
1599
const struct interpret_branch_name_options *options);
1611
-#define interpret_branch_name(str, len, buf, options) \
1612
- repo_interpret_branch_name(the_repository, str, len, buf, options)
1600
1601
int validate_headref(const char *ref);
1602
@@ -1629,8 +1616,6 @@ void *read_object_with_reference(struct repository *r,
1616
struct object *repo_peel_to_type(struct repository *r,
1617
const char *name, int namelen,
1618
struct object *o, enum object_type);
1632
-#define peel_to_type(name, namelen, obj, type) \
1633
- repo_peel_to_type(the_repository, name, namelen, obj, type)
1619
1620
#define IDENT_STRICT 1
1621
#define IDENT_NO_DATE 2
checkout.c
+1
-1
@@ -23,7 +23,7 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
23
memset(&query, 0, sizeof(struct refspec_item));
24
query.src = cb->src_ref;
25
if (remote_find_tracking(remote, &query) ||
26
- get_oid(query.dst, cb->dst_oid)) {
26
+ repo_get_oid(the_repository, query.dst, cb->dst_oid)) {
27
free(query.dst);
28
return 0;
29
}
combine-diff.c
+3
-3
@@ -948,11 +948,11 @@ static void show_combined_header(struct combine_diff_path *elem,
948
"", elem->path, line_prefix, c_meta, c_reset);
949
printf("%s%sindex ", line_prefix, c_meta);
950
for (i = 0; i < num_parent; i++) {
951
- abb = find_unique_abbrev(&elem->parent[i].oid,
952
- abbrev);
951
+ abb = repo_find_unique_abbrev(the_repository,
952
+ &elem->parent[i].oid, abbrev);
953
printf("%s%s", i ? "," : "", abb);
954
}
955
- abb = find_unique_abbrev(&elem->oid, abbrev);
955
+ abb = repo_find_unique_abbrev(the_repository, &elem->oid, abbrev);
956
printf("..%s%s\n", abb, c_reset);
957
958
if (mode_differs) {
commit.c
+6
-4
@@ -80,7 +80,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
80
struct object_id oid;
81
struct commit *commit;
82
83
- if (get_oid_committish(name, &oid))
83
+ if (repo_get_oid_committish(the_repository, name, &oid))
84
return NULL;
85
commit = lookup_commit_reference(the_repository, &oid);
86
if (parse_commit(commit))
@@ -1271,7 +1271,8 @@ void verify_merge_signature(struct commit *commit, int verbosity,
1271
1272
ret = check_commit_signature(commit, &signature_check);
1273
1274
- find_unique_abbrev_r(hex, &commit->object.oid, DEFAULT_ABBREV);
1274
+ repo_find_unique_abbrev_r(the_repository, hex, &commit->object.oid,
1275
+ DEFAULT_ABBREV);
1276
switch (signature_check.result) {
1277
case 'G':
1278
if (ret || (check_trust && signature_check.trust_level < TRUST_MARGINAL))
@@ -1632,10 +1633,11 @@ struct commit *get_merge_parent(const char *name)
1633
struct object *obj;
1634
struct commit *commit;
1635
struct object_id oid;
1635
- if (get_oid(name, &oid))
1636
+ if (repo_get_oid(the_repository, name, &oid))
1637
return NULL;
1638
obj = parse_object(the_repository, &oid);
1638
- commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
1639
+ commit = (struct commit *)repo_peel_to_type(the_repository, name, 0,
1640
+ obj, OBJ_COMMIT);
1641
if (commit && !merge_remote_util(commit))
1642
set_merge_remote_desc(commit, name, obj);
1643
return commit;
contrib/coccinelle/the_repository.cocci
new
+44
@@ -0,0 +1,44 @@
1
+// Fully migrated "the_repository" additions
2
+@@
3
+@@
4
+(
5
+// cache.h
6
+- get_oid
7
++ repo_get_oid
8
+|
9
+- get_oid_commit
10
++ repo_get_oid_commit
11
+|
12
+- get_oid_committish
13
++ repo_get_oid_committish
14
+|
15
+- get_oid_tree
16
++ repo_get_oid_tree
17
+|
18
+- get_oid_treeish
19
++ repo_get_oid_treeish
20
+|
21
+- get_oid_blob
22
++ repo_get_oid_blob
23
+|
24
+- get_oid_mb
25
++ repo_get_oid_mb
26
+|
27
+- find_unique_abbrev
28
++ repo_find_unique_abbrev
29
+|
30
+- find_unique_abbrev_r
31
++ repo_find_unique_abbrev_r
32
+|
33
+- for_each_abbrev
34
++ repo_for_each_abbrev
35
+|
36
+- interpret_branch_name
37
++ repo_interpret_branch_name
38
+|
39
+- peel_to_type
40
++ repo_peel_to_type
41
+)
42
+ (
43
++ the_repository,
44
+ ...)
contrib/coccinelle/the_repository.pending.cocci
-37
@@ -5,44 +5,7 @@
5
@@
6
@@
7
(
8
-// cache.h
9
-- get_oid
10
-+ repo_get_oid
11
-|
12
-- get_oid_commit
13
-+ repo_get_oid_commit
14
-|
15
-- get_oid_committish
16
-+ repo_get_oid_committish
17
-|
18
-- get_oid_tree
19
-+ repo_get_oid_tree
20
-|
21
-- get_oid_treeish
22
-+ repo_get_oid_treeish
23
-|
24
-- get_oid_blob
25
-+ repo_get_oid_blob
26
-|
27
-- get_oid_mb
28
-+ repo_get_oid_mb
29
-|
30
-- find_unique_abbrev
31
-+ repo_find_unique_abbrev
32
-|
33
-- find_unique_abbrev_r
34
-+ repo_find_unique_abbrev_r
35
-|
36
-- for_each_abbrev
37
-+ repo_for_each_abbrev
38
-|
39
-- interpret_branch_name
40
-+ repo_interpret_branch_name
41
-|
42
-- peel_to_type
43
-+ repo_peel_to_type
8
// commit-reach.h
45
-|
9
- get_merge_bases
10
+ repo_get_merge_bases
11
|
diff-lib.c
+1
-1
@@ -581,7 +581,7 @@ void diff_get_merge_base(const struct rev_info *revs, struct object_id *mb)
581
if (revs->pending.nr == 1) {
582
struct object_id oid;
583
584
- if (get_oid("HEAD", &oid))
584
+ if (repo_get_oid(the_repository, "HEAD", &oid))
585
die(_("unable to get HEAD"));
586
587
mb_child[1] = lookup_commit_reference(the_repository, &oid);
diff.c
+2
-2
@@ -4351,7 +4351,7 @@ static int similarity_index(struct diff_filepair *p)
4351
static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)
4352
{
4353
if (startup_info->have_repository)
4354
- return find_unique_abbrev(oid, abbrev);
4354
+ return repo_find_unique_abbrev(the_repository, oid, abbrev);
4355
else {
4356
char *hex = oid_to_hex(oid);
4357
if (abbrev < 0)
@@ -4988,7 +4988,7 @@ static int diff_opt_find_object(const struct option *option,
4988
struct object_id oid;
4989
4990
BUG_ON_OPT_NEG(unset);
4991
- if (get_oid(arg, &oid))
4991
+ if (repo_get_oid(the_repository, arg, &oid))
4992
return error(_("unable to resolve '%s'"), arg);
4993
4994
if (!opt->objfind)
fmt-merge-msg.c
+3
-1
@@ -605,7 +605,9 @@ static void find_merge_parents(struct merge_parents *result,
605
* util field yet.
606
*/
607
obj = parse_object(the_repository, &oid);
608
- parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT);
608
+ parent = (struct commit *)repo_peel_to_type(the_repository,
609
+ NULL, 0, obj,
610
+ OBJ_COMMIT);
611
if (!parent)
612
continue;
613
commit_list_insert(parent, &parents);
log-tree.c
+9
-6
@@ -233,7 +233,8 @@ static void show_parents(struct commit *commit, int abbrev, FILE *file)
233
struct commit_list *p;
234
for (p = commit->parents; p ; p = p->next) {
235
struct commit *parent = p->item;
236
- fprintf(file, " %s", find_unique_abbrev(&parent->object.oid, abbrev));
236
+ fprintf(file, " %s",
237
+ repo_find_unique_abbrev(the_repository, &parent->object.oid, abbrev));
238
}
239
}
240
@@ -241,7 +242,8 @@ static void show_children(struct rev_info *opt, struct commit *commit, int abbre
242
{
243
struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
244
for ( ; p; p = p->next) {
244
- fprintf(opt->diffopt.file, " %s", find_unique_abbrev(&p->item->object.oid, abbrev));
245
+ fprintf(opt->diffopt.file, " %s",
246
+ repo_find_unique_abbrev(the_repository, &p->item->object.oid, abbrev));
247
}
248
}
249
@@ -644,7 +646,8 @@ void show_log(struct rev_info *opt)
646
647
if (!opt->graph)
648
put_revision_mark(opt, commit);
647
- fputs(find_unique_abbrev(&commit->object.oid, abbrev_commit), opt->diffopt.file);
649
+ fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, abbrev_commit),
650
+ opt->diffopt.file);
651
if (opt->print_parents)
652
show_parents(commit, abbrev_commit, opt->diffopt.file);
653
if (opt->children.name)
@@ -706,8 +709,8 @@ void show_log(struct rev_info *opt)
709
710
if (!opt->graph)
711
put_revision_mark(opt, commit);
709
- fputs(find_unique_abbrev(&commit->object.oid,
710
- abbrev_commit),
712
+ fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid,
713
+ abbrev_commit),
714
opt->diffopt.file);
715
if (opt->print_parents)
716
show_parents(commit, abbrev_commit, opt->diffopt.file);
@@ -715,7 +718,7 @@ void show_log(struct rev_info *opt)
718
show_children(opt, commit, abbrev_commit);
719
if (parent)
720
fprintf(opt->diffopt.file, " (from %s)",
718
- find_unique_abbrev(&parent->object.oid, abbrev_commit));
721
+ repo_find_unique_abbrev(the_repository, &parent->object.oid, abbrev_commit));
722
fputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);
723
show_decorations(opt, commit);
724
if (opt->commit_format == CMIT_FMT_ONELINE) {
mailmap.c
+1
-1
@@ -213,7 +213,7 @@ static int read_mailmap_blob(struct string_list *map, const char *name)
213
214
if (!name)
215
return 0;
216
- if (get_oid(name, &oid) < 0)
216
+ if (repo_get_oid(the_repository, name, &oid) < 0)
217
return 0;
218
219
buf = read_object_file(&oid, &type, &size);
notes-merge.c
+1
-1
@@ -566,7 +566,7 @@ int notes_merge(struct notes_merge_options *o,
566
trace_printf("\tlocal commit: %.7s\n", oid_to_hex(&local_oid));
567
568
/* Dereference o->remote_ref into remote_oid */
569
- if (get_oid(o->remote_ref, &remote_oid)) {
569
+ if (repo_get_oid(the_repository, o->remote_ref, &remote_oid)) {
570
/*
571
* Failed to get remote_oid. If o->remote_ref looks like an
572
* unborn ref, perform the merge using an empty notes tree.
notes.c
+3
-3
@@ -944,7 +944,7 @@ void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
944
for_each_glob_ref(string_list_add_one_ref, glob, list);
945
} else {
946
struct object_id oid;
947
- if (get_oid(glob, &oid))
947
+ if (repo_get_oid(the_repository, glob, &oid))
948
warning("notes ref %s is invalid", glob);
949
if (!unsorted_string_list_has_string(list, glob))
950
string_list_append(list, glob);
@@ -1021,7 +1021,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
1021
t->dirty = 0;
1022
1023
if (flags & NOTES_INIT_EMPTY || !notes_ref ||
1024
- get_oid_treeish(notes_ref, &object_oid))
1024
+ repo_get_oid_treeish(the_repository, notes_ref, &object_oid))
1025
return;
1026
if (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, &object_oid))
1027
die("Cannot use notes ref %s", notes_ref);
@@ -1348,7 +1348,7 @@ void expand_loose_notes_ref(struct strbuf *sb)
1348
{
1349
struct object_id object;
1350
1351
- if (get_oid(sb->buf, &object)) {
1351
+ if (repo_get_oid(the_repository, sb->buf, &object)) {
1352
/* fallback to expand_notes_ref */
1353
expand_notes_ref(sb);
1354
}
object-name.c
+3
-2
@@ -1666,7 +1666,8 @@ void strbuf_branchname(struct strbuf *sb, const char *name, unsigned allowed)
1666
struct interpret_branch_name_options options = {
1667
.allowed = allowed
1668
};
1669
- int used = interpret_branch_name(name, len, sb, &options);
1669
+ int used = repo_interpret_branch_name(the_repository, name, len, sb,
1670
+ &options);
1671
1672
if (used < 0)
1673
used = 0;
@@ -1719,7 +1720,7 @@ int get_oidf(struct object_id *oid, const char *fmt, ...)
1720
strbuf_vaddf(&sb, fmt, ap);
1721
va_end(ap);
1722
1722
- ret = get_oid(sb.buf, oid);
1723
+ ret = repo_get_oid(the_repository, sb.buf, oid);
1724
strbuf_release(&sb);
1725
1726
return ret;
parse-options-cb.c
+4
-4
@@ -91,7 +91,7 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset)
91
92
if (!arg)
93
return -1;
94
- if (get_oid(arg, &oid))
94
+ if (repo_get_oid(the_repository, arg, &oid))
95
return error("malformed object name %s", arg);
96
commit = lookup_commit_reference(the_repository, &oid);
97
if (!commit)
@@ -110,7 +110,7 @@ int parse_opt_commit(const struct option *opt, const char *arg, int unset)
110
111
if (!arg)
112
return -1;
113
- if (get_oid(arg, &oid))
113
+ if (repo_get_oid(the_repository, arg, &oid))
114
return error("malformed object name %s", arg);
115
commit = lookup_commit_reference(the_repository, &oid);
116
if (!commit)
@@ -129,7 +129,7 @@ int parse_opt_object_name(const struct option *opt, const char *arg, int unset)
129
}
130
if (!arg)
131
return -1;
132
- if (get_oid(arg, &oid))
132
+ if (repo_get_oid(the_repository, arg, &oid))
133
return error(_("malformed object name '%s'"), arg);
134
oid_array_append(opt->value, &oid);
135
return 0;
@@ -146,7 +146,7 @@ int parse_opt_object_id(const struct option *opt, const char *arg, int unset)
146
}
147
if (!arg)
148
return -1;
149
- if (get_oid(arg, &oid))
149
+ if (repo_get_oid(the_repository, arg, &oid))
150
return error(_("malformed object name '%s'"), arg);
151
*target = oid;
152
return 0;
range-diff.c
+4
-4
@@ -94,7 +94,7 @@ static int read_patches(const char *range, struct string_list *list,
94
strbuf_reset(&buf);
95
}
96
CALLOC_ARRAY(util, 1);
97
- if (get_oid(p, &util->oid)) {
97
+ if (repo_get_oid(the_repository, p, &util->oid)) {
98
error(_("could not parse commit '%s'"), p);
99
FREE_AND_NULL(util);
100
string_list_clear(list, 1);
@@ -390,7 +390,7 @@ static void output_pair_header(struct diff_options *diffopt,
390
391
if (!dashes->len)
392
strbuf_addchars(dashes, '-',
393
- strlen(find_unique_abbrev(oid, abbrev)));
393
+ strlen(repo_find_unique_abbrev(the_repository, oid, abbrev)));
394
395
if (!b_util) {
396
color = color_old;
@@ -412,7 +412,7 @@ static void output_pair_header(struct diff_options *diffopt,
412
strbuf_addf(buf, "%*s: %s ", patch_no_width, "-", dashes->buf);
413
else
414
strbuf_addf(buf, "%*d: %s ", patch_no_width, a_util->i + 1,
415
- find_unique_abbrev(&a_util->oid, abbrev));
415
+ repo_find_unique_abbrev(the_repository, &a_util->oid, abbrev));
416
417
if (status == '!')
418
strbuf_addf(buf, "%s%s", color_reset, color);
@@ -424,7 +424,7 @@ static void output_pair_header(struct diff_options *diffopt,
424
strbuf_addf(buf, " %*s: %s", patch_no_width, "-", dashes->buf);
425
else
426
strbuf_addf(buf, " %*d: %s", patch_no_width, b_util->i + 1,
427
- find_unique_abbrev(&b_util->oid, abbrev));
427
+ repo_find_unique_abbrev(the_repository, &b_util->oid, abbrev));
428
429
commit = lookup_commit_reference(the_repository, oid);
430
if (commit) {
read-cache.c
+1
-1
@@ -2628,7 +2628,7 @@ int repo_index_has_changes(struct repository *repo,
2628
2629
if (tree)
2630
cmp = tree->object.oid;
2631
- if (tree || !get_oid_tree("HEAD", &cmp)) {
2631
+ if (tree || !repo_get_oid_tree(the_repository, "HEAD", &cmp)) {
2632
struct diff_options opt;
2633
2634
repo_diff_setup(repo, &opt);
rebase-interactive.c
+1
-1
@@ -187,7 +187,7 @@ int todo_list_check(struct todo_list *old_todo, struct todo_list *new_todo)
187
struct commit *commit = item->commit;
188
if (commit && !*commit_seen_at(&commit_seen, commit)) {
189
strbuf_addf(&missing, " - %s %.*s\n",
190
- find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV),
190
+ repo_find_unique_abbrev(the_repository, &commit->object.oid, DEFAULT_ABBREV),
191
item->arg_len,
192
todo_item_get_arg(old_todo, item));
193
*commit_seen_at(&commit_seen, commit) = 1;
ref-filter.c
+5
-3
@@ -1075,9 +1075,11 @@ static const char *do_grab_oid(const char *field, const struct object_id *oid,
1075
case O_FULL:
1076
return oid_to_hex(oid);
1077
case O_LENGTH:
1078
- return find_unique_abbrev(oid, atom->u.oid.length);
1078
+ return repo_find_unique_abbrev(the_repository, oid,
1079
+ atom->u.oid.length);
1080
case O_SHORT:
1080
- return find_unique_abbrev(oid, DEFAULT_ABBREV);
1081
+ return repo_find_unique_abbrev(the_repository, oid,
1082
+ DEFAULT_ABBREV);
1083
default:
1084
BUG("unknown %%(%s) option", field);
1085
}
@@ -2765,7 +2767,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
2767
2768
BUG_ON_OPT_NEG(unset);
2769
2768
- if (get_oid(arg, &oid))
2770
+ if (repo_get_oid(the_repository, arg, &oid))
2771
die(_("malformed object name %s"), arg);
2772
2773
merge_commit = lookup_commit_reference_gently(the_repository, &oid, 0);
remote.c
+3
-3
@@ -1163,7 +1163,7 @@ static int try_explicit_object_name(const char *name,
1163
return 0;
1164
}
1165
1166
- if (get_oid(name, &oid))
1166
+ if (repo_get_oid(the_repository, name, &oid))
1167
return -1;
1168
1169
if (match) {
@@ -1251,7 +1251,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,
1251
if (!advice_enabled(ADVICE_PUSH_UNQUALIFIED_REF_NAME))
1252
return;
1253
1254
- if (get_oid(matched_src_name, &oid))
1254
+ if (repo_get_oid(the_repository, matched_src_name, &oid))
1255
BUG("'%s' is not a valid object, "
1256
"match_explicit_lhs() should catch this!",
1257
matched_src_name);
@@ -2505,7 +2505,7 @@ static int parse_push_cas_option(struct push_cas_option *cas, const char *arg, i
2505
entry->use_tracking = 1;
2506
else if (!colon[1])
2507
oidclr(&entry->expect);
2508
- else if (get_oid(colon + 1, &entry->expect))
2508
+ else if (repo_get_oid(the_repository, colon + 1, &entry->expect))
2509
return error(_("cannot parse expected object name '%s'"),
2510
colon + 1);
2511
return 0;
reset.c
+2
-2
@@ -38,7 +38,7 @@ static int update_refs(const struct reset_head_opts *opts,
38
prefix_len = msg.len;
39
40
if (update_orig_head) {
41
- if (!get_oid("ORIG_HEAD", &oid_old_orig))
41
+ if (!repo_get_oid(the_repository, "ORIG_HEAD", &oid_old_orig))
42
old_orig = &oid_old_orig;
43
if (head) {
44
if (!reflog_orig_head) {
@@ -106,7 +106,7 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
106
goto leave_reset_head;
107
}
108
109
- if (!get_oid("HEAD", &head_oid)) {
109
+ if (!repo_get_oid(the_repository, "HEAD", &head_oid)) {
110
head = &head_oid;
111
} else if (!oid || !reset_hard) {
112
ret = error(_("could not determine HEAD revision"));
revision.c
+6
-5
@@ -324,7 +324,8 @@ static void add_pending_object_with_path(struct rev_info *revs,
324
if (revs->reflog_info && obj->type == OBJ_COMMIT) {
325
struct strbuf buf = STRBUF_INIT;
326
size_t namelen = strlen(name);
327
- int len = interpret_branch_name(name, namelen, &buf, &options);
327
+ int len = repo_interpret_branch_name(the_repository, name,
328
+ namelen, &buf, &options);
329
330
if (0 < len && len < namelen && buf.len)
331
strbuf_addstr(&buf, name + len);
@@ -354,7 +355,7 @@ void add_head_to_pending(struct rev_info *revs)
355
{
356
struct object_id oid;
357
struct object *obj;
357
- if (get_oid("HEAD", &oid))
358
+ if (repo_get_oid(the_repository, "HEAD", &oid))
359
return;
360
obj = parse_object(revs->repo, &oid);
361
if (!obj)
@@ -1867,7 +1868,7 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
1868
flags ^= UNINTERESTING | BOTTOM;
1869
arg++;
1870
}
1870
- if (get_oid_committish(arg, &oid))
1871
+ if (repo_get_oid_committish(the_repository, arg, &oid))
1872
return 0;
1873
while (1) {
1874
it = get_reference(revs, arg, &oid, 0);
@@ -1948,10 +1949,10 @@ static void prepare_show_merge(struct rev_info *revs)
1949
int i, prune_num = 1; /* counting terminating NULL */
1950
struct index_state *istate = revs->repo->index;
1951
1951
- if (get_oid("HEAD", &oid))
1952
+ if (repo_get_oid(the_repository, "HEAD", &oid))
1953
die("--merge without HEAD?");
1954
head = lookup_commit_or_die(&oid, "HEAD");
1954
- if (get_oid("MERGE_HEAD", &oid))
1955
+ if (repo_get_oid(the_repository, "MERGE_HEAD", &oid))
1956
die("--merge without MERGE_HEAD?");
1957
other = lookup_commit_or_die(&oid, "MERGE_HEAD");
1958
add_pending_object(revs, &head->object, "HEAD");
sequencer.c
+27
-24
@@ -419,7 +419,8 @@ struct commit_message {
419
420
static const char *short_commit_name(struct commit *commit)
421
{
422
- return find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV);
422
+ return repo_find_unique_abbrev(the_repository, &commit->object.oid,
423
+ DEFAULT_ABBREV);
424
}
425
426
static int get_message(struct commit *commit, struct commit_message *out)
@@ -561,7 +562,7 @@ static void update_abort_safety_file(void)
562
if (!file_exists(git_path_seq_dir()))
563
return;
564
564
- if (!get_oid("HEAD", &head))
565
+ if (!repo_get_oid(the_repository, "HEAD", &head))
566
write_file(git_path_abort_safety_file(), "%s", oid_to_hex(&head));
567
else
568
write_file(git_path_abort_safety_file(), "%s", "");
@@ -1406,7 +1407,7 @@ static int parse_head(struct repository *r, struct commit **head)
1407
struct commit *current_head;
1408
struct object_id oid;
1409
1409
- if (get_oid("HEAD", &oid)) {
1410
+ if (repo_get_oid(the_repository, "HEAD", &oid)) {
1411
current_head = NULL;
1412
} else {
1413
current_head = lookup_commit_reference(r, &oid);
@@ -1997,7 +1998,7 @@ static int update_squash_messages(struct repository *r,
1998
struct commit *head_commit;
1999
const char *head_message, *body;
2000
2000
- if (get_oid("HEAD", &head))
2001
+ if (repo_get_oid(the_repository, "HEAD", &head))
2002
return error(_("need a HEAD to fixup"));
2003
if (!(head_commit = lookup_commit_reference(r, &head)))
2004
return error(_("could not read HEAD"));
@@ -2067,7 +2068,7 @@ static void flush_rewritten_pending(void)
2068
FILE *out;
2069
2070
if (strbuf_read_file(&buf, rebase_path_rewritten_pending(), (GIT_MAX_HEXSZ + 1) * 2) > 0 &&
2070
- !get_oid("HEAD", &newoid) &&
2071
+ !repo_get_oid(the_repository, "HEAD", &newoid) &&
2072
(out = fopen_or_warn(rebase_path_rewritten_list(), "a"))) {
2073
char *bol = buf.buf, *eol;
2074
@@ -2152,7 +2153,7 @@ static int do_pick_commit(struct repository *r,
2153
if (write_index_as_tree(&head, r->index, r->index_file, 0, NULL))
2154
return error(_("your index file is unmerged."));
2155
} else {
2155
- unborn = get_oid("HEAD", &head);
2156
+ unborn = repo_get_oid(the_repository, "HEAD", &head);
2157
/* Do we want to generate a root commit? */
2158
if (is_pick_or_similar(command) && opts->have_squash_onto &&
2159
oideq(&head, &opts->squash_onto)) {
@@ -2606,7 +2607,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
2607
end_of_object_name = (char *) bol + strcspn(bol, " \t\n");
2608
saved = *end_of_object_name;
2609
*end_of_object_name = '\0';
2609
- status = get_oid(bol, &commit_oid);
2610
+ status = repo_get_oid(the_repository, bol, &commit_oid);
2611
if (status < 0)
2612
error(_("could not parse '%s'"), bol); /* return later */
2613
*end_of_object_name = saved;
@@ -3022,7 +3023,7 @@ static int read_populate_opts(struct replay_opts *opts)
3023
}
3024
3025
if (read_oneliner(&buf, rebase_path_squash_onto(), 0)) {
3025
- if (get_oid_committish(buf.buf, &opts->squash_onto) < 0) {
3026
+ if (repo_get_oid_committish(the_repository, buf.buf, &opts->squash_onto) < 0) {
3027
ret = error(_("unusable squash-onto"));
3028
goto done_rebase_i;
3029
}
@@ -3223,7 +3224,7 @@ static int rollback_is_safe(void)
3224
else
3225
die_errno(_("could not read '%s'"), git_path_abort_safety_file());
3226
3226
- if (get_oid("HEAD", &actual_head))
3227
+ if (repo_get_oid(the_repository, "HEAD", &actual_head))
3228
oidclr(&actual_head);
3229
3230
return oideq(&actual_head, &expected_head);
@@ -3534,7 +3535,7 @@ static int intend_to_amend(void)
3535
struct object_id head;
3536
char *p;
3537
3537
- if (get_oid("HEAD", &head))
3538
+ if (repo_get_oid(the_repository, "HEAD", &head))
3539
return error(_("cannot read HEAD"));
3540
3541
p = oid_to_hex(&head);
@@ -3700,7 +3701,7 @@ static int do_label(struct repository *r, const char *name, int len)
3701
if (!transaction) {
3702
error("%s", err.buf);
3703
ret = -1;
3703
- } else if (get_oid("HEAD", &head_oid)) {
3704
+ } else if (repo_get_oid(the_repository, "HEAD", &head_oid)) {
3705
error(_("could not read HEAD"));
3706
ret = -1;
3707
} else if (ref_transaction_update(transaction, ref_name.buf, &head_oid,
@@ -4456,7 +4457,7 @@ void create_autostash(struct repository *r, const char *path)
4457
if (capture_command(&stash, &buf, GIT_MAX_HEXSZ))
4458
die(_("Cannot autostash"));
4459
strbuf_trim_trailing_newline(&buf);
4459
- if (get_oid(buf.buf, &oid))
4460
+ if (repo_get_oid(the_repository, buf.buf, &oid))
4461
die(_("Unexpected stash response: '%s'"),
4462
buf.buf);
4463
strbuf_reset(&buf);
@@ -4581,7 +4582,7 @@ static int stopped_at_head(struct repository *r)
4582
struct commit *commit;
4583
struct commit_message message;
4584
4584
- if (get_oid("HEAD", &head) ||
4585
+ if (repo_get_oid(the_repository, "HEAD", &head) ||
4586
!(commit = lookup_commit(r, &head)) ||
4587
parse_commit(commit) || get_message(commit, &message))
4588
fprintf(stderr, _("Stopped at HEAD\n"));
@@ -4731,7 +4732,7 @@ static int pick_commits(struct repository *r,
4732
* otherwise we do not.
4733
*/
4734
if (item->command == TODO_REWORD &&
4734
- !get_oid("HEAD", &oid) &&
4735
+ !repo_get_oid(the_repository, "HEAD", &oid) &&
4736
(oideq(&item->commit->object.oid, &oid) ||
4737
(opts->have_squash_onto &&
4738
oideq(&opts->squash_onto, &oid))))
@@ -4820,7 +4821,7 @@ static int pick_commits(struct repository *r,
4821
struct object_id head, orig;
4822
int res;
4823
4823
- if (get_oid("HEAD", &head)) {
4824
+ if (repo_get_oid(the_repository, "HEAD", &head)) {
4825
res = error(_("cannot read HEAD"));
4826
cleanup_head_ref:
4827
strbuf_release(&head_ref);
@@ -4867,8 +4868,8 @@ cleanup_head_ref:
4868
log_tree_opt.disable_stdin = 1;
4869
4870
if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
4870
- !get_oid(buf.buf, &orig) &&
4871
- !get_oid("HEAD", &head)) {
4871
+ !repo_get_oid(the_repository, buf.buf, &orig) &&
4872
+ !repo_get_oid(the_repository, "HEAD", &head)) {
4873
diff_tree_oid(&orig, &head, "",
4874
&log_tree_opt.diffopt);
4875
log_tree_diff_flush(&log_tree_opt);
@@ -4960,7 +4961,7 @@ static int commit_staged_changes(struct repository *r,
4961
struct strbuf rev = STRBUF_INIT;
4962
struct object_id head, to_amend;
4963
4963
- if (get_oid("HEAD", &head))
4964
+ if (repo_get_oid(the_repository, "HEAD", &head))
4965
return error(_("cannot amend non-existing commit"));
4966
if (!read_oneliner(&rev, rebase_path_amend(), 0))
4967
return error(_("invalid file: '%s'"), rebase_path_amend());
@@ -5185,7 +5186,7 @@ int sequencer_pick_revisions(struct repository *r,
5186
if (!strlen(name))
5187
continue;
5188
5188
- if (!get_oid(name, &oid)) {
5189
+ if (!repo_get_oid(the_repository, name, &oid)) {
5190
if (!lookup_commit_reference_gently(r, &oid, 1)) {
5191
enum object_type type = oid_object_info(r,
5192
&oid,
@@ -5228,7 +5229,7 @@ int sequencer_pick_revisions(struct repository *r,
5229
if (walk_revs_populate_todo(&todo_list, opts) ||
5230
create_seq_dir(r) < 0)
5231
return -1;
5231
- if (get_oid("HEAD", &oid) && (opts->action == REPLAY_REVERT))
5232
+ if (repo_get_oid(the_repository, "HEAD", &oid) && (opts->action == REPLAY_REVERT))
5233
return error(_("can't revert as initial commit"));
5234
if (save_head(oid_to_hex(&oid)))
5235
return -1;
@@ -5360,7 +5361,8 @@ static const char *label_oid(struct object_id *oid, const char *label,
5361
strbuf_grow(&state->buf, GIT_MAX_HEXSZ);
5362
label = p = state->buf.buf;
5363
5363
- find_unique_abbrev_r(p, oid, default_abbrev);
5364
+ repo_find_unique_abbrev_r(the_repository, p, oid,
5365
+ default_abbrev);
5366
5367
/*
5368
* We may need to extend the abbreviated hash so that there is
@@ -6093,7 +6095,8 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
6095
struct object_id oid = onto->object.oid;
6096
int res;
6097
6096
- find_unique_abbrev_r(shortonto, &oid, DEFAULT_ABBREV);
6098
+ repo_find_unique_abbrev_r(the_repository, shortonto, &oid,
6099
+ DEFAULT_ABBREV);
6100
6101
if (buf->len == 0) {
6102
struct todo_item *item = append_new_todo(todo_list);
@@ -6369,8 +6372,8 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
6372
if (file_exists(git_path_seq_dir()))
6373
*whence = FROM_CHERRY_PICK_MULTI;
6374
if (file_exists(rebase_path()) &&
6372
- !get_oid("REBASE_HEAD", &rebase_head) &&
6373
- !get_oid("CHERRY_PICK_HEAD", &cherry_pick_head) &&
6375
+ !repo_get_oid(the_repository, "REBASE_HEAD", &rebase_head) &&
6376
+ !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &cherry_pick_head) &&
6377
oideq(&rebase_head, &cherry_pick_head))
6378
*whence = FROM_REBASE_PICK;
6379
else
submodule-config.c
+1
-1
@@ -535,7 +535,7 @@ static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
535
}
536
537
strbuf_addf(rev, "%s:.gitmodules", oid_to_hex(treeish_name));
538
- if (get_oid(rev->buf, gitmodules_oid) >= 0)
538
+ if (repo_get_oid(the_repository, rev->buf, gitmodules_oid) >= 0)
539
ret = 1;
540
541
return ret;
submodule.c
+4
-4
@@ -65,7 +65,7 @@ int is_writing_gitmodules_ok(void)
65
{
66
struct object_id oid;
67
return file_exists(GITMODULES_FILE) ||
68
- (get_oid(GITMODULES_INDEX, &oid) < 0 && get_oid(GITMODULES_HEAD, &oid) < 0);
68
+ (repo_get_oid(the_repository, GITMODULES_INDEX, &oid) < 0 && repo_get_oid(the_repository, GITMODULES_HEAD, &oid) < 0);
69
}
70
71
/*
@@ -1625,7 +1625,7 @@ get_fetch_task_from_changed(struct submodule_parallel_fetch *spf,
1625
if (!task->repo) {
1626
strbuf_addf(err, _("Could not access submodule '%s' at commit %s\n"),
1627
cs_data->path,
1628
- find_unique_abbrev(cs_data->super_oid, DEFAULT_ABBREV));
1628
+ repo_find_unique_abbrev(the_repository, cs_data->super_oid, DEFAULT_ABBREV));
1629
1630
fetch_task_release(task);
1631
free(task);
@@ -1636,8 +1636,8 @@ get_fetch_task_from_changed(struct submodule_parallel_fetch *spf,
1636
strbuf_addf(err,
1637
_("Fetching submodule %s%s at commit %s\n"),
1638
spf->prefix, task->sub->path,
1639
- find_unique_abbrev(cs_data->super_oid,
1640
- DEFAULT_ABBREV));
1639
+ repo_find_unique_abbrev(the_repository, cs_data->super_oid,
1640
+ DEFAULT_ABBREV));
1641
1642
spf->changed_count++;
1643
/*
t/helper/test-fast-rebase.c
+6
-4
@@ -25,7 +25,8 @@
25
26
static const char *short_commit_name(struct commit *commit)
27
{
28
- return find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV);
28
+ return repo_find_unique_abbrev(the_repository, &commit->object.oid,
29
+ DEFAULT_ABBREV);
30
}
31
32
static struct commit *peel_committish(const char *name)
@@ -33,10 +34,11 @@ static struct commit *peel_committish(const char *name)
34
struct object *obj;
35
struct object_id oid;
36
36
- if (get_oid(name, &oid))
37
+ if (repo_get_oid(the_repository, name, &oid))
38
return NULL;
39
obj = parse_object(the_repository, &oid);
39
- return (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
40
+ return (struct commit *)repo_peel_to_type(the_repository, name, 0, obj,
41
+ OBJ_COMMIT);
42
}
43
44
static char *get_author(const char *message)
@@ -119,7 +121,7 @@ int cmd__fast_rebase(int argc, const char **argv)
121
strbuf_addf(&branch_name, "refs/heads/%s", argv[4]);
122
123
/* Sanity check */
122
- if (get_oid("HEAD", &head))
124
+ if (repo_get_oid(the_repository, "HEAD", &head))
125
die(_("Cannot read HEAD"));
126
assert(oideq(&onto->object.oid, &head));
127
t/helper/test-match-trees.c
+2
-2
@@ -9,9 +9,9 @@ int cmd__match_trees(int ac, const char **av)
9
10
setup_git_directory();
11
12
- if (get_oid(av[1], &hash1))
12
+ if (repo_get_oid(the_repository, av[1], &hash1))
13
die("cannot parse %s as an object name", av[1]);
14
- if (get_oid(av[2], &hash2))
14
+ if (repo_get_oid(the_repository, av[2], &hash2))
15
die("cannot parse %s as an object name", av[2]);
16
one = parse_tree_indirect(&hash1);
17
if (!one)
t/helper/test-oidmap.c
+3
-3
@@ -49,7 +49,7 @@ int cmd__oidmap(int argc, const char **argv)
49
50
if (!strcmp("put", cmd) && p1 && p2) {
51
52
- if (get_oid(p1, &oid)) {
52
+ if (repo_get_oid(the_repository, p1, &oid)) {
53
printf("Unknown oid: %s\n", p1);
54
continue;
55
}
@@ -67,7 +67,7 @@ int cmd__oidmap(int argc, const char **argv)
67
68
} else if (!strcmp("get", cmd) && p1) {
69
70
- if (get_oid(p1, &oid)) {
70
+ if (repo_get_oid(the_repository, p1, &oid)) {
71
printf("Unknown oid: %s\n", p1);
72
continue;
73
}
@@ -80,7 +80,7 @@ int cmd__oidmap(int argc, const char **argv)
80
81
} else if (!strcmp("remove", cmd) && p1) {
82
83
- if (get_oid(p1, &oid)) {
83
+ if (repo_get_oid(the_repository, p1, &oid)) {
84
printf("Unknown oid: %s\n", p1);
85
continue;
86
}
t/helper/test-reach.c
+1
-1
@@ -57,7 +57,7 @@ int cmd__reach(int ac, const char **av)
57
if (buf.len < 3)
58
continue;
59
60
- if (get_oid_committish(buf.buf + 2, &oid))
60
+ if (repo_get_oid_committish(the_repository, buf.buf + 2, &oid))
61
die("failed to resolve %s", buf.buf + 2);
62
63
orig = parse_object(r, &oid);
t/helper/test-submodule-config.c
+1
-1
@@ -42,7 +42,7 @@ int cmd__submodule_config(int argc, const char **argv)
42
43
if (commit[0] == '\0')
44
oidclr(&commit_oid);
45
- else if (get_oid(commit, &commit_oid) < 0)
45
+ else if (repo_get_oid(the_repository, commit, &commit_oid) < 0)
46
die_usage(argc, argv, "Commit not found.");
47
48
if (lookup_name) {
tag.c
+2
-2
@@ -51,7 +51,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
51
return error("%s: cannot verify a non-tag object of type %s.",
52
name_to_report ?
53
name_to_report :
54
- find_unique_abbrev(oid, DEFAULT_ABBREV),
54
+ repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV),
55
type_name(type));
56
57
buf = read_object_file(oid, &type, &size);
@@ -59,7 +59,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
59
return error("%s: unable to read file.",
60
name_to_report ?
61
name_to_report :
62
- find_unique_abbrev(oid, DEFAULT_ABBREV));
62
+ repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV));
63
64
ret = run_gpg_verify(buf, size, flags);
65
transport-helper.c
+1
-1
@@ -1081,7 +1081,7 @@ static int push_refs_with_export(struct transport *transport,
1081
struct object_id oid;
1082
1083
private = apply_refspecs(&data->rs, ref->name);
1084
- if (private && !get_oid(private, &oid)) {
1084
+ if (private && !repo_get_oid(the_repository, private, &oid)) {
1085
strbuf_addf(&buf, "^%s", private);
1086
string_list_append_nodup(&revlist_args,
1087
strbuf_detach(&buf, NULL));
transport.c
+2
-1
@@ -776,7 +776,8 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count,
776
static int measure_abbrev(const struct object_id *oid, int sofar)
777
{
778
char hex[GIT_MAX_HEXSZ + 1];
779
- int w = find_unique_abbrev_r(hex, oid, DEFAULT_ABBREV);
779
+ int w = repo_find_unique_abbrev_r(the_repository, hex, oid,
780
+ DEFAULT_ABBREV);
781
782
return (w < sofar) ? sofar : w;
783
}
wt-status.c
+9
-9
@@ -1337,7 +1337,7 @@ static void abbrev_oid_in_line(struct strbuf *line)
1337
* it after abbreviation.
1338
*/
1339
strbuf_trim(split[1]);
1340
- if (!get_oid(split[1]->buf, &oid)) {
1340
+ if (!repo_get_oid(the_repository, split[1]->buf, &oid)) {
1341
strbuf_reset(split[1]);
1342
strbuf_add_unique_abbrev(split[1], &oid,
1343
DEFAULT_ABBREV);
@@ -1503,8 +1503,8 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
1503
else
1504
status_printf_ln(s, color,
1505
_("You are currently cherry-picking commit %s."),
1506
- find_unique_abbrev(&s->state.cherry_pick_head_oid,
1507
- DEFAULT_ABBREV));
1506
+ repo_find_unique_abbrev(the_repository, &s->state.cherry_pick_head_oid,
1507
+ DEFAULT_ABBREV));
1508
1509
if (s->hints) {
1510
if (has_unmerged(s))
@@ -1533,8 +1533,8 @@ static void show_revert_in_progress(struct wt_status *s,
1533
else
1534
status_printf_ln(s, color,
1535
_("You are currently reverting commit %s."),
1536
- find_unique_abbrev(&s->state.revert_head_oid,
1537
- DEFAULT_ABBREV));
1536
+ repo_find_unique_abbrev(the_repository, &s->state.revert_head_oid,
1537
+ DEFAULT_ABBREV));
1538
if (s->hints) {
1539
if (has_unmerged(s))
1540
status_printf_ln(s, color,
@@ -1676,9 +1676,9 @@ static void wt_status_get_detached_from(struct repository *r,
1676
state->detached_from = xstrdup(from);
1677
} else
1678
state->detached_from =
1679
- xstrdup(find_unique_abbrev(&cb.noid, DEFAULT_ABBREV));
1679
+ xstrdup(repo_find_unique_abbrev(the_repository, &cb.noid, DEFAULT_ABBREV));
1680
oidcpy(&state->detached_oid, &cb.noid);
1681
- state->detached_at = !get_oid("HEAD", &oid) &&
1681
+ state->detached_at = !repo_get_oid(the_repository, "HEAD", &oid) &&
1682
oideq(&oid, &state->detached_oid);
1683
1684
free(ref);
@@ -1769,13 +1769,13 @@ void wt_status_get_state(struct repository *r,
1769
} else if (wt_status_check_rebase(NULL, state)) {
1770
; /* all set */
1771
} else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
1772
- !get_oid("CHERRY_PICK_HEAD", &oid)) {
1772
+ !repo_get_oid(the_repository, "CHERRY_PICK_HEAD", &oid)) {
1773
state->cherry_pick_in_progress = 1;
1774
oidcpy(&state->cherry_pick_head_oid, &oid);
1775
}
1776
wt_status_check_bisect(NULL, state);
1777
if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") &&
1778
- !get_oid("REVERT_HEAD", &oid)) {
1778
+ !repo_get_oid(the_repository, "REVERT_HEAD", &oid)) {
1779
state->revert_in_progress = 1;
1780
oidcpy(&state->revert_head_oid, &oid);
1781
}