Skip to content

Commit 12cb1c1

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

17 files changed

+37
-27
lines changed

archive.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,11 @@ static void parse_treeish_arg(const char **argv,
456456
const char *colon = strchrnul(name, ':');
457457
int refnamelen = colon - name;
458458

459-
if (!dwim_ref(name, refnamelen, &oid, &ref, 0))
459+
if (!repo_dwim_ref(the_repository, name, refnamelen, &oid, &ref, 0))
460460
die(_("no such ref: %.*s"), refnamelen, name);
461461
} else {
462-
dwim_ref(name, strlen(name), &oid, &ref, 0);
462+
repo_dwim_ref(the_repository, name, strlen(name), &oid, &ref,
463+
0);
463464
}
464465

465466
if (repo_get_oid(the_repository, name, &oid))

branch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ static void dwim_branch_start(struct repository *r, const char *start_name,
541541
die(_("not a valid object name: '%s'"), start_name);
542542
}
543543

544-
switch (dwim_ref(start_name, strlen(start_name), &oid, &real_ref, 0)) {
544+
switch (repo_dwim_ref(the_repository, start_name, strlen(start_name),
545+
&oid, &real_ref, 0)) {
545546
case 0:
546547
/* Not branching from any existing branch */
547548
if (explicit_tracking)

builtin/checkout.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,8 @@ static void setup_branch_path(struct branch_info *branch)
703703
* If this is a ref, resolve it; otherwise, look up the OID for our
704704
* expression. Failure here is okay.
705705
*/
706-
if (!dwim_ref(branch->name, strlen(branch->name), &branch->oid, &branch->refname, 0))
706+
if (!repo_dwim_ref(the_repository, branch->name, strlen(branch->name),
707+
&branch->oid, &branch->refname, 0))
707708
repo_get_oid_committish(the_repository, branch->name, &branch->oid);
708709

709710
strbuf_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL);
@@ -1424,7 +1425,8 @@ static void die_expecting_a_branch(const struct branch_info *branch_info)
14241425
char *to_free;
14251426
int code;
14261427

1427-
if (dwim_ref(branch_info->name, strlen(branch_info->name), &oid, &to_free, 0) == 1) {
1428+
if (repo_dwim_ref(the_repository, branch_info->name,
1429+
strlen(branch_info->name), &oid, &to_free, 0) == 1) {
14281430
const char *ref = to_free;
14291431

14301432
if (skip_prefix(ref, "refs/tags/", &ref))

builtin/fast-export.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,8 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
918918
if (e->flags & UNINTERESTING)
919919
continue;
920920

921-
if (dwim_ref(e->name, strlen(e->name), &oid, &full_name, 0) != 1)
921+
if (repo_dwim_ref(the_repository, e->name, strlen(e->name),
922+
&oid, &full_name, 0) != 1)
922923
continue;
923924

924925
if (refspecs.nr) {

builtin/log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ static char *find_branch_name(struct rev_info *rev)
12041204
return NULL;
12051205
ref = rev->cmdline.rev[positive].name;
12061206
tip_oid = &rev->cmdline.rev[positive].item->oid;
1207-
if (dwim_ref(ref, strlen(ref), &branch_oid, &full_ref, 0) &&
1207+
if (repo_dwim_ref(the_repository, ref, strlen(ref), &branch_oid,
1208+
&full_ref, 0) &&
12081209
skip_prefix(full_ref, "refs/heads/", &v) &&
12091210
oideq(tip_oid, &branch_oid))
12101211
branch = xstrdup(v);

builtin/merge.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@ static void merge_name(const char *remote, struct strbuf *msg)
517517
if (!remote_head)
518518
die(_("'%s' does not point to a commit"), remote);
519519

520-
if (dwim_ref(remote, strlen(remote), &branch_head, &found_ref, 0) > 0) {
520+
if (repo_dwim_ref(the_repository, remote, strlen(remote), &branch_head,
521+
&found_ref, 0) > 0) {
521522
if (starts_with(found_ref, "refs/heads/")) {
522523
strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
523524
oid_to_hex(&branch_head), remote);

builtin/reset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
465465
char *ref = NULL;
466466
int err;
467467

468-
dwim_ref(rev, strlen(rev), &dummy, &ref, 0);
468+
repo_dwim_ref(the_repository, rev, strlen(rev),
469+
&dummy, &ref, 0);
469470
if (ref && !starts_with(ref, "refs/"))
470471
FREE_AND_NULL(ref);
471472

builtin/rev-parse.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
136136
struct object_id discard;
137137
char *full;
138138

139-
switch (dwim_ref(name, strlen(name), &discard, &full, 0)) {
139+
switch (repo_dwim_ref(the_repository, name,
140+
strlen(name), &discard, &full,
141+
0)) {
140142
case 0:
141143
/*
142144
* Not found -- not a ref. We could

builtin/show-branch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
746746
die(Q_("only %d entry can be shown at one time.",
747747
"only %d entries can be shown at one time.",
748748
MAX_REVS), MAX_REVS);
749-
if (!dwim_ref(*av, strlen(*av), &oid, &ref, 0))
749+
if (!repo_dwim_ref(the_repository, *av, strlen(*av), &oid,
750+
&ref, 0))
750751
die(_("no such ref %s"), *av);
751752

752753
/* Has the base been specified? */

builtin/stash.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
211211
end_of_rev = strchrnul(revision, '@');
212212
strbuf_add(&symbolic, revision, end_of_rev - revision);
213213

214-
ret = dwim_ref(symbolic.buf, symbolic.len, &dummy, &expanded_ref, 0);
214+
ret = repo_dwim_ref(the_repository, symbolic.buf, symbolic.len,
215+
&dummy, &expanded_ref, 0);
215216
strbuf_release(&symbolic);
216217
switch (ret) {
217218
case 0: /* Not found, but valid ref */

0 commit comments

Comments
 (0)