Re: [PATCH v4 11/16] revision.c: --all adds HEAD from all worktrees
- From
Stefan Beller <sbeller@google.com>
- Date
- Aug 23, 2017, 19:54 UTC
- Message-ID
- <CAGZ79kY8cW+6+60bgSAhS69nBWZbn1LA7gT3t4Ddii+MB2V_cA@mail.gmail.com>
- In-Reply-To
- <20170823123704.16518-12-pclouds@gmail.com>
Show 12 quoted lines
> +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.
Show 5 quoted lines
> +/* > + * 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.