Re: [PATCH 09/19] reset.c: replace switch by if-else
- From
Martin von Zweigbergk <martinvonz@gmail.com>
- Date
- Jan 11, 2013, 06:35 UTC
- Message-ID
- <CANiSa6gz-DBv+2gUDPdhgmeYdHg3-OVO80a7NvdLn4vYRyKEnA@mail.gmail.com>
- In-Reply-To
- <7vhamq5e1v.fsf@alter.siamese.dyndns.org>
On Wed, Jan 9, 2013 at 11:53 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 31 quoted lines
> Martin von Zweigbergk <martinvonz@gmail.com> writes:
>
>> ---
>> builtin/reset.c | 13 +++----------
>> 1 file changed, 3 insertions(+), 10 deletions(-)
>>
>> diff --git a/builtin/reset.c b/builtin/reset.c
>> index 42d1563..05ccfd4 100644
>> --- a/builtin/reset.c
>> +++ b/builtin/reset.c
>> @@ -351,18 +351,11 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
>> * saving the previous head in ORIG_HEAD before. */
>> update_ref_status = update_refs(rev, sha1);
>>
>> - switch (reset_type) {
>> - case HARD:
>> - if (!update_ref_status && !quiet)
>> - print_new_head_line(commit);
>> - break;
>> - case SOFT: /* Nothing else to do. */
>> - break;
>> - case MIXED: /* Report what has not been updated. */
>> + if (reset_type == HARD && !update_ref_status && !quiet)
>> + print_new_head_line(commit);
>> + else if (reset_type == MIXED) /* Report what has not been updated. */
>> update_index_refresh(0, NULL,
>> quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);
>> - break;
>> - }
>
> Justification?Clairvoyance -- the HARD case will soon be the only non-empty case. It's also missing KEEP and MERGE (but the empty SOFT block is there).
I'll update the message. I will also move the patch a little later in the series, closer to where it will be useful.