]> git.ipfire.org Git - thirdparty/git.git/commit
dir: refactor treat_directory to clarify control flow
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 1 Apr 2020 04:17:41 +0000 (04:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Apr 2020 18:10:38 +0000 (11:10 -0700)
commit0bbd0e8b5233b7cf66b846d4c1825a530d8402bd
tree18ced603d487ea5bd71d1ef0a34b8f8d5a244aa0
parent2df179d3dfeb431cc3030ac44e79b136debf1fd9
dir: refactor treat_directory to clarify control flow

The logic in treat_directory() is handled by a multi-case
switch statement, but this switch is very asymmetrical, as
the first two cases are simple but the third is more
complicated than the rest of the method. In fact, the third
case includes a "break" statement that leads to the block
of code outside the switch statement. That is the only way
to reach that block, as the switch handles all possible
values from directory_exists_in_index();

Extract the switch statement into a series of "if" statements.
This simplifies the trivial cases, while clarifying how to
reach the "show_other_directories" case. This is particularly
important as the "show_other_directories" case will expand
in a later change.

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c