Re: [PATCH 2/2] ref-filter: 'contents:trailers' show error if `:` is missing

2 messages, 2 authors, 2020-08-20 · open the first message on its own page

Re: [PATCH 2/2] ref-filter: 'contents:trailers' show error if `:` is missing

From: Junio C Hamano <hidden>
Date: 2020-08-19 22:08:50

Eric Sunshine [off-list ref] writes:
On Wed, Aug 19, 2020 at 3:07 PM Junio C Hamano [off-list ref] wrote:
quoted
Junio C Hamano [off-list ref] writes:
quoted
"Hariom Verma via GitGitGadget" [off-list ref] writes:
quoted
+static int check_format_field(const char *arg, const char *field, const char **option)
+{
+            else if (*opt == ':') {
+                    *option = ++opt;
+                    return 1;
+            }
And the helper does not have such a breakage.  It looks good.
One minor comment (not worth a re-roll): I personally found:

    *option = ++opt;

more confusing than:

    *option = opt + 1;

The `++opt` places a higher cognitive load on the reader. As a
reviewer, I had to go back and carefully reread the function to see if
the side-effect of `++opt` had some impact which I didn't notice on
the first readthrough. The simpler `opt + 1` does not have a
side-effect, thus is easier to reason about (and doesn't require me to
re-study the function when I encounter it).
That makes the two of us ... thanks.

Re: [PATCH 2/2] ref-filter: 'contents:trailers' show error if `:` is missing

From: Hariom verma <hidden>
Date: 2020-08-20 17:19:32

Hi,

On Thu, Aug 20, 2020 at 3:38 AM Junio C Hamano [off-list ref] wrote:
Eric Sunshine [off-list ref] writes:
quoted
On Wed, Aug 19, 2020 at 3:07 PM Junio C Hamano [off-list ref] wrote:
quoted
Junio C Hamano [off-list ref] writes:
quoted
"Hariom Verma via GitGitGadget" [off-list ref] writes:
quoted
+static int check_format_field(const char *arg, const char *field, const char **option)
+{
+            else if (*opt == ':') {
+                    *option = ++opt;
+                    return 1;
+            }
And the helper does not have such a breakage.  It looks good.
One minor comment (not worth a re-roll): I personally found:

    *option = ++opt;

more confusing than:

    *option = opt + 1;

The `++opt` places a higher cognitive load on the reader. As a
reviewer, I had to go back and carefully reread the function to see if
the side-effect of `++opt` had some impact which I didn't notice on
the first readthrough. The simpler `opt + 1` does not have a
side-effect, thus is easier to reason about (and doesn't require me to
re-study the function when I encounter it).
That makes the two of us ... thanks.
It seems like the score is 2-0.
I guess I'm going with winning side.

Will be improved in next version.

Thanks,
Hariom
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help