Re: [PATCH v2 3/4] show-ref: Optimize show_ref a bit
From: Junio C Hamano <hidden>
Date: 2017-01-22 22:55:27
Junio C Hamano [off-list ref] writes:
Having to do this change probably is an indication that the division of labour between show_ref() and show_one() up to this step needs to be rethought. Conceptually, "git show-ref" works in two ways: * When in --verify mode, the end user gives which refnames to consider showing. * Otherwise the end user gives pattern and the command infers which refnames to consider showing using the pattern. And for the refnames that are considered for showing, we may do various things, like -d to deref and --quiet to be silent. We want this actual "output" step to be the same between two modes of operation.
... also "error out if the named object did not exist" can be part of this, which means ...
So a better division of labour would be: * Make show_ref() about "using pattern, enumerate what refs to show" and call show_one(). * Update show_one() and teach _it_ to handle quiet and deref_tags.
... "if (!has_sha1_file(oid->hash)) die()" in show_ref() would probably want to be part of this update.