Skip to content

Commit 8c6e6b2

Browse files
committed
Revert "Merge branch 'ps/ref-peeled-tags' into next"
This reverts commit 8ac48a1, reversing changes made to 9ab444e.
1 parent 5ab9228 commit 8c6e6b2

Some content is hidden

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

66 files changed

+834
-783
lines changed

bisect.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -450,20 +450,21 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
450450
clear_commit_weight(&commit_weight);
451451
}
452452

453-
static int register_ref(const struct reference *ref, void *cb_data UNUSED)
453+
static int register_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
454+
int flags UNUSED, void *cb_data UNUSED)
454455
{
455456
struct strbuf good_prefix = STRBUF_INIT;
456457
strbuf_addstr(&good_prefix, term_good);
457458
strbuf_addstr(&good_prefix, "-");
458459

459-
if (!strcmp(ref->name, term_bad)) {
460+
if (!strcmp(refname, term_bad)) {
460461
free(current_bad_oid);
461462
current_bad_oid = xmalloc(sizeof(*current_bad_oid));
462-
oidcpy(current_bad_oid, ref->oid);
463-
} else if (starts_with(ref->name, good_prefix.buf)) {
464-
oid_array_append(&good_revs, ref->oid);
465-
} else if (starts_with(ref->name, "skip-")) {
466-
oid_array_append(&skipped_revs, ref->oid);
463+
oidcpy(current_bad_oid, oid);
464+
} else if (starts_with(refname, good_prefix.buf)) {
465+
oid_array_append(&good_revs, oid);
466+
} else if (starts_with(refname, "skip-")) {
467+
oid_array_append(&skipped_revs, oid);
467468
}
468469

469470
strbuf_release(&good_prefix);
@@ -1177,11 +1178,14 @@ int estimate_bisect_steps(int all)
11771178
return (e < 3 * x) ? n : n - 1;
11781179
}
11791180

1180-
static int mark_for_removal(const struct reference *ref, void *cb_data)
1181+
static int mark_for_removal(const char *refname,
1182+
const char *referent UNUSED,
1183+
const struct object_id *oid UNUSED,
1184+
int flag UNUSED, void *cb_data)
11811185
{
11821186
struct string_list *refs = cb_data;
1183-
char *bisect_ref = xstrfmt("refs/bisect%s", ref->name);
1184-
string_list_append(refs, bisect_ref);
1187+
char *ref = xstrfmt("refs/bisect%s", refname);
1188+
string_list_append(refs, ref);
11851189
return 0;
11861190
}
11871191

builtin/bisect.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,10 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
363363
return 0;
364364
}
365365

366-
static int inc_nr(const struct reference *ref UNUSED, void *cb_data)
366+
static int inc_nr(const char *refname UNUSED,
367+
const char *referent UNUSED,
368+
const struct object_id *oid UNUSED,
369+
int flag UNUSED, void *cb_data)
367370
{
368371
unsigned int *nr = (unsigned int *)cb_data;
369372
(*nr)++;
@@ -551,11 +554,12 @@ static int bisect_append_log_quoted(const char **argv)
551554
return res;
552555
}
553556

554-
static int add_bisect_ref(const struct reference *ref, void *cb)
557+
static int add_bisect_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
558+
int flags UNUSED, void *cb)
555559
{
556560
struct add_bisect_ref_data *data = cb;
557561

558-
add_pending_oid(data->revs, ref->name, ref->oid, data->object_flags);
562+
add_pending_oid(data->revs, refname, oid, data->object_flags);
559563

560564
return 0;
561565
}
@@ -1166,9 +1170,12 @@ static int bisect_visualize(struct bisect_terms *terms, int argc,
11661170
return run_command(&cmd);
11671171
}
11681172

1169-
static int get_first_good(const struct reference *ref, void *cb_data)
1173+
static int get_first_good(const char *refname UNUSED,
1174+
const char *referent UNUSED,
1175+
const struct object_id *oid,
1176+
int flag UNUSED, void *cb_data)
11701177
{
1171-
oidcpy(cb_data, ref->oid);
1178+
oidcpy(cb_data, oid);
11721179
return 1;
11731180
}
11741181

builtin/checkout.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,9 +1063,11 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
10631063
report_tracking(new_branch_info);
10641064
}
10651065

1066-
static int add_pending_uninteresting_ref(const struct reference *ref, void *cb_data)
1066+
static int add_pending_uninteresting_ref(const char *refname, const char *referent UNUSED,
1067+
const struct object_id *oid,
1068+
int flags UNUSED, void *cb_data)
10671069
{
1068-
add_pending_oid(cb_data, ref->name, ref->oid, UNINTERESTING);
1070+
add_pending_oid(cb_data, refname, oid, UNINTERESTING);
10691071
return 0;
10701072
}
10711073

builtin/describe.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,20 @@ static void add_to_known_names(const char *path,
154154
}
155155
}
156156

157-
static int get_name(const struct reference *ref, void *cb_data UNUSED)
157+
static int get_name(const char *path, const char *referent UNUSED, const struct object_id *oid,
158+
int flag UNUSED, void *cb_data UNUSED)
158159
{
159160
int is_tag = 0;
160161
struct object_id peeled;
161162
int is_annotated, prio;
162163
const char *path_to_match = NULL;
163164

164-
if (skip_prefix(ref->name, "refs/tags/", &path_to_match)) {
165+
if (skip_prefix(path, "refs/tags/", &path_to_match)) {
165166
is_tag = 1;
166167
} else if (all) {
167168
if ((exclude_patterns.nr || patterns.nr) &&
168-
!skip_prefix(ref->name, "refs/heads/", &path_to_match) &&
169-
!skip_prefix(ref->name, "refs/remotes/", &path_to_match)) {
169+
!skip_prefix(path, "refs/heads/", &path_to_match) &&
170+
!skip_prefix(path, "refs/remotes/", &path_to_match)) {
170171
/* Only accept reference of known type if there are match/exclude patterns */
171172
return 0;
172173
}
@@ -208,10 +209,10 @@ static int get_name(const struct reference *ref, void *cb_data UNUSED)
208209
}
209210

210211
/* Is it annotated? */
211-
if (!reference_get_peeled_oid(the_repository, ref, &peeled)) {
212-
is_annotated = !oideq(ref->oid, &peeled);
212+
if (!peel_iterated_oid(the_repository, oid, &peeled)) {
213+
is_annotated = !oideq(oid, &peeled);
213214
} else {
214-
oidcpy(&peeled, ref->oid);
215+
oidcpy(&peeled, oid);
215216
is_annotated = 0;
216217
}
217218

@@ -228,8 +229,7 @@ static int get_name(const struct reference *ref, void *cb_data UNUSED)
228229
else
229230
prio = 0;
230231

231-
add_to_known_names(all ? ref->name + 5 : ref->name + 10,
232-
&peeled, prio, ref->oid);
232+
add_to_known_names(all ? path + 5 : path + 10, &peeled, prio, oid);
233233
return 0;
234234
}
235235

builtin/fetch.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,13 @@ static struct refname_hash_entry *refname_hash_add(struct hashmap *map,
289289
return ent;
290290
}
291291

292-
static int add_one_refname(const struct reference *ref, void *cbdata)
292+
static int add_one_refname(const char *refname, const char *referent UNUSED,
293+
const struct object_id *oid,
294+
int flag UNUSED, void *cbdata)
293295
{
294296
struct hashmap *refname_map = cbdata;
295297

296-
(void) refname_hash_add(refname_map, ref->name, ref->oid);
298+
(void) refname_hash_add(refname_map, refname, oid);
297299
return 0;
298300
}
299301

@@ -1414,11 +1416,14 @@ static void set_option(struct transport *transport, const char *name, const char
14141416
}
14151417

14161418

1417-
static int add_oid(const struct reference *ref, void *cb_data)
1419+
static int add_oid(const char *refname UNUSED,
1420+
const char *referent UNUSED,
1421+
const struct object_id *oid,
1422+
int flags UNUSED, void *cb_data)
14181423
{
14191424
struct oid_array *oids = cb_data;
14201425

1421-
oid_array_append(oids, ref->oid);
1426+
oid_array_append(oids, oid);
14221427
return 0;
14231428
}
14241429

builtin/fsck.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -530,13 +530,14 @@ static int fsck_handle_reflog(const char *logname, void *cb_data)
530530
return 0;
531531
}
532532

533-
static int fsck_handle_ref(const struct reference *ref, void *cb_data UNUSED)
533+
static int fsck_handle_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
534+
int flag UNUSED, void *cb_data UNUSED)
534535
{
535536
struct object *obj;
536537

537-
obj = parse_object(the_repository, ref->oid);
538+
obj = parse_object(the_repository, oid);
538539
if (!obj) {
539-
if (is_promisor_object(the_repository, ref->oid)) {
540+
if (is_promisor_object(the_repository, oid)) {
540541
/*
541542
* Increment default_refs anyway, because this is a
542543
* valid ref.
@@ -545,19 +546,19 @@ static int fsck_handle_ref(const struct reference *ref, void *cb_data UNUSED)
545546
return 0;
546547
}
547548
error(_("%s: invalid sha1 pointer %s"),
548-
ref->name, oid_to_hex(ref->oid));
549+
refname, oid_to_hex(oid));
549550
errors_found |= ERROR_REACHABLE;
550551
/* We'll continue with the rest despite the error.. */
551552
return 0;
552553
}
553-
if (obj->type != OBJ_COMMIT && is_branch(ref->name)) {
554-
error(_("%s: not a commit"), ref->name);
554+
if (obj->type != OBJ_COMMIT && is_branch(refname)) {
555+
error(_("%s: not a commit"), refname);
555556
errors_found |= ERROR_REFS;
556557
}
557558
default_refs++;
558559
obj->flags |= USED;
559560
fsck_put_object_name(&fsck_walk_options,
560-
ref->oid, "%s", ref->name);
561+
oid, "%s", refname);
561562
mark_object_reachable(obj);
562563

563564
return 0;
@@ -579,19 +580,13 @@ static void get_default_heads(void)
579580
worktrees = get_worktrees();
580581
for (p = worktrees; *p; p++) {
581582
struct worktree *wt = *p;
582-
struct strbuf refname = STRBUF_INIT;
583+
struct strbuf ref = STRBUF_INIT;
583584

584-
strbuf_worktree_ref(wt, &refname, "HEAD");
585-
fsck_head_link(refname.buf, &head_points_at, &head_oid);
586-
if (head_points_at && !is_null_oid(&head_oid)) {
587-
struct reference ref = {
588-
.name = refname.buf,
589-
.oid = &head_oid,
590-
};
591-
592-
fsck_handle_ref(&ref, NULL);
593-
}
594-
strbuf_release(&refname);
585+
strbuf_worktree_ref(wt, &ref, "HEAD");
586+
fsck_head_link(ref.buf, &head_points_at, &head_oid);
587+
if (head_points_at && !is_null_oid(&head_oid))
588+
fsck_handle_ref(ref.buf, NULL, &head_oid, 0, NULL);
589+
strbuf_release(&ref);
595590

596591
if (include_reflogs)
597592
refs_for_each_reflog(get_worktree_ref_store(wt),

builtin/gc.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,21 +1103,24 @@ struct cg_auto_data {
11031103
int limit;
11041104
};
11051105

1106-
static int dfs_on_ref(const struct reference *ref, void *cb_data)
1106+
static int dfs_on_ref(const char *refname UNUSED,
1107+
const char *referent UNUSED,
1108+
const struct object_id *oid,
1109+
int flags UNUSED,
1110+
void *cb_data)
11071111
{
11081112
struct cg_auto_data *data = (struct cg_auto_data *)cb_data;
11091113
int result = 0;
1110-
const struct object_id *maybe_peeled = ref->oid;
11111114
struct object_id peeled;
11121115
struct commit_list *stack = NULL;
11131116
struct commit *commit;
11141117

1115-
if (!reference_get_peeled_oid(the_repository, ref, &peeled))
1116-
maybe_peeled = &peeled;
1117-
if (odb_read_object_info(the_repository->objects, maybe_peeled, NULL) != OBJ_COMMIT)
1118+
if (!peel_iterated_oid(the_repository, oid, &peeled))
1119+
oid = &peeled;
1120+
if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)
11181121
return 0;
11191122

1120-
commit = lookup_commit(the_repository, maybe_peeled);
1123+
commit = lookup_commit(the_repository, oid);
11211124
if (!commit)
11221125
return 0;
11231126
if (repo_parse_commit(the_repository, commit) ||

builtin/ls-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ int cmd_ls_remote(int argc,
156156
continue;
157157
if (!tail_match(&pattern, ref->name))
158158
continue;
159-
item = ref_array_push(&ref_array, ref->name, &ref->old_oid, NULL);
159+
item = ref_array_push(&ref_array, ref->name, &ref->old_oid);
160160
item->symref = xstrdup_or_null(ref->symref);
161161
}
162162

builtin/name-rev.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,24 +339,25 @@ static int cmp_by_tag_and_age(const void *a_, const void *b_)
339339
return a->taggerdate != b->taggerdate;
340340
}
341341

342-
static int name_ref(const struct reference *ref, void *cb_data)
342+
static int name_ref(const char *path, const char *referent UNUSED, const struct object_id *oid,
343+
int flags UNUSED, void *cb_data)
343344
{
344-
struct object *o = parse_object(the_repository, ref->oid);
345+
struct object *o = parse_object(the_repository, oid);
345346
struct name_ref_data *data = cb_data;
346347
int can_abbreviate_output = data->tags_only && data->name_only;
347348
int deref = 0;
348349
int from_tag = 0;
349350
struct commit *commit = NULL;
350351
timestamp_t taggerdate = TIME_MAX;
351352

352-
if (data->tags_only && !starts_with(ref->name, "refs/tags/"))
353+
if (data->tags_only && !starts_with(path, "refs/tags/"))
353354
return 0;
354355

355356
if (data->exclude_filters.nr) {
356357
struct string_list_item *item;
357358

358359
for_each_string_list_item(item, &data->exclude_filters) {
359-
if (subpath_matches(ref->name, item->string) >= 0)
360+
if (subpath_matches(path, item->string) >= 0)
360361
return 0;
361362
}
362363
}
@@ -377,7 +378,7 @@ static int name_ref(const struct reference *ref, void *cb_data)
377378
* shouldn't stop when seeing 'refs/tags/v1.4' matches
378379
* 'refs/tags/v*'. We should show it as 'v1.4'.
379380
*/
380-
switch (subpath_matches(ref->name, item->string)) {
381+
switch (subpath_matches(path, item->string)) {
381382
case -1: /* did not match */
382383
break;
383384
case 0: /* matched fully */
@@ -405,13 +406,13 @@ static int name_ref(const struct reference *ref, void *cb_data)
405406
}
406407
if (o && o->type == OBJ_COMMIT) {
407408
commit = (struct commit *)o;
408-
from_tag = starts_with(ref->name, "refs/tags/");
409+
from_tag = starts_with(path, "refs/tags/");
409410
if (taggerdate == TIME_MAX)
410411
taggerdate = commit->date;
411412
}
412413

413-
add_to_tip_table(ref->oid, ref->name, can_abbreviate_output,
414-
commit, taggerdate, from_tag, deref);
414+
add_to_tip_table(oid, path, can_abbreviate_output, commit, taggerdate,
415+
from_tag, deref);
415416
return 0;
416417
}
417418

0 commit comments

Comments
 (0)