unpack-trees: clean up some flow control
commit5d4f4a592e99e8fb220b2db410f0d81203f3762e
authorElijah Newren <newren@gmail.com>
Mon, 27 Feb 2023 15:28:13 +0000 (27 15:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2023 16:29:50 +0000 (27 08:29 -0800)
tree0b75c137adec5dad4bbcab888f91431b48290faf
parentd144a9d30d883ec4b2ea5ed065e1b42237217c14
unpack-trees: clean up some flow control

The update_sparsity() function was introduced in commit 7af7a25853
("unpack-trees: add a new update_sparsity() function", 2020-03-27).
Prior to that, unpack_trees() was used, but that had a few bugs because
the needs of the caller were different, and different enough that
unpack_trees() could not easily be modified to handle both usecases.

The implementation detail that update_sparsity() was written by copying
unpack_trees() and then streamlining it, and then modifying it in the
needed ways still shows through in that there are leftover vestiges in
both functions that are no longer needed.  Clean them up.  In
particular:

  * update_sparsity() allows a pattern list to be passed in, but
    unpack_trees() never should use a different pattern list.  Add a
    check and a BUG() if this gets violated.
  * update_sparsity() has a check early on that will BUG() if
    o->skip_sparse_checkout is set; as such, there's no need to check
    for that condition again later in the code.  We can simply remove
    the check and its corresponding goto label.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees.c