]> git.ipfire.org Git - thirdparty/git.git/commit
gpg-interface: do not use misdesigned strbuf_split*()
authorOlamide Caleb Bello <belkid98@gmail.com>
Thu, 23 Oct 2025 11:13:47 +0000 (11:13 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Oct 2025 16:26:12 +0000 (09:26 -0700)
commit2ab72a16d9e3f1aca223f5da5aaf8b533d8fa35a
tree4a0c324059d6dbdc80c0f8b9ea3101bf86e2aa42
parentbee1bdd5888aafd1a8d51df000170f18b6a299ac
gpg-interface: do not use misdesigned strbuf_split*()

In get_default_ssh_signing_key(), the default ssh signing key is
retrieved in `key_stdout` buf, which is then split using
strbuf_split_max() into up to two strbufs at a new line and the first
strbuf is returned as a `char *`and not a strbuf.
This makes the function lack the use of strbuf API as no edits are
performed on the split tokens.

Simplify the process of retrieving and returning the desired line by
using strchr() to isolate the line and xmemdupz() to return a copy of the
line. This removes the roundabout way of splitting the string into
strbufs, just to return the line.

Reported-by: Junio Hamano <gitster@pobox.com>
Helped-by: Christian Couder <christian.couder@gmail.com>
Helped-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Signed-off-by: Olamide Caleb Bello <belkid98@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gpg-interface.c