Re: [PATCH] refs.c: use skip_prefix() in prettify_refname()
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Mar 23, 2017, 20:06 UTC
- Message-ID
- <CAM0VKjkAMrePks4JikNvzs_v71YFidKF7yj0aNVugZ-nzx1kig@mail.gmail.com>
- In-Reply-To
- <20170323193919.twwfwdoulo2hjz24@sigill.intra.peff.net>
On Thu, Mar 23, 2017 at 8:39 PM, Jeff King <peff@peff.net> wrote:
Show 14 quoted lines
> On Thu, Mar 23, 2017 at 12:33:06PM -0700, Junio C Hamano wrote: > >> >> Nice, but why add the "if" when it's doing nothing? >> > >> > It's short-circuiting in the conditional. >> >> I think René meant this: >> >> /* just for side effects */ >> skip_prefix(name, "refs/heads/", &name) || >> skip_prefix(name, "refs/tags/", &name) || >> skip_prefix(name, "refs/remotes/", &name); >> >> return name;
That was my first version indeed. Unfortunately:
> And it causes the compiler to complain that the value is not used.
Exactly. So that 'if' was a way to shut up the compiler complaining about the unused result of the ||-chain. Perhaps not the best way to do that, but I couldn't come up with any better.
I had a note about it attached to the commit, but then run 'format-patch' without '--notes'... oh, well. I guess I should have wrote that in the commit message to begin with, shouldn't I? Or in an in-code comment.