-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit.c
More file actions
46 lines (37 loc) · 951 Bytes
/
git.c
File metadata and controls
46 lines (37 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* System-git wrappers -- see git.h for the contract. Moved here
* from cmd/repo/repo.c so consumers outside the repo namespace (e.g.
* @c ice idf component for git-sourced components) don't have to
* reach across a namespace boundary.
*/
#include "git.h"
#include <unistd.h>
#include "ice.h"
int git_run(const char *dir, const char **argv)
{
struct process proc = PROCESS_INIT;
proc.argv = argv;
proc.dir = dir;
return process_run(&proc);
}
int git_capture(const char *dir, const char **argv, struct sbuf *out)
{
struct process proc = PROCESS_INIT;
char buf[4096];
ssize_t n;
int rc;
proc.argv = argv;
proc.dir = dir;
proc.pipe_out = 1;
if (process_start(&proc))
return -1;
while ((n = read(proc.out, buf, sizeof(buf))) > 0)
sbuf_add(out, buf, (size_t)n);
rc = process_finish(&proc);
return rc;
}