subtree: parse revs in individual cmd_ functions
authorLuke Shumaker <lukeshu@datawire.io>
Tue, 27 Apr 2021 21:17:39 +0000 (15:17 -0600)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Apr 2021 07:47:18 +0000 (16:47 +0900)
commite4f8baa88a0b294e1e2d91728e728e14574d1d87
tree24bb784dd240dc7a3cc7b3625fe6f16f1ae6bb33
parentbbffb023830f9b68e2c461e47756579a5cd6ab7a
subtree: parse revs in individual cmd_ functions

The main argument parser goes ahead and tries to parse revs to make
things simpler for the sub-command implementations.  But, it includes
enough special cases for different sub-commands.  And it's difficult
having having to think about "is this info coming from an argument, or a
global variable?".  So the main argument parser's effort to make things
"simpler" ends up just making it more confusing and complicated.

Begone with the 'revs' global variable; parse 'rev=$(...)' as needed in
individual 'cmd_*' functions.

Begone with the 'default' global variable.  Its would-be value is
knowable just from which function we're in.

Begone with the 'ensure_single_rev' function.  Its functionality can be
achieved by passing '--verify' to 'git rev-parse'.

Signed-off-by: Luke Shumaker <lukeshu@datawire.io>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree/git-subtree.sh