aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-07-31 15:54:31 -0700
committerJunio C Hamano <gitster@pobox.com>2025-08-02 22:44:58 -0700
commitd6fd08bd760711d51b98f9ad98c3cd94d90d2618 (patch)
treeb8891903621f50cb102808816c239ba3da6a51e1
parentenvironment: do not use strbuf_split*() (diff)
downloadgit-d6fd08bd760711d51b98f9ad98c3cd94d90d2618.tar.gz
git-d6fd08bd760711d51b98f9ad98c3cd94d90d2618.zip
sub-process: do not use strbuf_split*()
The code to read status from subprocess reads one packet line and tries to find "status=<foo>". It is way overkill to split the line into an array of two strbufs to extract <foo>. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--sub-process.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/sub-process.c b/sub-process.c
index 1daf5a9752..83bf0a0e82 100644
--- a/sub-process.c
+++ b/sub-process.c
@@ -30,23 +30,20 @@ struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const ch
int subprocess_read_status(int fd, struct strbuf *status)
{
- struct strbuf **pair;
- char *line;
int len;
for (;;) {
+ char *line;
+ const char *value;
+
len = packet_read_line_gently(fd, NULL, &line);
if ((len < 0) || !line)
break;
- pair = strbuf_split_str(line, '=', 2);
- if (pair[0] && pair[0]->len && pair[1]) {
+ if (skip_prefix(line, "status=", &value)) {
/* the last "status=<foo>" line wins */
- if (!strcmp(pair[0]->buf, "status=")) {
- strbuf_reset(status);
- strbuf_addbuf(status, pair[1]);
- }
+ strbuf_reset(status);
+ strbuf_addstr(status, value);
}
- strbuf_list_free(pair);
}
return (len < 0) ? len : 0;