]> git.ipfire.org Git - thirdparty/git.git/commit
clone: refactor wanted_peer_refs()
authorToon Claes <toon@iotcl.com>
Thu, 6 Feb 2025 06:33:31 +0000 (07:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Feb 2025 20:23:53 +0000 (12:23 -0800)
commit879780f9a15177ed703f56bf347e0a410c22e9d1
tree47c8c178770db32db8158c5c2a2657a4e643a737
parentbc26f7690a318fd0a875bfd8d56c70e1ccb79ccb
clone: refactor wanted_peer_refs()

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.

Previously, there was a separate code path for when
`option_single_branch` was set. It resulted in duplicated code and
deeper nested conditions. After this refactor the code path for when
`option_single_branch` is truthy modifies `refs` and then falls through
to the common code path. This approach relies on the `refspec` being set
correctly and thus only mapping refs that are relevant.

Signed-off-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clone.c