On Fri, Jan 31, 2025 at 04:30:31PM +0100, Toon Claes wrote: > The function wanted_peer_refs() is used to map the refs returned by the > server to refs we will save in our clone. > > Over time this function grown to be very complex. Refactor it. The diff of this commit is a bit on the harder side to read, so it would be nice if the message guided the reader a bit. > Signed-off-by: Toon Claes <toon@xxxxxxxxx> > --- > builtin/clone.c | 39 +++++++++++++++------------------------ > 1 file changed, 15 insertions(+), 24 deletions(-) > > diff --git a/builtin/clone.c b/builtin/clone.c > index 69d1ad029dfa84a2f7136fa4a3c4c8a594b179c4..d652682494d0d27dd73cd0585e28b23f2883786d 100644 > --- a/builtin/clone.c > +++ b/builtin/clone.c > @@ -434,46 +434,37 @@ static struct ref *wanted_peer_refs(const struct ref *refs, [snip] > - if (!option_mirror && !option_single_branch && option_tags) > + for (int i = 0; i < refspec->nr; i++) While at it: this should be `size_t i` to match the type of `refspec->nr`. Patrick