Skip to content

Commit 162d001

Browse files
pks-tgitster
authored andcommitted
refs: replace refs_for_each_namespaced_ref()
Replace calls to `refs_for_each_namespaced_ref()` with the newly introduced `refs_for_each_ref_ext()` function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3516c21 commit 162d001

4 files changed

Lines changed: 13 additions & 25 deletions

File tree

http-backend.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,13 @@ static void get_info_refs(struct strbuf *hdr, char *arg UNUSED)
565565
run_service(argv, 0);
566566

567567
} else {
568+
struct refs_for_each_ref_options opts = {
569+
.namespace = get_git_namespace(),
570+
};
571+
568572
select_getanyfile(hdr);
569-
refs_for_each_namespaced_ref(get_main_ref_store(the_repository),
570-
NULL, show_text_ref, &buf);
573+
refs_for_each_ref_ext(get_main_ref_store(the_repository),
574+
show_text_ref, &buf, &opts);
571575
send_strbuf(hdr, "text/plain", &buf);
572576
}
573577
strbuf_release(&buf);

refs.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,17 +1942,6 @@ int refs_for_each_replace_ref(struct ref_store *refs, refs_for_each_cb cb, void
19421942
return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
19431943
}
19441944

1945-
int refs_for_each_namespaced_ref(struct ref_store *refs,
1946-
const char **exclude_patterns,
1947-
refs_for_each_cb cb, void *cb_data)
1948-
{
1949-
struct refs_for_each_ref_options opts = {
1950-
.exclude_patterns = exclude_patterns,
1951-
.namespace = get_git_namespace(),
1952-
};
1953-
return refs_for_each_ref_ext(refs, cb, cb_data, &opts);
1954-
}
1955-
19561945
static int qsort_strcmp(const void *va, const void *vb)
19571946
{
19581947
const char *a = *(const char **)va;

refs.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,14 +526,6 @@ int refs_for_each_ref_in_prefixes(struct ref_store *refs,
526526
const struct refs_for_each_ref_options *opts,
527527
refs_for_each_cb cb, void *cb_data);
528528

529-
/*
530-
* references matching any pattern in "exclude_patterns" are omitted from the
531-
* result set on a best-effort basis.
532-
*/
533-
int refs_for_each_namespaced_ref(struct ref_store *refs,
534-
const char **exclude_patterns,
535-
refs_for_each_cb fn, void *cb_data);
536-
537529
/*
538530
* Normalizes partial refs to their fully qualified form.
539531
* Will prepend <prefix> to the <pattern> if it doesn't start with 'refs/'.

upload-pack.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,10 @@ static int allow_hidden_refs(enum allow_uor allow_uor)
610610
static void for_each_namespaced_ref_1(refs_for_each_cb fn,
611611
struct upload_pack_data *data)
612612
{
613-
const char **excludes = NULL;
613+
struct refs_for_each_ref_options opts = {
614+
.namespace = get_git_namespace(),
615+
};
616+
614617
/*
615618
* If `data->allow_uor` allows fetching hidden refs, we need to
616619
* mark all references (including hidden ones), to check in
@@ -621,10 +624,10 @@ static void for_each_namespaced_ref_1(refs_for_each_cb fn,
621624
* hidden references.
622625
*/
623626
if (allow_hidden_refs(data->allow_uor))
624-
excludes = hidden_refs_to_excludes(&data->hidden_refs);
627+
opts.exclude_patterns = hidden_refs_to_excludes(&data->hidden_refs);
625628

626-
refs_for_each_namespaced_ref(get_main_ref_store(the_repository),
627-
excludes, fn, data);
629+
refs_for_each_ref_ext(get_main_ref_store(the_repository),
630+
fn, data, &opts);
628631
}
629632

630633

0 commit comments

Comments
 (0)