]> git.ipfire.org Git - thirdparty/git.git/commit
contrib/subtree: convert subtree type check to use case statement
authorPatrick Steinhardt <ps@pks.im>
Fri, 10 Nov 2023 10:01:24 +0000 (11:01 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 11 Nov 2023 00:21:00 +0000 (09:21 +0900)
commit47c39c28bc1a0001e4341ae70629adcb10f425cc
tree003f082c15b11ebc24f7c8bf95d5bfbb719a7cda
parent88983946fa00ebea8b346acab46e19bceeed427d
contrib/subtree: convert subtree type check to use case statement

The `subtree_for_commit ()` helper function asserts that the subtree
identified by its parameters are either a commit or tree. This is done
via the `-o` parameter of test, which is discouraged.

Refactor the code to instead use a switch statement over the type.
Despite being aligned with our coding guidelines, the resulting code is
arguably also easier to read.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree/git-subtree.sh