Skip to content

Conversation

listx
Copy link

@listx listx commented Jan 12, 2024

cc: Jeff King peff@peff.net

In d70a9eb (strvec: rename struct fields, 2020-07-28), we renamed the
"argv" member to "v". In the same patch we also did the following rename
in strvec.c:

    -void strvec_pushv(struct strvec *array, const char **argv)
    +void strvec_pushv(struct strvec *array, const char **items)

and it appears that this s/argv/items operation was erroneously applied
to strvec.h.

Rename "items" to "v".

Signed-off-by: Linus Arver <linusa@google.com>
@listx
Copy link
Author

listx commented Jan 12, 2024

/preview

Copy link

gitgitgadget bot commented Jan 12, 2024

Preview email sent as pull.1640.git.1705041969928.gitgitgadget@gmail.com

@listx
Copy link
Author

listx commented Jan 12, 2024

/preview

Copy link

gitgitgadget bot commented Jan 12, 2024

Preview email sent as pull.1640.git.1705042170325.gitgitgadget@gmail.com

@listx
Copy link
Author

listx commented Jan 12, 2024

/submit

Copy link

gitgitgadget bot commented Jan 12, 2024

Submitted as pull.1640.git.1705043195997.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1640/listx/fix-strvec-typos-v1

To fetch this version to local tag pr-1640/listx/fix-strvec-typos-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1640/listx/fix-strvec-typos-v1

Copy link

gitgitgadget bot commented Jan 12, 2024

On the Git mailing list, Jeff King wrote (reply to this):

On Fri, Jan 12, 2024 at 07:06:35AM +0000, Linus Arver via GitGitGadget wrote:

> From: Linus Arver <linusa@google.com>
> 
> In d70a9eb611 (strvec: rename struct fields, 2020-07-28), we renamed the
> "argv" member to "v". In the same patch we also did the following rename
> in strvec.c:
> 
>     -void strvec_pushv(struct strvec *array, const char **argv)
>     +void strvec_pushv(struct strvec *array, const char **items)
> 
> and it appears that this s/argv/items operation was erroneously applied
> to strvec.h.
> 
> Rename "items" to "v".

Good catch. The source of the problem is that the patch originally used
"items" in the struct, too, but after review we settled on the more
concise "v". I'd almost certainly have then flipped the name in the
struct definition and relied on the compiler to help find the fallout.
But of course it doesn't look in comments. :)

As you note, we still call use "items" for the vector passed in to
pushv. I think that is OK, and there is no real need to use the terse
"v" there (it is also purely internal; the declaration in strvec.h does
not name it at all).

So this patch looks great to me. Thanks!

-Peff

Copy link

gitgitgadget bot commented Jan 12, 2024

User Jeff King <peff@peff.net> has been added to the cc: list.

Copy link

gitgitgadget bot commented Jan 12, 2024

On the Git mailing list, Linus Arver wrote (reply to this):

Jeff King <peff@peff.net> writes:

> The source of the problem is that the patch originally used
> "items" in the struct, too

Ah, that makes sense.

> As you note, we still call use "items" for the vector passed in to
> pushv. I think that is OK, and there is no real need to use the terse
> "v" there (it is also purely internal; the declaration in strvec.h does
> not name it at all).

Indeed. Perhaps I should have included this in my commit message.

Side note: should we start naming the parameters in strvec.h? I would
think that it wouldn't hurt at this point (as the API is pretty stable).
If you think that's worth it, I could reroll to include that in this
series (and also improve my commit message for this patch).

Copy link

gitgitgadget bot commented Jan 12, 2024

On the Git mailing list, Junio C Hamano wrote (reply to this):

Linus Arver <linusa@google.com> writes:

> Side note: should we start naming the parameters in strvec.h? I would
> think that it wouldn't hurt at this point (as the API is pretty stable).
> If you think that's worth it, I could reroll to include that in this
> series (and also improve my commit message for this patch).

I am not sure if it adds more value to outweigh the cost of
churning.  When the meaning of the parameters are obvious only by
looking at their types, a prototype without parameter names is
easier to maintain, by allowing the parameters to be renamed only
once in the implementation.  When the meaning of parameters are not
obvious from their types, we do want them to be named so that you
only have to refer to the header files to know the argument order.

"void *calloc(size_t, size_t)" would not tell us if we should pass
the size of individual element or the number of elements first, and
writing "void *calloc(size_t nmemb, size_t size)" to make it more
obvious is a good idea.

On the other hand, "void *realloc(void *, size_t)" is sufficient to
tell us that we are passing a pointer as the first parameter and the
desired size as the second parameter, without them having any name.

Are there functions declared in strvec.h you have in mind that their
parameters are confusing and hard to guess what they mean?  

Thanks.

Copy link

gitgitgadget bot commented Jan 13, 2024

This branch is now known as la/strvec-comment-fix.

Copy link

gitgitgadget bot commented Jan 13, 2024

This patch series was integrated into seen via git@83a49ac.

@gitgitgadget gitgitgadget bot added the seen label Jan 13, 2024
Copy link

gitgitgadget bot commented Jan 13, 2024

On the Git mailing list, Linus Arver wrote (reply to this):

Junio C Hamano <gitster@pobox.com> writes:

> Linus Arver <linusa@google.com> writes:
>
>> Side note: should we start naming the parameters in strvec.h? I would
>> think that it wouldn't hurt at this point (as the API is pretty stable).
>> If you think that's worth it, I could reroll to include that in this
>> series (and also improve my commit message for this patch).
>
> I am not sure if it adds more value to outweigh the cost of
> churning.  When the meaning of the parameters are obvious only by
> looking at their types, a prototype without parameter names is
> easier to maintain, by allowing the parameters to be renamed only
> once in the implementation.  When the meaning of parameters are not
> obvious from their types, we do want them to be named so that you
> only have to refer to the header files to know the argument order.

This sounds like a good rule to me.

> "void *calloc(size_t, size_t)" would not tell us if we should pass
> the size of individual element or the number of elements first, and
> writing "void *calloc(size_t nmemb, size_t size)" to make it more
> obvious is a good idea.
>
> On the other hand, "void *realloc(void *, size_t)" is sufficient to
> tell us that we are passing a pointer as the first parameter and the
> desired size as the second parameter, without them having any name.

Thanks for the illuminating examples. Agreed.

> Are there functions declared in strvec.h you have in mind that their
> parameters are confusing and hard to guess what they mean?

TBH I only learned recently (while writing the patch in this thread)
that parameter names in prototypes were optional. I got a little
confused initially when looking at strvec.h for the first time because
none of the parameters were named. Having thought a bit more about these
functions, none of them have repeated types like in your example where
naming is warranted, so I think they're fine as is.

OTOH if we were treating these .h files as something meant for direct
external consumption (that is, if strvec.h is libified and external
users outside of Git are expected to use it directly as their first
point of documentation), at that point it might make sense to name the
parameters (akin to the style of manpages for syscalls). But I imagine
at that point we would have some other means of developer docs (beyond
raw header files) for libified parts of Git, so even in that case it's
probably fine to keep things as is.

Thanks.

Copy link

gitgitgadget bot commented Jan 13, 2024

On the Git mailing list, Jeff King wrote (reply to this):

On Fri, Jan 12, 2024 at 04:37:46PM -0800, Linus Arver wrote:

> OTOH if we were treating these .h files as something meant for direct
> external consumption (that is, if strvec.h is libified and external
> users outside of Git are expected to use it directly as their first
> point of documentation), at that point it might make sense to name the
> parameters (akin to the style of manpages for syscalls). But I imagine
> at that point we would have some other means of developer docs (beyond
> raw header files) for libified parts of Git, so even in that case it's
> probably fine to keep things as is.

I think this is mostly orthogonal to libification. Whether the audience
is other parts of Git or users outside of Git, they need to know how to
call the function. Our main source of documentation there is comments
above the declaration (we've marked these with "/**" which would allow a
parser to pull them into a separate doc file, but AFAIK in the 9 years
since we started that convention, nobody has bothered to write such a
script).

Naming the parameters can help when writing those comments, because you
can then refer to them (e.g., see the comment above strbuf_addftime).
Even without that, I think they can be helpful, but I don't think I'd
bother adding them in unless taking a pass over the whole file, looking
for comments that do not sufficiently explain their matching functions.

I don't doubt that some of that would be necessary for libification,
just to increase the quality of the documentation. But I think it's
largely separate from the patch in this thread.

-Peff

Copy link

gitgitgadget bot commented Jan 14, 2024

On the Git mailing list, Linus Arver wrote (reply to this):

Jeff King <peff@peff.net> writes:

> On Fri, Jan 12, 2024 at 04:37:46PM -0800, Linus Arver wrote:
>
>> OTOH if we were treating these .h files as something meant for direct
>> external consumption (that is, if strvec.h is libified and external
>> users outside of Git are expected to use it directly as their first
>> point of documentation), at that point it might make sense to name the
>> parameters (akin to the style of manpages for syscalls). But I imagine
>> at that point we would have some other means of developer docs (beyond
>> raw header files) for libified parts of Git, so even in that case it's
>> probably fine to keep things as is.
>
> I think this is mostly orthogonal to libification. Whether the audience
> is other parts of Git or users outside of Git, they need to know how to
> call the function. Our main source of documentation there is comments
> above the declaration (we've marked these with "/**" which would allow a
> parser to pull them into a separate doc file, but AFAIK in the 9 years
> since we started that convention, nobody has bothered to write such a
> script).
>
> Naming the parameters can help when writing those comments, because you
> can then refer to them (e.g., see the comment above strbuf_addftime).
> Even without that, I think they can be helpful, but I don't think I'd
> bother adding them in unless taking a pass over the whole file, looking
> for comments that do not sufficiently explain their matching functions.

So in summary you are saying that the comments are the most important
source of documentation that we have currently, and unless naming the
parameters improves these comments, we shouldn't bother naming these
parameters. I agree.

> I don't doubt that some of that would be necessary for libification,
> just to increase the quality of the documentation. But I think it's
> largely separate from the patch in this thread.

I agree with both statements. Thanks.

Copy link

gitgitgadget bot commented Jan 16, 2024

This patch series was integrated into seen via git@4beaaf8.

Copy link

gitgitgadget bot commented Jan 16, 2024

There was a status update in the "New Topics" section about the branch la/strvec-comment-fix on the Git mailing list:

Comment fix.

Will merge to 'next'.
source: <pull.1640.git.1705043195997.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Jan 17, 2024

This patch series was integrated into seen via git@caf45d1.

Copy link

gitgitgadget bot commented Jan 18, 2024

This patch series was integrated into seen via git@54228f5.

Copy link

gitgitgadget bot commented Jan 18, 2024

This patch series was integrated into seen via git@ccbcffd.

Copy link

gitgitgadget bot commented Jan 20, 2024

This patch series was integrated into seen via git@c23331d.

Copy link

gitgitgadget bot commented Jan 20, 2024

This patch series was integrated into next via git@120ef16.

@gitgitgadget gitgitgadget bot added the next label Jan 20, 2024
Copy link

gitgitgadget bot commented Jan 20, 2024

There was a status update in the "Cooking" section about the branch la/strvec-comment-fix on the Git mailing list:

Comment fix.

Will merge to 'master'.
source: <pull.1640.git.1705043195997.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Jan 22, 2024

This patch series was integrated into seen via git@31b903d.

Copy link

gitgitgadget bot commented Jan 23, 2024

This patch series was integrated into seen via git@c081807.

Copy link

gitgitgadget bot commented Jan 23, 2024

This patch series was integrated into seen via git@ab28716.

Copy link

gitgitgadget bot commented Jan 24, 2024

There was a status update in the "Cooking" section about the branch la/strvec-comment-fix on the Git mailing list:

Comment fix.

Will merge to 'master'.
source: <pull.1640.git.1705043195997.gitgitgadget@gmail.com>

Copy link

gitgitgadget bot commented Jan 24, 2024

This patch series was integrated into seen via git@dcefc33.

Copy link

gitgitgadget bot commented Jan 26, 2024

This patch series was integrated into seen via git@46277e3.

Copy link

gitgitgadget bot commented Jan 26, 2024

This patch series was integrated into seen via git@bc554e6.

Copy link

gitgitgadget bot commented Jan 26, 2024

This patch series was integrated into master via git@bc554e6.

Copy link

gitgitgadget bot commented Jan 26, 2024

This patch series was integrated into next via git@bc554e6.

@gitgitgadget gitgitgadget bot added the master label Jan 26, 2024
@gitgitgadget gitgitgadget bot closed this Jan 26, 2024
Copy link

gitgitgadget bot commented Jan 26, 2024

Closed via bc554e6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant