wrapper.h: move declarations for wrapper.c functions from cache.h
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Mar 21, 2023 at 06:26 UTC
d5ebb50dcb2bae27cf9f233088f7258f21e72be7
68 files changed
+103
-34
apply.c
+1
@@ -26,6 +26,7 @@
26
#include "rerere.h"
27
#include "apply.h"
28
#include "entry.h"
29
+#include "wrapper.h"
30
31
struct gitdiff_data {
32
struct strbuf *root;
builtin/am.c
+1
@@ -38,6 +38,7 @@
38
#include "packfile.h"
39
#include "repository.h"
40
#include "pretty.h"
41
+#include "wrapper.h"
42
43
/**
44
* Returns the length of the first line of msg.
builtin/bisect.c
+1
@@ -11,6 +11,7 @@
11
#include "prompt.h"
12
#include "quote.h"
13
#include "revision.h"
14
+#include "wrapper.h"
15
16
static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
17
static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")
builtin/branch.c
+1
@@ -26,6 +26,7 @@
26
#include "worktree.h"
27
#include "help.h"
28
#include "commit-reach.h"
29
+#include "wrapper.h"
30
31
static const char * const builtin_branch_usage[] = {
32
N_("git branch [<options>] [-r | -a] [--merged] [--no-merged]"),
builtin/bugreport.c
+1
-1
@@ -8,7 +8,7 @@
8
#include "hook.h"
9
#include "hook-list.h"
10
#include "diagnose.h"
11
-
11
+#include "wrapper.h"
12
13
static void get_system_info(struct strbuf *sys_info)
14
{
builtin/config.c
+1
@@ -9,6 +9,7 @@
9
#include "urlmatch.h"
10
#include "quote.h"
11
#include "worktree.h"
12
+#include "wrapper.h"
13
14
static const char *const builtin_config_usage[] = {
15
N_("git config [<options>]"),
builtin/credential-cache.c
+1
@@ -1,6 +1,7 @@
1
#include "builtin.h"
2
#include "gettext.h"
3
#include "parse-options.h"
4
+#include "wrapper.h"
5
6
#ifndef NO_UNIX_SOCKETS
7
builtin/difftool.c
+1
@@ -27,6 +27,7 @@
27
#include "object-store.h"
28
#include "dir.h"
29
#include "entry.h"
30
+#include "wrapper.h"
31
32
static int trust_exit_code;
33
builtin/fast-import.c
+1
@@ -23,6 +23,7 @@
23
#include "commit-reach.h"
24
#include "khash.h"
25
#include "date.h"
26
+#include "wrapper.h"
27
28
#define PACK_ID_BITS 16
29
#define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
builtin/fmt-merge-msg.c
+1
@@ -3,6 +3,7 @@
3
#include "fmt-merge-msg.h"
4
#include "gettext.h"
5
#include "parse-options.h"
6
+#include "wrapper.h"
7
8
static const char * const fmt_merge_msg_usage[] = {
9
N_("git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]"),
builtin/gc.c
+1
@@ -35,6 +35,7 @@
35
#include "exec-cmd.h"
36
#include "gettext.h"
37
#include "hook.h"
38
+#include "wrapper.h"
39
40
#define FAILED_RUN "failed to run %s"
41
builtin/get-tar-commit-id.c
+1
@@ -6,6 +6,7 @@
6
#include "tar.h"
7
#include "builtin.h"
8
#include "quote.h"
9
+#include "wrapper.h"
10
11
static const char builtin_get_tar_commit_id_usage[] =
12
"git get-tar-commit-id";
builtin/index-pack.c
+1
@@ -19,6 +19,7 @@
19
#include "object-store.h"
20
#include "replace-object.h"
21
#include "promisor-remote.h"
22
+#include "wrapper.h"
23
24
static const char index_pack_usage[] =
25
"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
builtin/init-db.c
+1
@@ -12,6 +12,7 @@
12
#include "exec-cmd.h"
13
#include "parse-options.h"
14
#include "worktree.h"
15
+#include "wrapper.h"
16
17
#ifndef DEFAULT_GIT_TEMPLATE_DIR
18
#define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
builtin/merge.c
+1
@@ -49,6 +49,7 @@
49
#include "commit-reach.h"
50
#include "wt-status.h"
51
#include "commit-graph.h"
52
+#include "wrapper.h"
53
54
#define DEFAULT_TWOHEAD (1<<0)
55
#define DEFAULT_OCTOPUS (1<<1)
builtin/pack-objects.c
+1
@@ -40,6 +40,7 @@
40
#include "shallow.h"
41
#include "promisor-remote.h"
42
#include "pack-mtimes.h"
43
+#include "wrapper.h"
44
45
/*
46
* Objects we are going to pack are collected in the `to_pack` structure.
builtin/rebase.c
+1
@@ -32,6 +32,7 @@
32
#include "rebase-interactive.h"
33
#include "reset.h"
34
#include "hook.h"
35
+#include "wrapper.h"
36
37
static char const * const builtin_rebase_usage[] = {
38
N_("git rebase [-i] [options] [--exec <cmd>] "
builtin/receive-pack.c
+1
@@ -33,6 +33,7 @@
33
#include "commit-reach.h"
34
#include "worktree.h"
35
#include "shallow.h"
36
+#include "wrapper.h"
37
38
static const char * const receive_pack_usage[] = {
39
N_("git receive-pack <git-dir>"),
builtin/rerere.c
+1
@@ -6,6 +6,7 @@
6
#include "parse-options.h"
7
#include "string-list.h"
8
#include "rerere.h"
9
+#include "wrapper.h"
10
#include "xdiff/xdiff.h"
11
#include "xdiff-interface.h"
12
#include "pathspec.h"
builtin/unpack-file.c
+1
@@ -2,6 +2,7 @@
2
#include "config.h"
3
#include "hex.h"
4
#include "object-store.h"
5
+#include "wrapper.h"
6
7
static char *create_temp_file(struct object_id *oid)
8
{
builtin/worktree.c
+1
@@ -16,6 +16,7 @@
16
#include "submodule.h"
17
#include "utf8.h"
18
#include "worktree.h"
19
+#include "wrapper.h"
20
#include "quote.h"
21
22
#define BUILTIN_WORKTREE_ADD_USAGE \
cache.h
-32
@@ -1085,10 +1085,6 @@ const char *repo_find_unique_abbrev(struct repository *r, const struct object_id
1085
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
1086
#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
1087
1088
-/* set default permissions by passing mode arguments to open(2) */
1089
-int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
1090
-int git_mkstemp_mode(char *pattern, int mode);
1091
-
1088
/*
1089
* NOTE NOTE NOTE!!
1090
*
@@ -1423,31 +1419,6 @@ static inline int batch_fsync_enabled(enum fsync_component component)
1419
return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH);
1420
}
1421
1426
-ssize_t read_in_full(int fd, void *buf, size_t count);
1427
-ssize_t write_in_full(int fd, const void *buf, size_t count);
1428
-ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset);
1429
-
1430
-static inline ssize_t write_str_in_full(int fd, const char *str)
1431
-{
1432
- return write_in_full(fd, str, strlen(str));
1433
-}
1434
-
1435
-/**
1436
- * Open (and truncate) the file at path, write the contents of buf to it,
1437
- * and close it. Dies if any errors are encountered.
1438
- */
1439
-void write_file_buf(const char *path, const char *buf, size_t len);
1440
-
1441
-/**
1442
- * Like write_file_buf(), but format the contents into a buffer first.
1443
- * Additionally, write_file() will append a newline if one is not already
1444
- * present, making it convenient to write text files:
1445
- *
1446
- * write_file(path, "counter: %d", ctr);
1447
- */
1448
-__attribute__((format (printf, 2, 3)))
1449
-void write_file(const char *path, const char *fmt, ...);
1450
-
1422
/* pager.c */
1423
void setup_pager(void);
1424
int pager_in_use(void);
@@ -1571,7 +1542,4 @@ int versioncmp(const char *s1, const char *s2);
1542
*/
1543
int print_sha1_ellipsis(void);
1544
1574
-/* Return 1 if the file is empty or does not exists, 0 otherwise. */
1575
-int is_empty_or_missing_file(const char *filename);
1576
-
1545
#endif /* CACHE_H */
commit-graph.c
+1
@@ -22,6 +22,7 @@
22
#include "json-writer.h"
23
#include "trace2.h"
24
#include "chunk-format.h"
25
+#include "wrapper.h"
26
27
void git_test_write_commit_graph_or_die(void)
28
{
compat/mingw.c
+1
@@ -11,6 +11,7 @@
11
#include "../alloc.h"
12
#include "win32/lazyload.h"
13
#include "../config.h"
14
+#include "../wrapper.h"
15
#include "dir.h"
16
#include "gettext.h"
17
#define SECURITY_WIN32
compat/terminal.c
+1
@@ -6,6 +6,7 @@
6
#include "run-command.h"
7
#include "string-list.h"
8
#include "hashmap.h"
9
+#include "wrapper.h"
10
11
#if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE)
12
config.c
+1
@@ -28,6 +28,7 @@
28
#include "replace-object.h"
29
#include "refs.h"
30
#include "worktree.h"
31
+#include "wrapper.h"
32
33
struct config_source {
34
struct config_source *prev;
convert.c
+1
@@ -11,6 +11,7 @@
11
#include "sub-process.h"
12
#include "utf8.h"
13
#include "ll-merge.h"
14
+#include "wrapper.h"
15
16
/*
17
* convert.c - convert a file when checking it out and checking it in.
copy.c
+1
@@ -1,4 +1,5 @@
1
#include "cache.h"
2
+#include "wrapper.h"
3
4
int copy_fd(int ifd, int ofd)
5
{
csum-file.c
+1
@@ -10,6 +10,7 @@
10
#include "cache.h"
11
#include "progress.h"
12
#include "csum-file.h"
13
+#include "wrapper.h"
14
15
static void verify_buffer_or_die(struct hashfile *f,
16
const void *buf,
daemon.c
+1
@@ -6,6 +6,7 @@
6
#include "run-command.h"
7
#include "strbuf.h"
8
#include "string-list.h"
9
+#include "wrapper.h"
10
11
#ifdef NO_INITGROUPS
12
#define initgroups(x, y) (0) /* nothing */
diff.c
+1
@@ -33,6 +33,7 @@
33
#include "promisor-remote.h"
34
#include "dir.h"
35
#include "strmap.h"
36
+#include "wrapper.h"
37
38
#ifdef NO_FAST_WORKING_DIRECTORY
39
#define FAST_WORKING_DIRECTORY 0
dir.c
+1
@@ -21,6 +21,7 @@
21
#include "ewah/ewok.h"
22
#include "fsmonitor.h"
23
#include "submodule-config.h"
24
+#include "wrapper.h"
25
26
/*
27
* Tells read_directory_recursive how a file or directory should be treated.
entry.c
+1
@@ -10,6 +10,7 @@
10
#include "fsmonitor.h"
11
#include "entry.h"
12
#include "parallel-checkout.h"
13
+#include "wrapper.h"
14
15
static void create_directories(const char *path, int path_len,
16
const struct checkout *state)
environment.c
+1
@@ -23,6 +23,7 @@
23
#include "tmp-objdir.h"
24
#include "chdir-notify.h"
25
#include "shallow.h"
26
+#include "wrapper.h"
27
28
int trust_executable_bit = 1;
29
int trust_ctime = 1;
fetch-pack.c
+1
@@ -30,6 +30,7 @@
30
#include "commit-graph.h"
31
#include "sigchain.h"
32
#include "mergesort.h"
33
+#include "wrapper.h"
34
35
static int transfer_unpack_limit = -1;
36
static int fetch_unpack_limit = -1;
gpg-interface.c
+1
@@ -10,6 +10,7 @@
10
#include "sigchain.h"
11
#include "tempfile.h"
12
#include "alias.h"
13
+#include "wrapper.h"
14
15
static int git_gpg_config(const char *, const char *, void *);
16
http-backend.c
+1
@@ -16,6 +16,7 @@
16
#include "object-store.h"
17
#include "protocol.h"
18
#include "date.h"
19
+#include "wrapper.h"
20
21
static const char content_type[] = "Content-Type";
22
static const char content_length[] = "Content-Length";
imap-send.c
+1
@@ -28,6 +28,7 @@
28
#include "gettext.h"
29
#include "run-command.h"
30
#include "parse-options.h"
31
+#include "wrapper.h"
32
#if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)
33
typedef void *SSL;
34
#endif
ll-merge.c
+1
@@ -11,6 +11,7 @@
11
#include "run-command.h"
12
#include "ll-merge.h"
13
#include "quote.h"
14
+#include "wrapper.h"
15
16
struct ll_merge_driver;
17
merge-recursive.c
+1
@@ -30,6 +30,7 @@
30
#include "tag.h"
31
#include "tree-walk.h"
32
#include "unpack-trees.h"
33
+#include "wrapper.h"
34
#include "xdiff-interface.h"
35
36
struct merge_options_internal {
notes-merge.c
+1
@@ -15,6 +15,7 @@
15
#include "strbuf.h"
16
#include "notes-utils.h"
17
#include "commit-reach.h"
18
+#include "wrapper.h"
19
20
struct notes_merge_pair {
21
struct object_id obj, base, local, remote;
object-file.c
+1
@@ -38,6 +38,7 @@
38
#include "promisor-remote.h"
39
#include "submodule.h"
40
#include "fsck.h"
41
+#include "wrapper.h"
42
43
/* The maximum size for an object header. */
44
#define MAX_HEADER_LEN 32
packfile.c
+1
@@ -20,6 +20,7 @@
20
#include "midx.h"
21
#include "commit-graph.h"
22
#include "promisor-remote.h"
23
+#include "wrapper.h"
24
25
char *odb_pack_name(struct strbuf *buf,
26
const unsigned char *hash,
parallel-checkout.c
+1
@@ -12,6 +12,7 @@
12
#include "streaming.h"
13
#include "thread-utils.h"
14
#include "trace2.h"
15
+#include "wrapper.h"
16
17
struct pc_worker {
18
struct child_process cp;
pkt-line.c
+1
@@ -3,6 +3,7 @@
3
#include "gettext.h"
4
#include "hex.h"
5
#include "run-command.h"
6
+#include "wrapper.h"
7
8
char packet_buffer[LARGE_PACKET_MAX];
9
static const char *packet_trace_prefix = "git";
read-cache.c
+1
@@ -32,6 +32,7 @@
32
#include "csum-file.h"
33
#include "promisor-remote.h"
34
#include "hook.h"
35
+#include "wrapper.h"
36
37
/* Mask for the name length in ce_flags in the on-disk index */
38
rebase-interactive.c
+1
@@ -7,6 +7,7 @@
7
#include "commit-slab.h"
8
#include "config.h"
9
#include "dir.h"
10
+#include "wrapper.h"
11
12
static const char edit_todo_list_advice[] =
13
N_("You can fix this with 'git rebase --edit-todo' "
refs.c
+1
@@ -24,6 +24,7 @@
24
#include "sigchain.h"
25
#include "date.h"
26
#include "commit.h"
27
+#include "wrapper.h"
28
29
/*
30
* List of all available backends
refs/files-backend.c
+2
-1
@@ -13,7 +13,8 @@
13
#include "../object.h"
14
#include "../dir.h"
15
#include "../chdir-notify.h"
16
-#include "worktree.h"
16
+#include "../worktree.h"
17
+#include "../wrapper.h"
18
19
/*
20
* This backend uses the following flags in `ref_update::flags` for
rerere.c
+1
@@ -16,6 +16,7 @@
16
#include "object-store.h"
17
#include "hash-lookup.h"
18
#include "strmap.h"
19
+#include "wrapper.h"
20
21
#define RESOLVED 0
22
#define PUNTED 1
sequencer.c
+1
@@ -41,6 +41,7 @@
41
#include "rebase-interactive.h"
42
#include "reset.h"
43
#include "branch.h"
44
+#include "wrapper.h"
45
46
#define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
47
server-info.c
+1
@@ -10,6 +10,7 @@
10
#include "packfile.h"
11
#include "object-store.h"
12
#include "strbuf.h"
13
+#include "wrapper.h"
14
15
struct update_info_ctx {
16
FILE *cur_fp;
shallow.c
+1
@@ -17,6 +17,7 @@
17
#include "list-objects.h"
18
#include "commit-reach.h"
19
#include "shallow.h"
20
+#include "wrapper.h"
21
22
void set_alternate_shallow_file(struct repository *r, const char *path, int override)
23
{
strbuf.c
+1
@@ -8,6 +8,7 @@
8
#include "string-list.h"
9
#include "utf8.h"
10
#include "date.h"
11
+#include "wrapper.h"
12
13
int starts_with(const char *str, const char *prefix)
14
{
streaming.c
+1
@@ -7,6 +7,7 @@
7
#include "object-store.h"
8
#include "replace-object.h"
9
#include "packfile.h"
10
+#include "wrapper.h"
11
12
typedef int (*open_istream_fn)(struct git_istream *,
13
struct repository *,
t/helper/test-delta.c
+1
@@ -12,6 +12,7 @@
12
#include "git-compat-util.h"
13
#include "delta.h"
14
#include "cache.h"
15
+#include "wrapper.h"
16
17
static const char usage_str[] =
18
"test-tool delta (-d|-p) <from_file> <data_file> <out_file>";
t/helper/test-fsmonitor-client.c
+1
@@ -9,6 +9,7 @@
9
#include "fsmonitor-ipc.h"
10
#include "thread-utils.h"
11
#include "trace2.h"
12
+#include "wrapper.h"
13
14
#ifndef HAVE_FSMONITOR_DAEMON_BACKEND
15
int cmd__fsmonitor_client(int argc, const char **argv)
t/helper/test-read-cache.c
+1
@@ -2,6 +2,7 @@
2
#include "test-tool.h"
3
#include "cache.h"
4
#include "config.h"
5
+#include "wrapper.h"
6
7
int cmd__read_cache(int argc, const char **argv)
8
{
tag.c
+1
@@ -8,6 +8,7 @@
8
#include "gpg-interface.h"
9
#include "hex.h"
10
#include "packfile.h"
11
+#include "wrapper.h"
12
13
const char *tag_type = "tag";
14
tempfile.c
+1
@@ -45,6 +45,7 @@
45
#include "cache.h"
46
#include "tempfile.h"
47
#include "sigchain.h"
48
+#include "wrapper.h"
49
50
static VOLATILE_LIST_HEAD(tempfile_list);
51
trace.c
+1
@@ -24,6 +24,7 @@
24
#include "cache.h"
25
#include "abspath.h"
26
#include "quote.h"
27
+#include "wrapper.h"
28
29
struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
30
struct trace_key trace_perf_key = TRACE_KEY_INIT(PERFORMANCE);
transport-helper.c
+1
@@ -16,6 +16,7 @@
16
#include "refspec.h"
17
#include "transport-internal.h"
18
#include "protocol.h"
19
+#include "wrapper.h"
20
21
static int debug;
22
transport.c
+1
@@ -26,6 +26,7 @@
26
#include "object-store.h"
27
#include "color.h"
28
#include "bundle-uri.h"
29
+#include "wrapper.h"
30
31
static int transport_use_color = -1;
32
static char transport_colors[][COLOR_MAXLEN] = {
usage.c
+1
@@ -5,6 +5,7 @@
5
*/
6
#include "cache.h"
7
#include "gettext.h"
8
+#include "wrapper.h"
9
10
static void vreportf(const char *prefix, const char *err, va_list params)
11
{
worktree.c
+1
@@ -9,6 +9,7 @@
9
#include "dir.h"
10
#include "wt-status.h"
11
#include "config.h"
12
+#include "wrapper.h"
13
14
void free_worktrees(struct worktree **worktrees)
15
{
wrapper.c
+1
@@ -5,6 +5,7 @@
5
#include "abspath.h"
6
#include "config.h"
7
#include "gettext.h"
8
+#include "wrapper.h"
9
10
static intmax_t count_fsync_writeout_only;
11
static intmax_t count_fsync_hardware_flush;
wrapper.h
new
+36
@@ -0,0 +1,36 @@
1
+#ifndef WRAPPER_H
2
+#define WRAPPER_H
3
+
4
+/* set default permissions by passing mode arguments to open(2) */
5
+int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
6
+int git_mkstemp_mode(char *pattern, int mode);
7
+
8
+ssize_t read_in_full(int fd, void *buf, size_t count);
9
+ssize_t write_in_full(int fd, const void *buf, size_t count);
10
+ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset);
11
+
12
+static inline ssize_t write_str_in_full(int fd, const char *str)
13
+{
14
+ return write_in_full(fd, str, strlen(str));
15
+}
16
+
17
+/**
18
+ * Open (and truncate) the file at path, write the contents of buf to it,
19
+ * and close it. Dies if any errors are encountered.
20
+ */
21
+void write_file_buf(const char *path, const char *buf, size_t len);
22
+
23
+/**
24
+ * Like write_file_buf(), but format the contents into a buffer first.
25
+ * Additionally, write_file() will append a newline if one is not already
26
+ * present, making it convenient to write text files:
27
+ *
28
+ * write_file(path, "counter: %d", ctr);
29
+ */
30
+__attribute__((format (printf, 2, 3)))
31
+void write_file(const char *path, const char *fmt, ...);
32
+
33
+/* Return 1 if the file is empty or does not exists, 0 otherwise. */
34
+int is_empty_or_missing_file(const char *filename);
35
+
36
+#endif /* WRAPPER_H */
write-or-die.c
+1
@@ -1,6 +1,7 @@
1
#include "cache.h"
2
#include "config.h"
3
#include "run-command.h"
4
+#include "wrapper.h"
5
6
/*
7
* Some cases use stdio, but want to flush after the write