-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit.h
More file actions
54 lines (49 loc) · 1.59 KB
/
Copy pathgit.h
File metadata and controls
54 lines (49 loc) · 1.59 KB
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
47
48
49
50
51
52
53
54
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file git.h
* @brief Thin wrappers for invoking the system @c git binary.
*
* @c git is a hard runtime dependency for ice (same as for
* ESP-IDF's setup flow). Rather than linking libgit or implementing
* pack-file I/O ourselves, we shell out to the system binary and
* consume its stdout. The wrappers here just assemble an argv and
* hand it to @c process_run() / @c process_start().
*
* Typical use:
*
* const char *argv[] = { "git", "clone", url, dest, NULL };
* if (git_run(NULL, argv) != 0) die("clone failed");
*
* struct sbuf head = SBUF_INIT;
* const char *rev[] = { "git", "rev-parse", "HEAD", NULL };
* if (git_capture(dir, rev, &head) == 0)
* printf("head = %s\n", head.buf);
*
* @c argv must be NULL-terminated and include @c "git" as @c argv[0].
*/
#ifndef GIT_H
#define GIT_H
struct sbuf;
/**
* @brief Run a git command in @p dir.
*
* stdout/stderr inherit the parent's descriptors. If @p dir is NULL
* the command runs in the parent's working directory.
*
* @return the child's exit code (0 on success), or -1 on spawn failure.
*/
int git_run(const char *dir, const char **argv);
/**
* @brief Run a git command in @p dir and capture its stdout.
*
* Appends stdout bytes to @p out (caller initialises via SBUF_INIT).
* stderr is left attached to the parent's.
*
* @return the child's exit code (0 on success), or -1 on spawn failure.
*/
int git_capture(const char *dir, const char **argv, struct sbuf *out);
#endif /* GIT_H */