In the switch statement, the difference between the `protocol_v2` and `protocol_v{1,0}` arms is a prepatory call to die_if_server_options() in the latter. The fetch_pack() call is identical in both arms. However, since this fetch_pack() call has so many parameters, it is not immediately obvious that the call is identical in both cases. Rewrite the switch statement to fallthrough from the v{1,0} case to v2 so that they share a common fetch_pack() call. This reduces duplication and makes the logic more clear for future readers. Signed-off-by: Denton Liu <liu.denton@xxxxxxxxx> --- transport.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/transport.c b/transport.c index 15f5ba4e8f..475f94564a 100644 --- a/transport.c +++ b/transport.c @@ -370,15 +370,11 @@ static int fetch_refs_via_pack(struct transport *transport, } switch (data->version) { - case protocol_v2: - refs = fetch_pack(&args, data->fd, - refs_tmp ? refs_tmp : transport->remote_refs, - to_fetch, nr_heads, &data->shallow, - &transport->pack_lockfile, data->version); - break; - case protocol_v1: case protocol_v0: + case protocol_v1: die_if_server_options(transport); + /* fallthrough */ + case protocol_v2: refs = fetch_pack(&args, data->fd, refs_tmp ? refs_tmp : transport->remote_refs, to_fetch, nr_heads, &data->shallow, -- 2.26.2.706.g87896c9627