> +int other_head_refs(each_ref_fn fn, void *cb_data) > +{ > + struct worktree **worktrees, **p; > + int ret = 0; > + > + worktrees = get_worktrees(0); > + for (p = worktrees; *p; p++) { > + struct worktree *wt = *p; > + struct ref_store *refs; > + > + if (wt->is_current) > + continue; As said in an earlier patch (and now this pattern coming up twice in this patch series alone), the lines of this function up to here, could become part of a worktree iterator function? > + refs = get_worktree_ref_store(wt); > + ret = refs_head_ref(refs, fn, cb_data); > + if (ret) > + break; with these 4 lines in the callback function. > +/* > + * Similar to head_ref() for all HEADs _except_ one from the current > + * worktree, which is covered by head_ref(). > + */ > +int other_head_refs(each_ref_fn fn, void *cb_data); This is already such an iterator function, just at another abstraction level.