[PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Felipe Contreras
Signed-off-by: Felipe Contreras felipe.contre...@gmail.com --- builtin/add.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/add.c b/builtin/add.c index 226f758..9b30356 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -429,7 +429,7 @@ int cmd_add(int argc, const char

Re: [PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Martin von Zweigbergk
I was recently confused by the yoda condition in this block of code from [1] + for (i = 0; i revs.nr; i++) + if (bases-item-object == revs.commit[i]-object) + break; /* found */ + if (revs.nr = i) I think I was particularly surprised because it came so soon after the i revs.nr. I didn't bother

Re: [PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 1:48 PM, Martin von Zweigbergk martinv...@gmail.com wrote: I guess what I'm trying to say is that either we accept them and get used to reading them without being surprised, or we can change a bit more than one at a time perhaps? I understand that this was an

Re: [PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Junio C Hamano
Martin von Zweigbergk martinv...@gmail.com writes: I was recently confused by the yoda condition in this block of code from [1] + for (i = 0; i revs.nr; i++) + if (bases-item-object == revs.commit[i]-object) + break; /* found */ + if (revs.nr = i) I think I was particularly surprised

Re: [PATCH 16/16] add: avoid yoda conditions

2013-10-31 Thread Felipe Contreras
On Thu, Oct 31, 2013 at 2:31 PM, Junio C Hamano gits...@pobox.com wrote: I agree that there is no justification to write if 0 == something, when if something == 0 suffices. The latter reads better and that is why the phrase yoda condition was invented. But the situation is different when