]> git.ipfire.org Git - thirdparty/git.git/commitdiff
wrapper.h: move declarations for wrapper.c functions from cache.h
authorElijah Newren <newren@gmail.com>
Tue, 21 Mar 2023 06:26:01 +0000 (06:26 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Mar 2023 17:56:53 +0000 (10:56 -0700)
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
68 files changed:
apply.c
builtin/am.c
builtin/bisect.c
builtin/branch.c
builtin/bugreport.c
builtin/config.c
builtin/credential-cache.c
builtin/difftool.c
builtin/fast-import.c
builtin/fmt-merge-msg.c
builtin/gc.c
builtin/get-tar-commit-id.c
builtin/index-pack.c
builtin/init-db.c
builtin/merge.c
builtin/pack-objects.c
builtin/rebase.c
builtin/receive-pack.c
builtin/rerere.c
builtin/unpack-file.c
builtin/worktree.c
cache.h
commit-graph.c
compat/mingw.c
compat/terminal.c
config.c
convert.c
copy.c
csum-file.c
daemon.c
diff.c
dir.c
entry.c
environment.c
fetch-pack.c
gpg-interface.c
http-backend.c
imap-send.c
ll-merge.c
merge-recursive.c
notes-merge.c
object-file.c
packfile.c
parallel-checkout.c
pkt-line.c
read-cache.c
rebase-interactive.c
refs.c
refs/files-backend.c
rerere.c
sequencer.c
server-info.c
shallow.c
strbuf.c
streaming.c
t/helper/test-delta.c
t/helper/test-fsmonitor-client.c
t/helper/test-read-cache.c
tag.c
tempfile.c
trace.c
transport-helper.c
transport.c
usage.c
worktree.c
wrapper.c
wrapper.h [new file with mode: 0644]
write-or-die.c

diff --git a/apply.c b/apply.c
index e5e11b85793e3b29d2947f352e38fe6983d76baf..373565a7bafb6d96c37e52691f15f48122f5b41f 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -26,6 +26,7 @@
 #include "rerere.h"
 #include "apply.h"
 #include "entry.h"
+#include "wrapper.h"
 
 struct gitdiff_data {
        struct strbuf *root;
index 14347ecf9aa3dc22f6bee283db7f0782ccf11b04..37f82b3eb424cc60bf5e2e881d56e2514492c238 100644 (file)
@@ -38,6 +38,7 @@
 #include "packfile.h"
 #include "repository.h"
 #include "pretty.h"
+#include "wrapper.h"
 
 /**
  * Returns the length of the first line of msg.
index 09188e554b308e4b64c1c62bd66ce6e04c949557..31cc57e45ba9b97107cf90eab2fc749f4d502694 100644 (file)
@@ -11,6 +11,7 @@
 #include "prompt.h"
 #include "quote.h"
 #include "revision.h"
+#include "wrapper.h"
 
 static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
 static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")
index 56dbee97d20db5b146b12a6f6a0b28dedf0755e0..98475ea5325c18370016010bf24a300677108154 100644 (file)
@@ -26,6 +26,7 @@
 #include "worktree.h"
 #include "help.h"
 #include "commit-reach.h"
+#include "wrapper.h"
 
 static const char * const builtin_branch_usage[] = {
        N_("git branch [<options>] [-r | -a] [--merged] [--no-merged]"),
index b5dfad4e12a6d3d5e94e971a3dc226739ea9cf22..160590e4ef609a0d0549cbc8722504cc2c6c259e 100644 (file)
@@ -8,7 +8,7 @@
 #include "hook.h"
 #include "hook-list.h"
 #include "diagnose.h"
-
+#include "wrapper.h"
 
 static void get_system_info(struct strbuf *sys_info)
 {
index 42e6b8d34814a4cb214d3be5c79fc2564098c60b..1c1e006ff3fe727e51a73677615e131e7a05284f 100644 (file)
@@ -9,6 +9,7 @@
 #include "urlmatch.h"
 #include "quote.h"
 #include "worktree.h"
+#include "wrapper.h"
 
 static const char *const builtin_config_usage[] = {
        N_("git config [<options>]"),
index 25f2f71c2168097261acfd8856e4beebcdb1cc8b..af56a44923d689f4dbd8f182ec6a6911da170b57 100644 (file)
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "wrapper.h"
 
 #ifndef NO_UNIX_SOCKETS
 
index ed06db120851aeef37440b6a8fb36666bd5cd610..59465c39f1d1865c54e74a85652ad038214fe8f1 100644 (file)
@@ -27,6 +27,7 @@
 #include "object-store.h"
 #include "dir.h"
 #include "entry.h"
+#include "wrapper.h"
 
 static int trust_exit_code;
 
index 7307c4657f22591080979bb6e39aa1d09590baca..3300b7f30f052371a16940a9ab6458821c47441b 100644 (file)
@@ -23,6 +23,7 @@
 #include "commit-reach.h"
 #include "khash.h"
 #include "date.h"
+#include "wrapper.h"
 
 #define PACK_ID_BITS 16
 #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
index 0f9855b680eb7bf4e534af40847e32af835cfa13..cc812416420d7c3ac876b95affbb3ebab7caf040 100644 (file)
@@ -3,6 +3,7 @@
 #include "fmt-merge-msg.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "wrapper.h"
 
 static const char * const fmt_merge_msg_usage[] = {
        N_("git fmt-merge-msg [-m <message>] [--log[=<n>] | --no-log] [--file <file>]"),
index ef063fc828c82fe032f27dd241e5e492335d76ab..2107e3d1f2cfb5913c287316c04a24977642279c 100644 (file)
@@ -35,6 +35,7 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "hook.h"
+#include "wrapper.h"
 
 #define FAILED_RUN "failed to run %s"
 
index 491af9202dc937339db83980e2bf96de6ff81646..67457969986fdd0b511c349fa2f87ec170c1baa5 100644 (file)
@@ -6,6 +6,7 @@
 #include "tar.h"
 #include "builtin.h"
 #include "quote.h"
+#include "wrapper.h"
 
 static const char builtin_get_tar_commit_id_usage[] =
 "git get-tar-commit-id";
index bae5b05403913b602bc5a36c3ca6698563c035ef..2393897cb88db529dae3367ff32efbcbb6b068b0 100644 (file)
@@ -19,6 +19,7 @@
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
+#include "wrapper.h"
 
 static const char index_pack_usage[] =
 "git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--[no-]rev-index] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
index 6f724f694f41c4d2109266bc19999e64d234fe3d..a5d4f5c8ece0d8f6bf5ace2ada69319bd367952d 100644 (file)
@@ -12,6 +12,7 @@
 #include "exec-cmd.h"
 #include "parse-options.h"
 #include "worktree.h"
+#include "wrapper.h"
 
 #ifndef DEFAULT_GIT_TEMPLATE_DIR
 #define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
index 38243e55c5fac6d2823f41af323bd357a59ace24..f4f4a220f302f582eaae89e41b48c56e11198b3d 100644 (file)
@@ -49,6 +49,7 @@
 #include "commit-reach.h"
 #include "wt-status.h"
 #include "commit-graph.h"
+#include "wrapper.h"
 
 #define DEFAULT_TWOHEAD (1<<0)
 #define DEFAULT_OCTOPUS (1<<1)
index 1ca800c7c50aab9ee6e7e99311c8341c43861eda..8b55a088a7c82cddefe20323e7daf26630fc2985 100644 (file)
@@ -40,6 +40,7 @@
 #include "shallow.h"
 #include "promisor-remote.h"
 #include "pack-mtimes.h"
+#include "wrapper.h"
 
 /*
  * Objects we are going to pack are collected in the `to_pack` structure.
index a3f8be88882feaddb8e40ff612c5803c1641db4d..d2f8f703d67de8c63a779b1928826d9d72220cc7 100644 (file)
@@ -32,6 +32,7 @@
 #include "rebase-interactive.h"
 #include "reset.h"
 #include "hook.h"
+#include "wrapper.h"
 
 static char const * const builtin_rebase_usage[] = {
        N_("git rebase [-i] [options] [--exec <cmd>] "
index aec5ee930b235c1c22f5ca43ac00b772ea00496c..ae49ea8c2adc947e36e432de3ba7977ba9fd5923 100644 (file)
@@ -33,6 +33,7 @@
 #include "commit-reach.h"
 #include "worktree.h"
 #include "shallow.h"
+#include "wrapper.h"
 
 static const char * const receive_pack_usage[] = {
        N_("git receive-pack <git-dir>"),
index 24c787557233685cd31d3c3f6b754613a10df5f6..d4a03707b1af6bea5689e01eb35200ebfa9f40c7 100644 (file)
@@ -6,6 +6,7 @@
 #include "parse-options.h"
 #include "string-list.h"
 #include "rerere.h"
+#include "wrapper.h"
 #include "xdiff/xdiff.h"
 #include "xdiff-interface.h"
 #include "pathspec.h"
index e9b105a5397a3fe232f8aa0c005f8ce72599b98b..4cbb40392931357b15fd06d14fcda211249a5079 100644 (file)
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "hex.h"
 #include "object-store.h"
+#include "wrapper.h"
 
 static char *create_temp_file(struct object_id *oid)
 {
index ed614ffddcb87ae8fa2b363b70b00f1b83fd7c6d..1533b4ab43c117093cfddfb67001b6cecc12860a 100644 (file)
@@ -16,6 +16,7 @@
 #include "submodule.h"
 #include "utf8.h"
 #include "worktree.h"
+#include "wrapper.h"
 #include "quote.h"
 
 #define BUILTIN_WORKTREE_ADD_USAGE \
diff --git a/cache.h b/cache.h
index 705c41992bc0d312c7e7f6c86f0cfa70e457cdc1..31c722533f9ba0d52dff749f0f28d226ab3a98d4 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1085,10 +1085,6 @@ const char *repo_find_unique_abbrev(struct repository *r, const struct object_id
 int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
 #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
 
-/* set default permissions by passing mode arguments to open(2) */
-int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
-int git_mkstemp_mode(char *pattern, int mode);
-
 /*
  * NOTE NOTE NOTE!!
  *
@@ -1423,31 +1419,6 @@ static inline int batch_fsync_enabled(enum fsync_component component)
        return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH);
 }
 
-ssize_t read_in_full(int fd, void *buf, size_t count);
-ssize_t write_in_full(int fd, const void *buf, size_t count);
-ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset);
-
-static inline ssize_t write_str_in_full(int fd, const char *str)
-{
-       return write_in_full(fd, str, strlen(str));
-}
-
-/**
- * Open (and truncate) the file at path, write the contents of buf to it,
- * and close it. Dies if any errors are encountered.
- */
-void write_file_buf(const char *path, const char *buf, size_t len);
-
-/**
- * Like write_file_buf(), but format the contents into a buffer first.
- * Additionally, write_file() will append a newline if one is not already
- * present, making it convenient to write text files:
- *
- *   write_file(path, "counter: %d", ctr);
- */
-__attribute__((format (printf, 2, 3)))
-void write_file(const char *path, const char *fmt, ...);
-
 /* pager.c */
 void setup_pager(void);
 int pager_in_use(void);
@@ -1571,7 +1542,4 @@ int versioncmp(const char *s1, const char *s2);
  */
 int print_sha1_ellipsis(void);
 
-/* Return 1 if the file is empty or does not exists, 0 otherwise. */
-int is_empty_or_missing_file(const char *filename);
-
 #endif /* CACHE_H */
index 8f21a0a0c203074abef578fa8728a4b3af8ebfbe..5481736c76c399b7f592db4e2af870f0db7acac9 100644 (file)
@@ -22,6 +22,7 @@
 #include "json-writer.h"
 #include "trace2.h"
 #include "chunk-format.h"
+#include "wrapper.h"
 
 void git_test_write_commit_graph_or_die(void)
 {
index cbcd03aea9b1d2260f04bbcf6a3db16cdaec7a3a..d48899bf7b494ec2446a9b019f0ddd81644a1399 100644 (file)
@@ -11,6 +11,7 @@
 #include "../alloc.h"
 #include "win32/lazyload.h"
 #include "../config.h"
+#include "../wrapper.h"
 #include "dir.h"
 #include "gettext.h"
 #define SECURITY_WIN32
index afebe6b2496e00a1a452a838f55ffed67efaeb7f..ed2b30b38f7c18281d153b4732a8365cb5019513 100644 (file)
@@ -6,6 +6,7 @@
 #include "run-command.h"
 #include "string-list.h"
 #include "hashmap.h"
+#include "wrapper.h"
 
 #if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE)
 
index 6815919ec303c060260ffde8ee828b45c6a2667f..5b1a5d52052ca0219a95d25639adbfe327ec66fd 100644 (file)
--- a/config.c
+++ b/config.c
@@ -28,6 +28,7 @@
 #include "replace-object.h"
 #include "refs.h"
 #include "worktree.h"
+#include "wrapper.h"
 
 struct config_source {
        struct config_source *prev;
index 2bd54244b55ec489407b7a4d299da52ad13a9676..da06e2f51cb0ff83b989106c32e94b5921de496c 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -11,6 +11,7 @@
 #include "sub-process.h"
 #include "utf8.h"
 #include "ll-merge.h"
+#include "wrapper.h"
 
 /*
  * convert.c - convert a file when checking it out and checking it in.
diff --git a/copy.c b/copy.c
index 4de6a110f0912d81def3f2dd4ffd6ddc9bc30d2f..c3250f08221b338e3843f5aa72f42f973beb1a38 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "wrapper.h"
 
 int copy_fd(int ifd, int ofd)
 {
index cce13c0f0473183a201a15e86de256cfd7bfc7d9..2d22f80d901e972a5caccd69f5ae68fa51028326 100644 (file)
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "progress.h"
 #include "csum-file.h"
+#include "wrapper.h"
 
 static void verify_buffer_or_die(struct hashfile *f,
                                 const void *buf,
index bb795ca3ca9726c61fb75b7a275bb8c442cfc371..e35604e194cf92868fb5b8bd1b4e09c5d6d96996 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -6,6 +6,7 @@
 #include "run-command.h"
 #include "strbuf.h"
 #include "string-list.h"
+#include "wrapper.h"
 
 #ifdef NO_INITGROUPS
 #define initgroups(x, y) (0) /* nothing */
diff --git a/diff.c b/diff.c
index 1b0be99c065e3f185c141ab63390bd5c8164e736..1b0b24c21c3ab0953a50e59bf7ed5cbb7845587d 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -33,6 +33,7 @@
 #include "promisor-remote.h"
 #include "dir.h"
 #include "strmap.h"
+#include "wrapper.h"
 
 #ifdef NO_FAST_WORKING_DIRECTORY
 #define FAST_WORKING_DIRECTORY 0
diff --git a/dir.c b/dir.c
index c72481c60ee3a552d46644443b3e1c66dc980d09..b57c770e68b025ce64b3e3eff3699188f511b35e 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -21,6 +21,7 @@
 #include "ewah/ewok.h"
 #include "fsmonitor.h"
 #include "submodule-config.h"
+#include "wrapper.h"
 
 /*
  * Tells read_directory_recursive how a file or directory should be treated.
diff --git a/entry.c b/entry.c
index acb76a61acaa6a4c38ecb4230b17b4550d805f97..70212af260b53822ad72b169a6601a8e98a95ad0 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -10,6 +10,7 @@
 #include "fsmonitor.h"
 #include "entry.h"
 #include "parallel-checkout.h"
+#include "wrapper.h"
 
 static void create_directories(const char *path, int path_len,
                               const struct checkout *state)
index c69571f0b292be528313b7d55073ecbb166c2f97..bf02f3cf4876a7c7f94781a897ed80b21f4631d3 100644 (file)
@@ -23,6 +23,7 @@
 #include "tmp-objdir.h"
 #include "chdir-notify.h"
 #include "shallow.h"
+#include "wrapper.h"
 
 int trust_executable_bit = 1;
 int trust_ctime = 1;
index 359dce6afed618d888949e26bf8aac3b611dccef..c1190801405715edcdeeccd46053cda19e208f57 100644 (file)
@@ -30,6 +30,7 @@
 #include "commit-graph.h"
 #include "sigchain.h"
 #include "mergesort.h"
+#include "wrapper.h"
 
 static int transfer_unpack_limit = -1;
 static int fetch_unpack_limit = -1;
index f9c5b6c3f531f4ec181ebc89bc950544edb3b250..6644701fda05ad61327791a328e645c177d16fee 100644 (file)
@@ -10,6 +10,7 @@
 #include "sigchain.h"
 #include "tempfile.h"
 #include "alias.h"
+#include "wrapper.h"
 
 static int git_gpg_config(const char *, const char *, void *);
 
index 7e7c19e66b379a992474e31f14c0bec7b45cbab0..42e6c2596e94497b3a8f30fd1a602f266bebcedc 100644 (file)
@@ -16,6 +16,7 @@
 #include "object-store.h"
 #include "protocol.h"
 #include "date.h"
+#include "wrapper.h"
 
 static const char content_type[] = "Content-Type";
 static const char content_length[] = "Content-Length";
index c65a27219c65689bc9844adbf1555c8667a71a7d..aa5b2f252d24e2e2bb06eb5e599b23c142a215d5 100644 (file)
@@ -28,6 +28,7 @@
 #include "gettext.h"
 #include "run-command.h"
 #include "parse-options.h"
+#include "wrapper.h"
 #if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)
 typedef void *SSL;
 #endif
index 130d26501c69cd47b762f13b46ff4835cfa6261a..8be38d3bd4176410cbb1c7d838f0982baab5d726 100644 (file)
@@ -11,6 +11,7 @@
 #include "run-command.h"
 #include "ll-merge.h"
 #include "quote.h"
+#include "wrapper.h"
 
 struct ll_merge_driver;
 
index 0b0255ebc8048272c1c76b66493a4f83cefc147a..f918cea4c695d1e91b48b50a93a6b2e3dd70da56 100644 (file)
@@ -30,6 +30,7 @@
 #include "tag.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
+#include "wrapper.h"
 #include "xdiff-interface.h"
 
 struct merge_options_internal {
index c8d0020b1a288f0ec5f52d6c24c4250e97940d9d..ba2970f0702a5dddd462bea296aaccf67883544b 100644 (file)
@@ -15,6 +15,7 @@
 #include "strbuf.h"
 #include "notes-utils.h"
 #include "commit-reach.h"
+#include "wrapper.h"
 
 struct notes_merge_pair {
        struct object_id obj, base, local, remote;
index bee41b30474538513140582e6b5874b4a6dbf23c..bdf68763a50bd9725d3582d3ae69188eb593d3e5 100644 (file)
@@ -38,6 +38,7 @@
 #include "promisor-remote.h"
 #include "submodule.h"
 #include "fsck.h"
+#include "wrapper.h"
 
 /* The maximum size for an object header. */
 #define MAX_HEADER_LEN 32
index 3290fde15a1a9ff81060d825585a37e24f8e4572..8c117ccee27c9f8bdfa80c7d15127fac3481ee68 100644 (file)
@@ -20,6 +20,7 @@
 #include "midx.h"
 #include "commit-graph.h"
 #include "promisor-remote.h"
+#include "wrapper.h"
 
 char *odb_pack_name(struct strbuf *buf,
                    const unsigned char *hash,
index 38c4dc665d55854ba394f9ac4d65962617105510..50fd7fe31ef91e21a5204693f1509ae8d5d55589 100644 (file)
@@ -12,6 +12,7 @@
 #include "streaming.h"
 #include "thread-utils.h"
 #include "trace2.h"
+#include "wrapper.h"
 
 struct pc_worker {
        struct child_process cp;
index c8b90b2242e929562fb223a074558b61f8507ceb..30469eb4d8d36866b7ba0ea303332bf61962ba4c 100644 (file)
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "run-command.h"
+#include "wrapper.h"
 
 char packet_buffer[LARGE_PACKET_MAX];
 static const char *packet_trace_prefix = "git";
index 63789ea5e21d9b2fbcd36c4f9839cc1aaece3bd6..9a8d5fe97ed4aa06a0f4fd0579d2376f6a615f46 100644 (file)
@@ -32,6 +32,7 @@
 #include "csum-file.h"
 #include "promisor-remote.h"
 #include "hook.h"
+#include "wrapper.h"
 
 /* Mask for the name length in ce_flags in the on-disk index */
 
index 649c94e69a6eaa027bfd70ee6aa3bc5cb85fca31..7c885c35bfdd1be3afbe5c893c95d9ddc000a97e 100644 (file)
@@ -7,6 +7,7 @@
 #include "commit-slab.h"
 #include "config.h"
 #include "dir.h"
+#include "wrapper.h"
 
 static const char edit_todo_list_advice[] =
 N_("You can fix this with 'git rebase --edit-todo' "
diff --git a/refs.c b/refs.c
index 8684f4610f53727df0698940982b0aec94dc3ce7..385051752f195dd0db071753c96e81bdb955b691 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -24,6 +24,7 @@
 #include "sigchain.h"
 #include "date.h"
 #include "commit.h"
+#include "wrapper.h"
 
 /*
  * List of all available backends
index de3628ff3f14e635c28d9643375e4656e211e87a..eb14d124e3f7ba34d5c16bb9c832e1c9e1c978ec 100644 (file)
@@ -13,7 +13,8 @@
 #include "../object.h"
 #include "../dir.h"
 #include "../chdir-notify.h"
-#include "worktree.h"
+#include "../worktree.h"
+#include "../wrapper.h"
 
 /*
  * This backend uses the following flags in `ref_update::flags` for
index c3258e13902d47a71b5bc94d39e50790a264b6be..b5ccbecdcd2bd6156bc681b4048c7fca9386ade6 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -16,6 +16,7 @@
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "strmap.h"
+#include "wrapper.h"
 
 #define RESOLVED 0
 #define PUNTED 1
index c61c1fc4d875c58786aaa616995d0d9567091231..aa7983f5b45cc6bde99cebdd78d66d4224c6a884 100644 (file)
@@ -41,6 +41,7 @@
 #include "rebase-interactive.h"
 #include "reset.h"
 #include "branch.h"
+#include "wrapper.h"
 
 #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
 
index 78643377057921a97d2178d4fd0b7bcb195fe57d..ae96d784e5329a291bcd9384a10785c7736a93b0 100644 (file)
@@ -10,6 +10,7 @@
 #include "packfile.h"
 #include "object-store.h"
 #include "strbuf.h"
+#include "wrapper.h"
 
 struct update_info_ctx {
        FILE *cur_fp;
index c5433a4fd30ee3e99e74ed5783113037b874a7fa..7fcba5f6d06193bcdd38c8e69bdeda9e63e52c86 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -17,6 +17,7 @@
 #include "list-objects.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "wrapper.h"
 
 void set_alternate_shallow_file(struct repository *r, const char *path, int override)
 {
index 9633e37b62f45fe91eda67820469b0c17168bfa3..70a83e7980e0e575cde2d9b8fed5eec1fa9f48e5 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -8,6 +8,7 @@
 #include "string-list.h"
 #include "utf8.h"
 #include "date.h"
+#include "wrapper.h"
 
 int starts_with(const char *str, const char *prefix)
 {
index 27841dc1d9e535df291a1005a7a005d65323dd1d..6c69f59504569cc50e9a828b5dea5a91f1eef9ae 100644 (file)
@@ -7,6 +7,7 @@
 #include "object-store.h"
 #include "replace-object.h"
 #include "packfile.h"
+#include "wrapper.h"
 
 typedef int (*open_istream_fn)(struct git_istream *,
                               struct repository *,
index b15481ea596dcdd2337a4dd9d99761ecb5514ea4..6609fcbc12e7f507f9a26399d49b76372bd81f2e 100644 (file)
@@ -12,6 +12,7 @@
 #include "git-compat-util.h"
 #include "delta.h"
 #include "cache.h"
+#include "wrapper.h"
 
 static const char usage_str[] =
        "test-tool delta (-d|-p) <from_file> <data_file> <out_file>";
index 54a4856c48c55af0af4e3ffe7cc3a62dce993842..c43fc976b82368b8adb0d8aecfaf4d97b816baf6 100644 (file)
@@ -9,6 +9,7 @@
 #include "fsmonitor-ipc.h"
 #include "thread-utils.h"
 #include "trace2.h"
+#include "wrapper.h"
 
 #ifndef HAVE_FSMONITOR_DAEMON_BACKEND
 int cmd__fsmonitor_client(int argc, const char **argv)
index 23e9e27109faa2acac0bd2804e1143efc7c8971b..84818363d5b24e65a2241830dcf342deb524b0c2 100644 (file)
@@ -2,6 +2,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "config.h"
+#include "wrapper.h"
 
 int cmd__read_cache(int argc, const char **argv)
 {
diff --git a/tag.c b/tag.c
index 18b718cca666e1ecdd8520e6fc3e3e5ff9031df2..3408bb9433f3b83a763a683fe483b9107140c616 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -8,6 +8,7 @@
 #include "gpg-interface.h"
 #include "hex.h"
 #include "packfile.h"
+#include "wrapper.h"
 
 const char *tag_type = "tag";
 
index e27048f970ba3a22823a0a7eab870c424d2e3e1d..cdd2cab3bada725e7276665ace87a2d7cab353db 100644 (file)
@@ -45,6 +45,7 @@
 #include "cache.h"
 #include "tempfile.h"
 #include "sigchain.h"
+#include "wrapper.h"
 
 static VOLATILE_LIST_HEAD(tempfile_list);
 
diff --git a/trace.c b/trace.c
index 2b41c683fc85e76b11f82e9c71ca6cd1ae6b16a0..de004f62988ab6510af8bdcab9667820f01540db 100644 (file)
--- a/trace.c
+++ b/trace.c
@@ -24,6 +24,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "quote.h"
+#include "wrapper.h"
 
 struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
 struct trace_key trace_perf_key = TRACE_KEY_INIT(PERFORMANCE);
index 105bb801c21cda23a02fe8c66f8977b802221382..09048eab484744948fc283ca814add048698a3bb 100644 (file)
@@ -16,6 +16,7 @@
 #include "refspec.h"
 #include "transport-internal.h"
 #include "protocol.h"
+#include "wrapper.h"
 
 static int debug;
 
index 80059124c0a5a2f38bf67fc421d4f933e8110c3f..c6179b801e8b858bc5decb2bcc29ab6ad692ce46 100644 (file)
@@ -26,6 +26,7 @@
 #include "object-store.h"
 #include "color.h"
 #include "bundle-uri.h"
+#include "wrapper.h"
 
 static int transport_use_color = -1;
 static char transport_colors[][COLOR_MAXLEN] = {
diff --git a/usage.c b/usage.c
index 40a1c5a43392040b6578bd2d47291fb022f70f85..b53c99dbe5bdc5803dcfe7cc6fabff88025fbe42 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -5,6 +5,7 @@
  */
 #include "cache.h"
 #include "gettext.h"
+#include "wrapper.h"
 
 static void vreportf(const char *prefix, const char *err, va_list params)
 {
index b7bc4c7bb7a66b6cd4ba8a6b9b7fadb176659e74..fe4345012c475745addfa77667d219d926f205d9 100644 (file)
@@ -9,6 +9,7 @@
 #include "dir.h"
 #include "wt-status.h"
 #include "config.h"
+#include "wrapper.h"
 
 void free_worktrees(struct worktree **worktrees)
 {
index df1fa6286d014469f904ad73de8d40c09f22617d..ee83757590269f063a83c9c89cbd1b64ae22c044 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "wrapper.h"
 
 static intmax_t count_fsync_writeout_only;
 static intmax_t count_fsync_hardware_flush;
diff --git a/wrapper.h b/wrapper.h
new file mode 100644 (file)
index 0000000..f0c7d06
--- /dev/null
+++ b/wrapper.h
@@ -0,0 +1,36 @@
+#ifndef WRAPPER_H
+#define WRAPPER_H
+
+/* set default permissions by passing mode arguments to open(2) */
+int git_mkstemps_mode(char *pattern, int suffix_len, int mode);
+int git_mkstemp_mode(char *pattern, int mode);
+
+ssize_t read_in_full(int fd, void *buf, size_t count);
+ssize_t write_in_full(int fd, const void *buf, size_t count);
+ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset);
+
+static inline ssize_t write_str_in_full(int fd, const char *str)
+{
+       return write_in_full(fd, str, strlen(str));
+}
+
+/**
+ * Open (and truncate) the file at path, write the contents of buf to it,
+ * and close it. Dies if any errors are encountered.
+ */
+void write_file_buf(const char *path, const char *buf, size_t len);
+
+/**
+ * Like write_file_buf(), but format the contents into a buffer first.
+ * Additionally, write_file() will append a newline if one is not already
+ * present, making it convenient to write text files:
+ *
+ *   write_file(path, "counter: %d", ctr);
+ */
+__attribute__((format (printf, 2, 3)))
+void write_file(const char *path, const char *fmt, ...);
+
+/* Return 1 if the file is empty or does not exists, 0 otherwise. */
+int is_empty_or_missing_file(const char *filename);
+
+#endif /* WRAPPER_H */
index aaa0318e8248116af4d14143eace6c34e59d730b..a7afc303db2dc02108cbafc091fe82cbc0739500 100644 (file)
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "config.h"
 #include "run-command.h"
+#include "wrapper.h"
 
 /*
  * Some cases use stdio, but want to flush after the write