Skip to content

Commit e820771

Browse files
john-caigitster
authored andcommitted
refs: add referent to each_ref_fn
Add a parameter to each_ref_fn so that callers to the ref APIs that use this function as a callback can have acess to the unresolved value of a symbolic ref. Signed-off-by: John Cai <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cfd9715 commit e820771

Some content is hidden

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

48 files changed

+78
-54
lines changed

bisect.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void find_bisection(struct commit_list **commit_list, int *reaches,
448448
clear_commit_weight(&commit_weight);
449449
}
450450

451-
static int register_ref(const char *refname, const struct object_id *oid,
451+
static int register_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
452452
int flags UNUSED, void *cb_data UNUSED)
453453
{
454454
struct strbuf good_prefix = STRBUF_INIT;
@@ -1170,6 +1170,7 @@ int estimate_bisect_steps(int all)
11701170
}
11711171

11721172
static int mark_for_removal(const char *refname,
1173+
const char *referent UNUSED,
11731174
const struct object_id *oid UNUSED,
11741175
int flag UNUSED, void *cb_data)
11751176
{

builtin/bisect.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ static int check_and_set_terms(struct bisect_terms *terms, const char *cmd)
356356
}
357357

358358
static int inc_nr(const char *refname UNUSED,
359+
const char *referent UNUSED,
359360
const struct object_id *oid UNUSED,
360361
int flag UNUSED, void *cb_data)
361362
{
@@ -545,7 +546,7 @@ static int bisect_append_log_quoted(const char **argv)
545546
return res;
546547
}
547548

548-
static int add_bisect_ref(const char *refname, const struct object_id *oid,
549+
static int add_bisect_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
549550
int flags UNUSED, void *cb)
550551
{
551552
struct add_bisect_ref_data *data = cb;
@@ -1162,6 +1163,7 @@ static int bisect_visualize(struct bisect_terms *terms, int argc,
11621163
}
11631164

11641165
static int get_first_good(const char *refname UNUSED,
1166+
const char *referent UNUSED,
11651167
const struct object_id *oid,
11661168
int flag UNUSED, void *cb_data)
11671169
{

builtin/checkout.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
10451045
report_tracking(new_branch_info);
10461046
}
10471047

1048-
static int add_pending_uninteresting_ref(const char *refname,
1048+
static int add_pending_uninteresting_ref(const char *refname, const char *referent UNUSED,
10491049
const struct object_id *oid,
10501050
int flags UNUSED, void *cb_data)
10511051
{

builtin/describe.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static void add_to_known_names(const char *path,
149149
}
150150
}
151151

152-
static int get_name(const char *path, const struct object_id *oid,
152+
static int get_name(const char *path, const char *referent UNUSED, const struct object_id *oid,
153153
int flag UNUSED, void *cb_data UNUSED)
154154
{
155155
int is_tag = 0;

builtin/fetch.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static struct refname_hash_entry *refname_hash_add(struct hashmap *map,
286286
return ent;
287287
}
288288

289-
static int add_one_refname(const char *refname,
289+
static int add_one_refname(const char *refname, const char *referent UNUSED,
290290
const struct object_id *oid,
291291
int flag UNUSED, void *cbdata)
292292
{
@@ -1464,6 +1464,7 @@ static void set_option(struct transport *transport, const char *name, const char
14641464

14651465

14661466
static int add_oid(const char *refname UNUSED,
1467+
const char *referent UNUSED,
14671468
const struct object_id *oid,
14681469
int flags UNUSED, void *cb_data)
14691470
{

builtin/fsck.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ static int fsck_handle_reflog(const char *logname, void *cb_data)
521521
return 0;
522522
}
523523

524-
static int fsck_handle_ref(const char *refname, const struct object_id *oid,
524+
static int fsck_handle_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
525525
int flag UNUSED, void *cb_data UNUSED)
526526
{
527527
struct object *obj;
@@ -576,7 +576,7 @@ static void get_default_heads(void)
576576
strbuf_worktree_ref(wt, &ref, "HEAD");
577577
fsck_head_link(ref.buf, &head_points_at, &head_oid);
578578
if (head_points_at && !is_null_oid(&head_oid))
579-
fsck_handle_ref(ref.buf, &head_oid, 0, NULL);
579+
fsck_handle_ref(ref.buf, NULL, &head_oid, 0, NULL);
580580
strbuf_release(&ref);
581581

582582
if (include_reflogs)

builtin/gc.c

+1
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ struct cg_auto_data {
836836
};
837837

838838
static int dfs_on_ref(const char *refname UNUSED,
839+
const char *referent UNUSED,
839840
const struct object_id *oid,
840841
int flags UNUSED,
841842
void *cb_data)

builtin/name-rev.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int cmp_by_tag_and_age(const void *a_, const void *b_)
337337
return a->taggerdate != b->taggerdate;
338338
}
339339

340-
static int name_ref(const char *path, const struct object_id *oid,
340+
static int name_ref(const char *path, const char *referent UNUSED, const struct object_id *oid,
341341
int flags UNUSED, void *cb_data)
342342
{
343343
struct object *o = parse_object(the_repository, oid);

builtin/pack-objects.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ static enum write_one_status write_one(struct hashfile *f,
771771
return WRITE_ONE_WRITTEN;
772772
}
773773

774-
static int mark_tagged(const char *path UNUSED, const struct object_id *oid,
774+
static int mark_tagged(const char *path UNUSED, const char *referent UNUSED, const struct object_id *oid,
775775
int flag UNUSED, void *cb_data UNUSED)
776776
{
777777
struct object_id peeled;
@@ -3129,7 +3129,7 @@ static void add_tag_chain(const struct object_id *oid)
31293129
}
31303130
}
31313131

3132-
static int add_ref_tag(const char *tag UNUSED, const struct object_id *oid,
3132+
static int add_ref_tag(const char *tag UNUSED, const char *referent UNUSED, const struct object_id *oid,
31333133
int flag UNUSED, void *cb_data UNUSED)
31343134
{
31353135
struct object_id peeled;
@@ -4076,6 +4076,7 @@ static void record_recent_commit(struct commit *commit, void *data UNUSED)
40764076
}
40774077

40784078
static int mark_bitmap_preferred_tip(const char *refname,
4079+
const char *referent UNUSED,
40794080
const struct object_id *oid,
40804081
int flags UNUSED,
40814082
void *data UNUSED)

builtin/receive-pack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ static void show_ref(const char *path, const struct object_id *oid)
300300
}
301301
}
302302

303-
static int show_ref_cb(const char *path_full, const struct object_id *oid,
303+
static int show_ref_cb(const char *path_full, const char *referent UNUSED, const struct object_id *oid,
304304
int flag UNUSED, void *data)
305305
{
306306
struct oidset *seen = data;

builtin/remote.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ struct branches_for_remote {
543543
};
544544

545545
static int add_branch_for_removal(const char *refname,
546+
const char *referent UNUSED,
546547
const struct object_id *oid UNUSED,
547548
int flags UNUSED, void *cb_data)
548549
{
@@ -585,7 +586,7 @@ struct rename_info {
585586
uint32_t symrefs_nr;
586587
};
587588

588-
static int read_remote_branches(const char *refname,
589+
static int read_remote_branches(const char *refname, const char *referent UNUSED,
589590
const struct object_id *oid UNUSED,
590591
int flags UNUSED, void *cb_data)
591592
{
@@ -971,6 +972,7 @@ static void free_remote_ref_states(struct ref_states *states)
971972
}
972973

973974
static int append_ref_to_tracked_list(const char *refname,
975+
const char *referent UNUSED,
974976
const struct object_id *oid UNUSED,
975977
int flags, void *cb_data)
976978
{

builtin/repack.c

+1
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ struct midx_snapshot_ref_data {
667667
};
668668

669669
static int midx_snapshot_ref_one(const char *refname UNUSED,
670+
const char *referent UNUSED,
670671
const struct object_id *oid,
671672
int flag UNUSED, void *_data)
672673
{

builtin/replace.c

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct show_data {
4949
};
5050

5151
static int show_reference(const char *refname,
52+
const char *referent UNUSED,
5253
const struct object_id *oid,
5354
int flag UNUSED, void *cb_data)
5455
{

builtin/rev-parse.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static int show_default(void)
211211
return 0;
212212
}
213213

214-
static int show_reference(const char *refname, const struct object_id *oid,
214+
static int show_reference(const char *refname, const char *referent UNUSED, const struct object_id *oid,
215215
int flag UNUSED, void *cb_data UNUSED)
216216
{
217217
if (ref_excluded(&ref_excludes, refname))
@@ -220,7 +220,7 @@ static int show_reference(const char *refname, const struct object_id *oid,
220220
return 0;
221221
}
222222

223-
static int anti_reference(const char *refname, const struct object_id *oid,
223+
static int anti_reference(const char *refname, const char *referent UNUSED, const struct object_id *oid,
224224
int flag UNUSED, void *cb_data UNUSED)
225225
{
226226
show_rev(REVERSED, oid, refname);

builtin/show-branch.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static int append_ref(const char *refname, const struct object_id *oid,
410410
return 0;
411411
}
412412

413-
static int append_head_ref(const char *refname, const struct object_id *oid,
413+
static int append_head_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
414414
int flag UNUSED, void *cb_data UNUSED)
415415
{
416416
struct object_id tmp;
@@ -425,7 +425,7 @@ static int append_head_ref(const char *refname, const struct object_id *oid,
425425
return append_ref(refname + ofs, oid, 0);
426426
}
427427

428-
static int append_remote_ref(const char *refname, const struct object_id *oid,
428+
static int append_remote_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
429429
int flag UNUSED, void *cb_data UNUSED)
430430
{
431431
struct object_id tmp;
@@ -451,7 +451,7 @@ static int append_tag_ref(const char *refname, const struct object_id *oid,
451451
static const char *match_ref_pattern = NULL;
452452
static int match_ref_slash = 0;
453453

454-
static int append_matching_ref(const char *refname, const struct object_id *oid,
454+
static int append_matching_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
455455
int flag, void *cb_data)
456456
{
457457
/* we want to allow pattern hold/<asterisk> to show all
@@ -468,7 +468,7 @@ static int append_matching_ref(const char *refname, const struct object_id *oid,
468468
if (wildmatch(match_ref_pattern, tail, 0))
469469
return 0;
470470
if (starts_with(refname, "refs/heads/"))
471-
return append_head_ref(refname, oid, flag, cb_data);
471+
return append_head_ref(refname, NULL, oid, flag, cb_data);
472472
if (starts_with(refname, "refs/tags/"))
473473
return append_tag_ref(refname, oid, flag, cb_data);
474474
return append_ref(refname, oid, 0);

builtin/show-ref.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct show_ref_data {
6363
int show_head;
6464
};
6565

66-
static int show_ref(const char *refname, const struct object_id *oid,
66+
static int show_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
6767
int flag UNUSED, void *cbdata)
6868
{
6969
struct show_ref_data *data = cbdata;
@@ -97,6 +97,7 @@ static int show_ref(const char *refname, const struct object_id *oid,
9797
}
9898

9999
static int add_existing(const char *refname,
100+
const char *referent UNUSED,
100101
const struct object_id *oid UNUSED,
101102
int flag UNUSED, void *cbdata)
102103
{

builtin/submodule--helper.c

+1
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ static void print_status(unsigned int flags, char state, const char *path,
608608
}
609609

610610
static int handle_submodule_head_ref(const char *refname UNUSED,
611+
const char *referent UNUSED,
611612
const struct object_id *oid,
612613
int flags UNUSED,
613614
void *cb_data)

builtin/worktree.c

+1
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ static void print_preparing_worktree_line(int detach,
626626
* Returns 0 on failure and non-zero on success.
627627
*/
628628
static int first_valid_ref(const char *refname UNUSED,
629+
const char *referent UNUSED,
629630
const struct object_id *oid UNUSED,
630631
int flags UNUSED,
631632
void *cb_data UNUSED)

commit-graph.c

+1
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,7 @@ struct refs_cb_data {
18471847
};
18481848

18491849
static int add_ref_to_set(const char *refname UNUSED,
1850+
const char *referent UNUSED,
18501851
const struct object_id *oid,
18511852
int flags UNUSED, void *cb_data)
18521853
{

delta-islands.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static void add_ref_to_island(kh_str_t *remote_islands, const char *island_name,
390390
rl->hash += sha_core;
391391
}
392392

393-
static int find_island_for_ref(const char *refname, const struct object_id *oid,
393+
static int find_island_for_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
394394
int flags UNUSED, void *cb)
395395
{
396396
struct island_load_data *ild = cb;

fetch-pack.c

+2
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
183183
}
184184

185185
static int rev_list_insert_ref_oid(const char *refname UNUSED,
186+
const char *referent UNUSED,
186187
const struct object_id *oid,
187188
int flag UNUSED,
188189
void *cb_data)
@@ -610,6 +611,7 @@ static int mark_complete(const struct object_id *oid)
610611
}
611612

612613
static int mark_complete_oid(const char *refname UNUSED,
614+
const char *referent UNUSED,
613615
const struct object_id *oid,
614616
int flag UNUSED,
615617
void *cb_data UNUSED)

help.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ struct similar_ref_cb {
804804
struct string_list *similar_refs;
805805
};
806806

807-
static int append_similar_ref(const char *refname,
807+
static int append_similar_ref(const char *refname, const char *referent UNUSED,
808808
const struct object_id *oid UNUSED,
809809
int flags UNUSED, void *cb_data)
810810
{

http-backend.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static void run_service(const char **argv, int buffer_input)
512512
exit(1);
513513
}
514514

515-
static int show_text_ref(const char *name, const struct object_id *oid,
515+
static int show_text_ref(const char *name, const char *referent UNUSED, const struct object_id *oid,
516516
int flag UNUSED, void *cb_data)
517517
{
518518
const char *name_nons = strip_namespace(name);
@@ -568,7 +568,7 @@ static void get_info_refs(struct strbuf *hdr, char *arg UNUSED)
568568
strbuf_release(&buf);
569569
}
570570

571-
static int show_head_ref(const char *refname, const struct object_id *oid,
571+
static int show_head_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
572572
int flag, void *cb_data)
573573
{
574574
struct strbuf *buf = cb_data;

log-tree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int ref_filter_match(const char *refname,
145145
return 1;
146146
}
147147

148-
static int add_ref_decoration(const char *refname, const struct object_id *oid,
148+
static int add_ref_decoration(const char *refname, const char *referent UNUSED, const struct object_id *oid,
149149
int flags UNUSED,
150150
void *cb_data)
151151
{

ls-refs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct ls_refs_data {
7777
unsigned unborn : 1;
7878
};
7979

80-
static int send_ref(const char *refname, const struct object_id *oid,
80+
static int send_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
8181
int flag, void *cb_data)
8282
{
8383
struct ls_refs_data *data = cb_data;
@@ -135,7 +135,7 @@ static void send_possibly_unborn_head(struct ls_refs_data *data)
135135
oid_is_null = is_null_oid(&oid);
136136
if (!oid_is_null ||
137137
(data->unborn && data->symrefs && (flag & REF_ISSYMREF)))
138-
send_ref(namespaced.buf, oid_is_null ? NULL : &oid, flag, data);
138+
send_ref(namespaced.buf, NULL, oid_is_null ? NULL : &oid, flag, data);
139139
strbuf_release(&namespaced);
140140
}
141141

midx-write.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ static void prepare_midx_packing_data(struct packing_data *pdata,
655655
trace2_region_leave("midx", "prepare_midx_packing_data", the_repository);
656656
}
657657

658-
static int add_ref_to_pending(const char *refname,
658+
static int add_ref_to_pending(const char *refname, const char *referent UNUSED,
659659
const struct object_id *oid,
660660
int flag, void *cb_data)
661661
{

negotiator/default.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void rev_list_push(struct negotiation_state *ns,
3838
}
3939
}
4040

41-
static int clear_marks(const char *refname, const struct object_id *oid,
41+
static int clear_marks(const char *refname, const char *referent UNUSED, const struct object_id *oid,
4242
int flag UNUSED,
4343
void *cb_data UNUSED)
4444
{

negotiator/skipping.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static struct entry *rev_list_push(struct data *data, struct commit *commit, int
7575
return entry;
7676
}
7777

78-
static int clear_marks(const char *refname, const struct object_id *oid,
78+
static int clear_marks(const char *refname, const char *referent UNUSED, const struct object_id *oid,
7979
int flag UNUSED,
8080
void *cb_data UNUSED)
8181
{

notes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ int combine_notes_cat_sort_uniq(struct object_id *cur_oid,
932932
return ret;
933933
}
934934

935-
static int string_list_add_one_ref(const char *refname,
935+
static int string_list_add_one_ref(const char *refname, const char *referent UNUSED,
936936
const struct object_id *oid UNUSED,
937937
int flag UNUSED, void *cb)
938938
{

0 commit comments

Comments
 (0)