ls-tree: slightly refactor `show_tree()`
commit315f22c853c08b1f3473fc50985d76618f31ebd0
authorTeng Long <dyroneteng@gmail.com>
Wed, 23 Mar 2022 09:13:09 +0000 (23 17:13 +0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Mar 2022 18:38:39 +0000 (23 11:38 -0700)
tree8cc67a434fbfc0ac54e46d356a5606c930583c56
parentf6b224d5ebfe9fcf58ef34eddea68d9fb4384d50
ls-tree: slightly refactor `show_tree()`

This is a non-functional change, we introduce an enum "ls_tree_cmdmode"
then use it to mark which columns to output.

This has the advantage of making the show_tree logic simpler and more
readable, as well as making it easier to extend new options (for example,
if we want to add a "--object-only" option, we just need to add a similar
"short-circuit logic in "show_tree()").

Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Teng Long <dyroneteng@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/ls-tree.c