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>
This commit is contained in:
Elijah Newren 2023-03-21 06:26:01 +00:00 committed by Junio C Hamano
parent 905f96939b
commit d5ebb50dcb
68 changed files with 103 additions and 34 deletions

View File

@ -26,6 +26,7 @@
#include "rerere.h"
#include "apply.h"
#include "entry.h"
#include "wrapper.h"
struct gitdiff_data {
struct strbuf *root;

View 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.

View 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")

View 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]"),

View 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)
{

View 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>]"),

View File

@ -1,6 +1,7 @@
#include "builtin.h"
#include "gettext.h"
#include "parse-options.h"
#include "wrapper.h"
#ifndef NO_UNIX_SOCKETS

View File

@ -27,6 +27,7 @@
#include "object-store.h"
#include "dir.h"
#include "entry.h"
#include "wrapper.h"
static int trust_exit_code;

View 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)

View 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>]"),

View 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"

View 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";

View 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>])";

View 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"

View 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)

View 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.

View 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>] "

View 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>"),

View 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"

View 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)
{

View 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 \

32
cache.h
View File

@ -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 */

View 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)
{

View 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

View 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)

View File

@ -28,6 +28,7 @@
#include "replace-object.h"
#include "refs.h"
#include "worktree.h"
#include "wrapper.h"
struct config_source {
struct config_source *prev;

View File

@ -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.

1
copy.c
View File

@ -1,4 +1,5 @@
#include "cache.h"
#include "wrapper.h"
int copy_fd(int ifd, int ofd)
{

View 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,

View File

@ -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 */

1
diff.c
View File

@ -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

1
dir.c
View File

@ -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.

View File

@ -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)

View 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;

View 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;

View 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 *);

View 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";

View 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

View File

@ -11,6 +11,7 @@
#include "run-command.h"
#include "ll-merge.h"
#include "quote.h"
#include "wrapper.h"
struct ll_merge_driver;

View 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 {

View 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;

View 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

View 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,

View 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;

View 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";

View 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 */

View 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' "

1
refs.c
View File

@ -24,6 +24,7 @@
#include "sigchain.h"
#include "date.h"
#include "commit.h"
#include "wrapper.h"
/*
* List of all available backends

View 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

View File

@ -16,6 +16,7 @@
#include "object-store.h"
#include "hash-lookup.h"
#include "strmap.h"
#include "wrapper.h"
#define RESOLVED 0
#define PUNTED 1

View 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"

View 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;

View File

@ -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)
{

View File

@ -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)
{

View 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 *,

View 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>";

View 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)

View 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)
{

1
tag.c
View File

@ -8,6 +8,7 @@
#include "gpg-interface.h"
#include "hex.h"
#include "packfile.h"
#include "wrapper.h"
const char *tag_type = "tag";

View File

@ -45,6 +45,7 @@
#include "cache.h"
#include "tempfile.h"
#include "sigchain.h"
#include "wrapper.h"
static VOLATILE_LIST_HEAD(tempfile_list);

View File

@ -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);

View File

@ -16,6 +16,7 @@
#include "refspec.h"
#include "transport-internal.h"
#include "protocol.h"
#include "wrapper.h"
static int debug;

View 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] = {

View File

@ -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)
{

View File

@ -9,6 +9,7 @@
#include "dir.h"
#include "wt-status.h"
#include "config.h"
#include "wrapper.h"
void free_worktrees(struct worktree **worktrees)
{

View File

@ -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;

36
wrapper.h Normal file
View File

@ -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 */

View 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