Browse Source

write-or-die.h: move declarations for write-or-die.c functions from cache.h

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
main
Elijah Newren 2 years ago committed by Junio C Hamano
parent
commit
d48be35ca6
  1. 1
      archive-tar.c
  2. 1
      archive-zip.c
  3. 1
      builtin/blame.c
  4. 1
      builtin/cat-file.c
  5. 1
      builtin/check-attr.c
  6. 1
      builtin/check-ignore.c
  7. 1
      builtin/check-mailmap.c
  8. 1
      builtin/credential-cache.c
  9. 1
      builtin/credential-store.c
  10. 1
      builtin/grep.c
  11. 1
      builtin/hash-object.c
  12. 1
      builtin/log.c
  13. 1
      builtin/notes.c
  14. 1
      builtin/send-pack.c
  15. 1
      builtin/stripspace.c
  16. 1
      builtin/tag.c
  17. 1
      builtin/update-index.c
  18. 1
      bundle.c
  19. 74
      cache.h
  20. 1
      config.c
  21. 1
      csum-file.h
  22. 1
      diagnose.c
  23. 1
      environment.c
  24. 1
      http-backend.c
  25. 1
      log-tree.c
  26. 1
      pkt-line.c
  27. 1
      refs/files-backend.c
  28. 1
      refs/packed-backend.c
  29. 1
      remote-curl.c
  30. 3
      send-pack.c
  31. 1
      sideband.c
  32. 3
      t/helper/test-pkt-line.c
  33. 1
      upload-pack.c
  34. 3
      write-or-die.c
  35. 78
      write-or-die.h

1
archive-tar.c

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include "object-store.h"
#include "streaming.h"
#include "run-command.h"
#include "write-or-die.h"

#define RECORDSIZE (512)
#define BLOCKSIZE (RECORDSIZE * 20)

1
archive-zip.c

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
#include "utf8.h"
#include "object-store.h"
#include "userdiff.h"
#include "write-or-die.h"
#include "xdiff-interface.h"
#include "date.h"


1
builtin/blame.c

@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
#include "refs.h"
#include "setup.h"
#include "tag.h"
#include "write-or-die.h"

static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>");
static char annotate_usage[] = N_("git annotate [<options>] [<rev-opts>] [<rev>] [--] <file>");

1
builtin/cat-file.c

@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
#include "replace-object.h"
#include "promisor-remote.h"
#include "mailmap.h"
#include "write-or-die.h"

enum batch_mode {
BATCH_MODE_CONTENTS,

1
builtin/check-attr.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
#include "quote.h"
#include "setup.h"
#include "parse-options.h"
#include "write-or-die.h"

static int all_attrs;
static int cached_attrs;

1
builtin/check-ignore.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
#include "pathspec.h"
#include "parse-options.h"
#include "submodule.h"
#include "write-or-die.h"

static int quiet, verbose, stdin_paths, show_non_matching, no_index;
static const char * const check_ignore_usage[] = {

1
builtin/check-mailmap.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
#include "mailmap.h"
#include "parse-options.h"
#include "string-list.h"
#include "write-or-die.h"

static int use_stdin;
static const char * const check_mailmap_usage[] = {

1
builtin/credential-cache.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "gettext.h"
#include "parse-options.h"
#include "wrapper.h"
#include "write-or-die.h"

#ifndef NO_UNIX_SOCKETS


1
builtin/credential-store.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
#include "credential.h"
#include "string-list.h"
#include "parse-options.h"
#include "write-or-die.h"

static struct lock_file credential_lock;


1
builtin/grep.c

@ -28,6 +28,7 @@ @@ -28,6 +28,7 @@
#include "submodule-config.h"
#include "object-store.h"
#include "packfile.h"
#include "write-or-die.h"

static const char *grep_prefix;


1
builtin/hash-object.c

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
#include "parse-options.h"
#include "exec-cmd.h"
#include "setup.h"
#include "write-or-die.h"

/*
* This is to create corrupt objects for debugging and as such it

1
builtin/log.c

@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
#include "commit-reach.h"
#include "range-diff.h"
#include "tmp-objdir.h"
#include "write-or-die.h"

#define MAIL_DEFAULT_WRAP 72
#define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100

1
builtin/notes.c

@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
#include "notes-merge.h"
#include "notes-utils.h"
#include "worktree.h"
#include "write-or-die.h"

static const char * const git_notes_usage[] = {
N_("git notes [--ref <notes-ref>] [list [<object>]]"),

1
builtin/send-pack.c

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
#include "gpg-interface.h"
#include "gettext.h"
#include "protocol.h"
#include "write-or-die.h"

static const char * const send_pack_usage[] = {
N_("git send-pack [--mirror] [--dry-run] [--force]\n"

1
builtin/stripspace.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
#include "parse-options.h"
#include "setup.h"
#include "strbuf.h"
#include "write-or-die.h"

static void comment_lines(struct strbuf *buf)
{

1
builtin/tag.c

@ -24,6 +24,7 @@ @@ -24,6 +24,7 @@
#include "column.h"
#include "ref-filter.h"
#include "date.h"
#include "write-or-die.h"

static const char * const git_tag_usage[] = {
N_("git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] [-e]\n"

1
builtin/update-index.c

@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
#include "setup.h"
#include "split-index.h"
#include "fsmonitor.h"
#include "write-or-die.h"

/*
* Default to not allowing changes to the list of files. The

1
bundle.c

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
#include "strvec.h"
#include "list-objects-filter-options.h"
#include "connected.h"
#include "write-or-die.h"

static const char v2_bundle_signature[] = "# v2 git bundle\n";
static const char v3_bundle_signature[] = "# v3 git bundle\n";

74
cache.h

@ -686,63 +686,6 @@ extern int verify_ce_order; @@ -686,63 +686,6 @@ extern int verify_ce_order;

extern int quote_path_fully;

/*
* These values are used to help identify parts of a repository to fsync.
* FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the
* repository and so shouldn't be fsynced.
*/
enum fsync_component {
FSYNC_COMPONENT_NONE,
FSYNC_COMPONENT_LOOSE_OBJECT = 1 << 0,
FSYNC_COMPONENT_PACK = 1 << 1,
FSYNC_COMPONENT_PACK_METADATA = 1 << 2,
FSYNC_COMPONENT_COMMIT_GRAPH = 1 << 3,
FSYNC_COMPONENT_INDEX = 1 << 4,
FSYNC_COMPONENT_REFERENCE = 1 << 5,
};

#define FSYNC_COMPONENTS_OBJECTS (FSYNC_COMPONENT_LOOSE_OBJECT | \
FSYNC_COMPONENT_PACK)

#define FSYNC_COMPONENTS_DERIVED_METADATA (FSYNC_COMPONENT_PACK_METADATA | \
FSYNC_COMPONENT_COMMIT_GRAPH)

#define FSYNC_COMPONENTS_DEFAULT ((FSYNC_COMPONENTS_OBJECTS | \
FSYNC_COMPONENTS_DERIVED_METADATA) & \
~FSYNC_COMPONENT_LOOSE_OBJECT)

#define FSYNC_COMPONENTS_COMMITTED (FSYNC_COMPONENTS_OBJECTS | \
FSYNC_COMPONENT_REFERENCE)

#define FSYNC_COMPONENTS_ADDED (FSYNC_COMPONENTS_COMMITTED | \
FSYNC_COMPONENT_INDEX)

#define FSYNC_COMPONENTS_ALL (FSYNC_COMPONENT_LOOSE_OBJECT | \
FSYNC_COMPONENT_PACK | \
FSYNC_COMPONENT_PACK_METADATA | \
FSYNC_COMPONENT_COMMIT_GRAPH | \
FSYNC_COMPONENT_INDEX | \
FSYNC_COMPONENT_REFERENCE)

#ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT
#define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT
#endif

/*
* A bitmask indicating which components of the repo should be fsynced.
*/
extern enum fsync_component fsync_components;
extern int fsync_object_files;
extern int use_fsync;

enum fsync_method {
FSYNC_METHOD_FSYNC,
FSYNC_METHOD_WRITEOUT_ONLY,
FSYNC_METHOD_BATCH,
};

extern enum fsync_method fsync_method;

#define MTIME_CHANGED 0x0001
#define CTIME_CHANGED 0x0002
#define OWNER_CHANGED 0x0004
@ -1045,29 +988,12 @@ int update_server_info(int); @@ -1045,29 +988,12 @@ int update_server_info(int);
extern const char *git_mailmap_file;
extern const char *git_mailmap_blob;

/* IO helper functions */
void maybe_flush_or_die(FILE *, const char *);
__attribute__((format (printf, 2, 3)))
void fprintf_or_die(FILE *, const char *fmt, ...);
void fwrite_or_die(FILE *f, const void *buf, size_t count);
void fflush_or_die(FILE *f);

#define COPY_READ_ERROR (-2)
#define COPY_WRITE_ERROR (-3)
int copy_fd(int ifd, int ofd);
int copy_file(const char *dst, const char *src, int mode);
int copy_file_with_time(const char *dst, const char *src, int mode);

void write_or_die(int fd, const void *buf, size_t count);
void fsync_or_die(int fd, const char *);
int fsync_component(enum fsync_component component, int fd);
void fsync_component_or_die(enum fsync_component component, int fd, const char *msg);

static inline int batch_fsync_enabled(enum fsync_component component)
{
return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH);
}

/* pager.c */
void setup_pager(void);
int pager_in_use(void);

1
config.c

@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
#include "setup.h"
#include "worktree.h"
#include "wrapper.h"
#include "write-or-die.h"

struct config_source {
struct config_source *prev;

1
csum-file.h

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@

#include "cache.h"
#include "hash.h"
#include "write-or-die.h"

struct progress;


1
diagnose.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "strvec.h"
#include "object-store.h"
#include "packfile.h"
#include "write-or-die.h"

struct archive_dir {
const char *path;

1
environment.c

@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
#include "setup.h"
#include "shallow.h"
#include "wrapper.h"
#include "write-or-die.h"

int trust_executable_bit = 1;
int trust_ctime = 1;

1
http-backend.c

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
#include "protocol.h"
#include "date.h"
#include "wrapper.h"
#include "write-or-die.h"

static const char content_type[] = "Content-Type";
static const char content_length[] = "Content-Length";

1
log-tree.c

@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
#include "help.h"
#include "range-diff.h"
#include "strmap.h"
#include "write-or-die.h"

static struct decoration name_decoration = { "object names" };
static int decoration_loaded;

1
pkt-line.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "hex.h"
#include "run-command.h"
#include "wrapper.h"
#include "write-or-die.h"

char packet_buffer[LARGE_PACKET_MAX];
static const char *packet_trace_prefix = "git";

1
refs/files-backend.c

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
#include "../setup.h"
#include "../worktree.h"
#include "../wrapper.h"
#include "../write-or-die.h"

/*
* This backend uses the following flags in `ref_update::flags` for

1
refs/packed-backend.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "../iterator.h"
#include "../lockfile.h"
#include "../chdir-notify.h"
#include "../write-or-die.h"

enum mmap_strategy {
/*

1
remote-curl.c

@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
#include "protocol.h"
#include "quote.h"
#include "transport.h"
#include "write-or-die.h"

static struct remote *remote;
/* always ends with a trailing slash */

3
send-pack.c

@ -16,8 +16,9 @@ @@ -16,8 +16,9 @@
#include "version.h"
#include "oid-array.h"
#include "gpg-interface.h"
#include "cache.h"
#include "shallow.h"
#include "trace2.h"
#include "write-or-die.h"

int option_parse_push_signed(const struct option *opt,
const char *arg, int unset)

1
sideband.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
#include "sideband.h"
#include "help.h"
#include "pkt-line.h"
#include "write-or-die.h"

struct keyword_entry {
/*

3
t/helper/test-pkt-line.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "git-compat-util.h"
#include "test-tool.h"
#include "pkt-line.h"
#include "write-or-die.h"

static void pack_line(const char *line)
{

1
upload-pack.c

@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
#include "commit-graph.h"
#include "commit-reach.h"
#include "shallow.h"
#include "write-or-die.h"

/* Remember to update object flag allocation in object.h */
#define THEY_HAVE (1u << 11)

3
write-or-die.c

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
#include "cache.h"
#include "git-compat-util.h"
#include "config.h"
#include "run-command.h"
#include "wrapper.h"
#include "write-or-die.h"

/*
* Some cases use stdio, but want to flush after the write

78
write-or-die.h

@ -0,0 +1,78 @@ @@ -0,0 +1,78 @@
#ifndef WRITE_OR_DIE_H
#define WRITE_OR_DIE_H

void maybe_flush_or_die(FILE *, const char *);
__attribute__((format (printf, 2, 3)))
void fprintf_or_die(FILE *, const char *fmt, ...);
void fwrite_or_die(FILE *f, const void *buf, size_t count);
void fflush_or_die(FILE *f);
void write_or_die(int fd, const void *buf, size_t count);

/*
* These values are used to help identify parts of a repository to fsync.
* FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the
* repository and so shouldn't be fsynced.
*/
enum fsync_component {
FSYNC_COMPONENT_NONE,
FSYNC_COMPONENT_LOOSE_OBJECT = 1 << 0,
FSYNC_COMPONENT_PACK = 1 << 1,
FSYNC_COMPONENT_PACK_METADATA = 1 << 2,
FSYNC_COMPONENT_COMMIT_GRAPH = 1 << 3,
FSYNC_COMPONENT_INDEX = 1 << 4,
FSYNC_COMPONENT_REFERENCE = 1 << 5,
};

#define FSYNC_COMPONENTS_OBJECTS (FSYNC_COMPONENT_LOOSE_OBJECT | \
FSYNC_COMPONENT_PACK)

#define FSYNC_COMPONENTS_DERIVED_METADATA (FSYNC_COMPONENT_PACK_METADATA | \
FSYNC_COMPONENT_COMMIT_GRAPH)

#define FSYNC_COMPONENTS_DEFAULT ((FSYNC_COMPONENTS_OBJECTS | \
FSYNC_COMPONENTS_DERIVED_METADATA) & \
~FSYNC_COMPONENT_LOOSE_OBJECT)

#define FSYNC_COMPONENTS_COMMITTED (FSYNC_COMPONENTS_OBJECTS | \
FSYNC_COMPONENT_REFERENCE)

#define FSYNC_COMPONENTS_ADDED (FSYNC_COMPONENTS_COMMITTED | \
FSYNC_COMPONENT_INDEX)

#define FSYNC_COMPONENTS_ALL (FSYNC_COMPONENT_LOOSE_OBJECT | \
FSYNC_COMPONENT_PACK | \
FSYNC_COMPONENT_PACK_METADATA | \
FSYNC_COMPONENT_COMMIT_GRAPH | \
FSYNC_COMPONENT_INDEX | \
FSYNC_COMPONENT_REFERENCE)

#ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT
#define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT
#endif

/* IO helper functions */
void fsync_or_die(int fd, const char *);
int fsync_component(enum fsync_component component, int fd);
void fsync_component_or_die(enum fsync_component component, int fd, const char *msg);

/*
* A bitmask indicating which components of the repo should be fsynced.
*/
extern enum fsync_component fsync_components;
extern int fsync_object_files;
extern int use_fsync;

enum fsync_method {
FSYNC_METHOD_FSYNC,
FSYNC_METHOD_WRITEOUT_ONLY,
FSYNC_METHOD_BATCH,
};

extern enum fsync_method fsync_method;

static inline int batch_fsync_enabled(enum fsync_component component)
{
return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH);
}

#endif /* WRITE_OR_DIE_H */
Loading…
Cancel
Save