From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: Olamide Caleb Bello <belkid98@gmail.com>,
git@vger.kernel.org, usmanakinyemi202@gmail.com,
kristofferhaugsbakk@fastmail.com
Subject: Re: [Outreachy PATCH v5 2/2] gpg-interface: do not use misdesigned strbuf_split*()
Date: Wed, 22 Oct 2025 10:44:09 -0700 [thread overview]
Message-ID: <xmqq4irqzv9y.fsf@gitster.g> (raw)
In-Reply-To: <CAP8UFD3OTMi6uxv+z4rTqJ4wVpmezSG2Yj8tZMpgptWaWU343w@mail.gmail.com> (Christian Couder's message of "Wed, 22 Oct 2025 16:03:50 +0200")
Christian Couder <christian.couder@gmail.com> writes:
>> @@ -887,19 +887,22 @@ static char *get_default_ssh_signing_key(void)
>> &key_stderr, 0);
>>
>> if (!ret) {
>> - keys = strbuf_split_max(&key_stdout, '\n', 2);
>> - if (keys[0] && is_literal_ssh_key(keys[0]->buf, &literal_key)) {
>> + begin = key_stdout.buf;
>> + new_line = strchr(begin, '\n');
>> + end = new_line ? new_line : strchr(begin, '\0');
>> + first_line = xmemdupz(begin, end - begin);
>
> That works but I wonder if something like the following is not a bit better:
>
> if (new_line)
> first_line = xmemdupz(begin, new_line - begin);
> else
> first_line = xstrdup(begin);
Yeah, that is certainly much easier to understand without even
reading and thinking.
Thanks.
next prev parent reply other threads:[~2025-10-22 17:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 22:55 [Outreachy PATCH v4 0/2] do not use strbuf_split*() Olamide Caleb Bello
2025-10-20 22:55 ` [Outreachy PATCH v4 1/2] gpg-interface: do not use misdesigned strbuf_split*() Olamide Caleb Bello
2025-10-21 6:46 ` Christian Couder
2025-10-21 6:51 ` Christian Couder
2025-10-21 11:18 ` Bello Olamide
2025-10-21 16:26 ` Junio C Hamano
2025-10-20 22:55 ` [Outreachy PATCH v4 2/2] gpg-interface: do not use misdesigned strbuf_split*() [Part 2] Olamide Caleb Bello
2025-10-21 7:01 ` Christian Couder
2025-10-21 12:12 ` Bello Olamide
2025-10-21 7:19 ` [Outreachy PATCH v4 0/2] do not use strbuf_split*() Christian Couder
2025-10-21 10:19 ` Bello Olamide
2025-10-21 17:13 ` Junio C Hamano
2025-10-22 7:16 ` Bello Olamide
2025-10-22 12:40 ` [Outreachy PATCH v5 0/2] do not use misdesigned strbuf_split*() Olamide Caleb Bello
2025-10-22 12:40 ` [Outreachy PATCH v5 1/2] gpg-interface: " Olamide Caleb Bello
2025-10-22 13:56 ` Christian Couder
2025-10-23 8:14 ` Bello Olamide
2025-10-22 12:40 ` [Outreachy PATCH v5 2/2] " Olamide Caleb Bello
2025-10-22 14:03 ` Christian Couder
2025-10-22 17:44 ` Junio C Hamano [this message]
2025-10-23 8:17 ` Bello Olamide
2025-10-23 11:13 ` [Outreachy PATCH v6 0/2] " Olamide Caleb Bello
2025-10-23 11:13 ` [Outreachy PATCH v6 1/2] gpg-interface: " Olamide Caleb Bello
2025-10-23 11:13 ` [Outreachy PATCH v6 2/2] " Olamide Caleb Bello
2025-10-23 16:27 ` [Outreachy PATCH v6 0/2] " Junio C Hamano
2025-10-24 13:25 ` Christian Couder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4irqzv9y.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=belkid98@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=usmanakinyemi202@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).