Re: [PATCHv10 01/10] receive-pack.c: shorten the execute_commands loop over all commands
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Jan 5, 2015, 21:18 UTC
- Message-ID
- <20150105211803.GM29365@google.com>
- In-Reply-To
- <CAGZ79kbRLPYRw+iifigRHqJ5Lc1brQ3qkUV=4YYPSwr72+giPg@mail.gmail.com>
Stefan Beller wrote:
> On Mon, Jan 5, 2015 at 12:22 PM, Jonathan Nieder <jrnieder@gmail.com> wrote: >> Stefan Beller wrote:
Show 18 quoted lines
>>> --- a/builtin/receive-pack.c >>> +++ b/builtin/receive-pack.c >> [...] >>> @@ -1077,27 +1100,15 @@ static void execute_commands(struct command *commands, >> [...] >>> + if (shallow_update) >>> + assure_connectivity_checked(commands, si); >> >> Looking at this code alone, it seems like assure_connectivity_checked() >> is going to ensure that connectivity was checked, so that I can assume >> connectivity going forward. But the opposite is true --- it is a >> safety check that prints a warning and doesn't affect what I can >> assume. > > I disagree on that. Combined with the next patch (s/error/die/) we can assume > that the the connectivity is there as if it is not, git is dead. > > This is why I choose the word assure.
If this patch depends on the next one, would it make sense to put them in the opposite order?
Show 15 quoted lines
>> The factored-out function fails in what it is meant to do, which is to >> save the reader of execute_commands from having to look at the >> implementation of the parts they are not interested in. >> >> Would something like warn_if_skipped_connectivity_check() make sense? > > The next patch would then change this to die_if_... ? > I'd be ok with that, but in your original email you would still have the last > die(...) in the execute_command function which I dislike. > So what about: > > if (shallow_update) > (warn|die)_on_skipped_connectivity_check() > > ?
My personal preference would be to refactor the preceding code to make the check unnecessary.
But aside from that, anything that makes the code clearer is fine with me. I find ..._if_... clearer than ..._on_... here because it seems more obvious that it is not an expected condition (i.e., it's a kind of abbreviation for
warn_if_skipped_connectivity_check_which_should_never_happen()
) but that's a more minor detail. An alternative way to make the code clearer would be to use a comment.
Thanks, Jonathan