Junio C Hamano <gitster@xxxxxxxxx> writes:
> I am not so sure about that. The "only-to-die" caller is not even
> expecting that the call to this codepath would successfully return.
>
> Or at least, it shouldn't.
>
> So it might not be a bad idea to actually catch this as a
> programming error and do
>
> if (only_to_die) {
> if (!ret)
> die("BUG");
> diagnose_invalid_sha1_path(...);
> }
I disagree.
The only-to-die caller can expect that get_sha1_with_context_1 never
returns when called with only-to-die, but it's a stronger assumption to
expect that this particular place will trigger the failure.
In this case, the assumption is correct because there's a "return ret;"
a bit later in the code, but I don't think we should have to look at
this to check the correctness of the code (for example, if something
like "if (ret) try_some_fallback_method();" is later added before
"return ret;", then the assumption would become false).
My version reads as
try something;
if (it failed && I'm only here to report an error)
report_error();
which I find easier to understand.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Newbies FAQ] [Linux Kernel Development] [Free Online Dating] [Gcc Help] [IETF Annouce] [DCCP] [Netdev] [Networking] [Security] [V4L] [Bugtraq] [Free Online Dating] [Photo] [Yosemite] [MIPS Linux] [ARM Linux] [Linux Security] [Linux RAID] [Linux SCSI] [Fedora Users] [Linux Resources]