]> git.ipfire.org Git - thirdparty/git.git/commit
reftable: wrap EXPECT macros in do/while
authorPatrick Steinhardt <ps@pks.im>
Mon, 11 Dec 2023 09:07:29 +0000 (10:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Dec 2023 15:23:15 +0000 (07:23 -0800)
commite32b8ece640fc700c5a74dd53e6cae8b1a893a6d
treeb4847d1138284eba0b9a20ce460c37c19994f6e6
parent564d0252ca632e0264ed670534a51d18a689ef5d
reftable: wrap EXPECT macros in do/while

The `EXPECT` macros used by the reftable test framework are all using a
single `if` statement with the actual condition. This results in weird
syntax when using them in if/else statements like the following:

```
if (foo)
EXPECT(foo == 2)
else
EXPECT(bar == 2)
```

Note that there need not be a trailing semicolon. Furthermore, it is not
immediately obvious whether the else now belongs to the `if (foo)` or
whether it belongs to the expanded `if (foo == 2)` from the macro.

Fix this by wrapping the macros in a do/while loop.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/test_framework.h