Git fork

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>

authored by

Elijah Newren and committed by
Junio C Hamano
d48be35c 61a7b982

+114 -77
+1
archive-tar.c
··· 11 #include "object-store.h" 12 #include "streaming.h" 13 #include "run-command.h" 14 15 #define RECORDSIZE (512) 16 #define BLOCKSIZE (RECORDSIZE * 20)
··· 11 #include "object-store.h" 12 #include "streaming.h" 13 #include "run-command.h" 14 + #include "write-or-die.h" 15 16 #define RECORDSIZE (512) 17 #define BLOCKSIZE (RECORDSIZE * 20)
+1
archive-zip.c
··· 10 #include "utf8.h" 11 #include "object-store.h" 12 #include "userdiff.h" 13 #include "xdiff-interface.h" 14 #include "date.h" 15
··· 10 #include "utf8.h" 11 #include "object-store.h" 12 #include "userdiff.h" 13 + #include "write-or-die.h" 14 #include "xdiff-interface.h" 15 #include "date.h" 16
+1
builtin/blame.c
··· 33 #include "refs.h" 34 #include "setup.h" 35 #include "tag.h" 36 37 static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>"); 38 static char annotate_usage[] = N_("git annotate [<options>] [<rev-opts>] [<rev>] [--] <file>");
··· 33 #include "refs.h" 34 #include "setup.h" 35 #include "tag.h" 36 + #include "write-or-die.h" 37 38 static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>"); 39 static char annotate_usage[] = N_("git annotate [<options>] [<rev-opts>] [<rev>] [--] <file>");
+1
builtin/cat-file.c
··· 23 #include "replace-object.h" 24 #include "promisor-remote.h" 25 #include "mailmap.h" 26 27 enum batch_mode { 28 BATCH_MODE_CONTENTS,
··· 23 #include "replace-object.h" 24 #include "promisor-remote.h" 25 #include "mailmap.h" 26 + #include "write-or-die.h" 27 28 enum batch_mode { 29 BATCH_MODE_CONTENTS,
+1
builtin/check-attr.c
··· 8 #include "quote.h" 9 #include "setup.h" 10 #include "parse-options.h" 11 12 static int all_attrs; 13 static int cached_attrs;
··· 8 #include "quote.h" 9 #include "setup.h" 10 #include "parse-options.h" 11 + #include "write-or-die.h" 12 13 static int all_attrs; 14 static int cached_attrs;
+1
builtin/check-ignore.c
··· 8 #include "pathspec.h" 9 #include "parse-options.h" 10 #include "submodule.h" 11 12 static int quiet, verbose, stdin_paths, show_non_matching, no_index; 13 static const char * const check_ignore_usage[] = {
··· 8 #include "pathspec.h" 9 #include "parse-options.h" 10 #include "submodule.h" 11 + #include "write-or-die.h" 12 13 static int quiet, verbose, stdin_paths, show_non_matching, no_index; 14 static const char * const check_ignore_usage[] = {
+1
builtin/check-mailmap.c
··· 5 #include "mailmap.h" 6 #include "parse-options.h" 7 #include "string-list.h" 8 9 static int use_stdin; 10 static const char * const check_mailmap_usage[] = {
··· 5 #include "mailmap.h" 6 #include "parse-options.h" 7 #include "string-list.h" 8 + #include "write-or-die.h" 9 10 static int use_stdin; 11 static const char * const check_mailmap_usage[] = {
+1
builtin/credential-cache.c
··· 2 #include "gettext.h" 3 #include "parse-options.h" 4 #include "wrapper.h" 5 6 #ifndef NO_UNIX_SOCKETS 7
··· 2 #include "gettext.h" 3 #include "parse-options.h" 4 #include "wrapper.h" 5 + #include "write-or-die.h" 6 7 #ifndef NO_UNIX_SOCKETS 8
+1
builtin/credential-store.c
··· 5 #include "credential.h" 6 #include "string-list.h" 7 #include "parse-options.h" 8 9 static struct lock_file credential_lock; 10
··· 5 #include "credential.h" 6 #include "string-list.h" 7 #include "parse-options.h" 8 + #include "write-or-die.h" 9 10 static struct lock_file credential_lock; 11
+1
builtin/grep.c
··· 28 #include "submodule-config.h" 29 #include "object-store.h" 30 #include "packfile.h" 31 32 static const char *grep_prefix; 33
··· 28 #include "submodule-config.h" 29 #include "object-store.h" 30 #include "packfile.h" 31 + #include "write-or-die.h" 32 33 static const char *grep_prefix; 34
+1
builtin/hash-object.c
··· 15 #include "parse-options.h" 16 #include "exec-cmd.h" 17 #include "setup.h" 18 19 /* 20 * This is to create corrupt objects for debugging and as such it
··· 15 #include "parse-options.h" 16 #include "exec-cmd.h" 17 #include "setup.h" 18 + #include "write-or-die.h" 19 20 /* 21 * This is to create corrupt objects for debugging and as such it
+1
builtin/log.c
··· 40 #include "commit-reach.h" 41 #include "range-diff.h" 42 #include "tmp-objdir.h" 43 44 #define MAIL_DEFAULT_WRAP 72 45 #define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100
··· 40 #include "commit-reach.h" 41 #include "range-diff.h" 42 #include "tmp-objdir.h" 43 + #include "write-or-die.h" 44 45 #define MAIL_DEFAULT_WRAP 72 46 #define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100
+1
builtin/notes.c
··· 25 #include "notes-merge.h" 26 #include "notes-utils.h" 27 #include "worktree.h" 28 29 static const char * const git_notes_usage[] = { 30 N_("git notes [--ref <notes-ref>] [list [<object>]]"),
··· 25 #include "notes-merge.h" 26 #include "notes-utils.h" 27 #include "worktree.h" 28 + #include "write-or-die.h" 29 30 static const char * const git_notes_usage[] = { 31 N_("git notes [--ref <notes-ref>] [list [<object>]]"),
+1
builtin/send-pack.c
··· 16 #include "gpg-interface.h" 17 #include "gettext.h" 18 #include "protocol.h" 19 20 static const char * const send_pack_usage[] = { 21 N_("git send-pack [--mirror] [--dry-run] [--force]\n"
··· 16 #include "gpg-interface.h" 17 #include "gettext.h" 18 #include "protocol.h" 19 + #include "write-or-die.h" 20 21 static const char * const send_pack_usage[] = { 22 N_("git send-pack [--mirror] [--dry-run] [--force]\n"
+1
builtin/stripspace.c
··· 5 #include "parse-options.h" 6 #include "setup.h" 7 #include "strbuf.h" 8 9 static void comment_lines(struct strbuf *buf) 10 {
··· 5 #include "parse-options.h" 6 #include "setup.h" 7 #include "strbuf.h" 8 + #include "write-or-die.h" 9 10 static void comment_lines(struct strbuf *buf) 11 {
+1
builtin/tag.c
··· 24 #include "column.h" 25 #include "ref-filter.h" 26 #include "date.h" 27 28 static const char * const git_tag_usage[] = { 29 N_("git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] [-e]\n"
··· 24 #include "column.h" 25 #include "ref-filter.h" 26 #include "date.h" 27 + #include "write-or-die.h" 28 29 static const char * const git_tag_usage[] = { 30 N_("git tag [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] [-e]\n"
+1
builtin/update-index.c
··· 23 #include "setup.h" 24 #include "split-index.h" 25 #include "fsmonitor.h" 26 27 /* 28 * Default to not allowing changes to the list of files. The
··· 23 #include "setup.h" 24 #include "split-index.h" 25 #include "fsmonitor.h" 26 + #include "write-or-die.h" 27 28 /* 29 * Default to not allowing changes to the list of files. The
+1
bundle.c
··· 16 #include "strvec.h" 17 #include "list-objects-filter-options.h" 18 #include "connected.h" 19 20 static const char v2_bundle_signature[] = "# v2 git bundle\n"; 21 static const char v3_bundle_signature[] = "# v3 git bundle\n";
··· 16 #include "strvec.h" 17 #include "list-objects-filter-options.h" 18 #include "connected.h" 19 + #include "write-or-die.h" 20 21 static const char v2_bundle_signature[] = "# v2 git bundle\n"; 22 static const char v3_bundle_signature[] = "# v3 git bundle\n";
-74
cache.h
··· 686 687 extern int quote_path_fully; 688 689 - /* 690 - * These values are used to help identify parts of a repository to fsync. 691 - * FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the 692 - * repository and so shouldn't be fsynced. 693 - */ 694 - enum fsync_component { 695 - FSYNC_COMPONENT_NONE, 696 - FSYNC_COMPONENT_LOOSE_OBJECT = 1 << 0, 697 - FSYNC_COMPONENT_PACK = 1 << 1, 698 - FSYNC_COMPONENT_PACK_METADATA = 1 << 2, 699 - FSYNC_COMPONENT_COMMIT_GRAPH = 1 << 3, 700 - FSYNC_COMPONENT_INDEX = 1 << 4, 701 - FSYNC_COMPONENT_REFERENCE = 1 << 5, 702 - }; 703 - 704 - #define FSYNC_COMPONENTS_OBJECTS (FSYNC_COMPONENT_LOOSE_OBJECT | \ 705 - FSYNC_COMPONENT_PACK) 706 - 707 - #define FSYNC_COMPONENTS_DERIVED_METADATA (FSYNC_COMPONENT_PACK_METADATA | \ 708 - FSYNC_COMPONENT_COMMIT_GRAPH) 709 - 710 - #define FSYNC_COMPONENTS_DEFAULT ((FSYNC_COMPONENTS_OBJECTS | \ 711 - FSYNC_COMPONENTS_DERIVED_METADATA) & \ 712 - ~FSYNC_COMPONENT_LOOSE_OBJECT) 713 - 714 - #define FSYNC_COMPONENTS_COMMITTED (FSYNC_COMPONENTS_OBJECTS | \ 715 - FSYNC_COMPONENT_REFERENCE) 716 - 717 - #define FSYNC_COMPONENTS_ADDED (FSYNC_COMPONENTS_COMMITTED | \ 718 - FSYNC_COMPONENT_INDEX) 719 - 720 - #define FSYNC_COMPONENTS_ALL (FSYNC_COMPONENT_LOOSE_OBJECT | \ 721 - FSYNC_COMPONENT_PACK | \ 722 - FSYNC_COMPONENT_PACK_METADATA | \ 723 - FSYNC_COMPONENT_COMMIT_GRAPH | \ 724 - FSYNC_COMPONENT_INDEX | \ 725 - FSYNC_COMPONENT_REFERENCE) 726 - 727 - #ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT 728 - #define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT 729 - #endif 730 - 731 - /* 732 - * A bitmask indicating which components of the repo should be fsynced. 733 - */ 734 - extern enum fsync_component fsync_components; 735 - extern int fsync_object_files; 736 - extern int use_fsync; 737 - 738 - enum fsync_method { 739 - FSYNC_METHOD_FSYNC, 740 - FSYNC_METHOD_WRITEOUT_ONLY, 741 - FSYNC_METHOD_BATCH, 742 - }; 743 - 744 - extern enum fsync_method fsync_method; 745 - 746 #define MTIME_CHANGED 0x0001 747 #define CTIME_CHANGED 0x0002 748 #define OWNER_CHANGED 0x0004 ··· 1045 extern const char *git_mailmap_file; 1046 extern const char *git_mailmap_blob; 1047 1048 - /* IO helper functions */ 1049 - void maybe_flush_or_die(FILE *, const char *); 1050 - __attribute__((format (printf, 2, 3))) 1051 - void fprintf_or_die(FILE *, const char *fmt, ...); 1052 - void fwrite_or_die(FILE *f, const void *buf, size_t count); 1053 - void fflush_or_die(FILE *f); 1054 - 1055 #define COPY_READ_ERROR (-2) 1056 #define COPY_WRITE_ERROR (-3) 1057 int copy_fd(int ifd, int ofd); 1058 int copy_file(const char *dst, const char *src, int mode); 1059 int copy_file_with_time(const char *dst, const char *src, int mode); 1060 - 1061 - void write_or_die(int fd, const void *buf, size_t count); 1062 - void fsync_or_die(int fd, const char *); 1063 - int fsync_component(enum fsync_component component, int fd); 1064 - void fsync_component_or_die(enum fsync_component component, int fd, const char *msg); 1065 - 1066 - static inline int batch_fsync_enabled(enum fsync_component component) 1067 - { 1068 - return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH); 1069 - } 1070 1071 /* pager.c */ 1072 void setup_pager(void);
··· 686 687 extern int quote_path_fully; 688 689 #define MTIME_CHANGED 0x0001 690 #define CTIME_CHANGED 0x0002 691 #define OWNER_CHANGED 0x0004 ··· 988 extern const char *git_mailmap_file; 989 extern const char *git_mailmap_blob; 990 991 #define COPY_READ_ERROR (-2) 992 #define COPY_WRITE_ERROR (-3) 993 int copy_fd(int ifd, int ofd); 994 int copy_file(const char *dst, const char *src, int mode); 995 int copy_file_with_time(const char *dst, const char *src, int mode); 996 997 /* pager.c */ 998 void setup_pager(void);
+1
config.c
··· 30 #include "setup.h" 31 #include "worktree.h" 32 #include "wrapper.h" 33 34 struct config_source { 35 struct config_source *prev;
··· 30 #include "setup.h" 31 #include "worktree.h" 32 #include "wrapper.h" 33 + #include "write-or-die.h" 34 35 struct config_source { 36 struct config_source *prev;
+1
csum-file.h
··· 3 4 #include "cache.h" 5 #include "hash.h" 6 7 struct progress; 8
··· 3 4 #include "cache.h" 5 #include "hash.h" 6 + #include "write-or-die.h" 7 8 struct progress; 9
+1
diagnose.c
··· 9 #include "strvec.h" 10 #include "object-store.h" 11 #include "packfile.h" 12 13 struct archive_dir { 14 const char *path;
··· 9 #include "strvec.h" 10 #include "object-store.h" 11 #include "packfile.h" 12 + #include "write-or-die.h" 13 14 struct archive_dir { 15 const char *path;
+1
environment.c
··· 25 #include "setup.h" 26 #include "shallow.h" 27 #include "wrapper.h" 28 29 int trust_executable_bit = 1; 30 int trust_ctime = 1;
··· 25 #include "setup.h" 26 #include "shallow.h" 27 #include "wrapper.h" 28 + #include "write-or-die.h" 29 30 int trust_executable_bit = 1; 31 int trust_ctime = 1;
+1
http-backend.c
··· 18 #include "protocol.h" 19 #include "date.h" 20 #include "wrapper.h" 21 22 static const char content_type[] = "Content-Type"; 23 static const char content_length[] = "Content-Length";
··· 18 #include "protocol.h" 19 #include "date.h" 20 #include "wrapper.h" 21 + #include "write-or-die.h" 22 23 static const char content_type[] = "Content-Type"; 24 static const char content_length[] = "Content-Length";
+1
log-tree.c
··· 23 #include "help.h" 24 #include "range-diff.h" 25 #include "strmap.h" 26 27 static struct decoration name_decoration = { "object names" }; 28 static int decoration_loaded;
··· 23 #include "help.h" 24 #include "range-diff.h" 25 #include "strmap.h" 26 + #include "write-or-die.h" 27 28 static struct decoration name_decoration = { "object names" }; 29 static int decoration_loaded;
+1
pkt-line.c
··· 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";
··· 4 #include "hex.h" 5 #include "run-command.h" 6 #include "wrapper.h" 7 + #include "write-or-die.h" 8 9 char packet_buffer[LARGE_PACKET_MAX]; 10 static const char *packet_trace_prefix = "git";
+1
refs/files-backend.c
··· 17 #include "../setup.h" 18 #include "../worktree.h" 19 #include "../wrapper.h" 20 21 /* 22 * This backend uses the following flags in `ref_update::flags` for
··· 17 #include "../setup.h" 18 #include "../worktree.h" 19 #include "../wrapper.h" 20 + #include "../write-or-die.h" 21 22 /* 23 * This backend uses the following flags in `ref_update::flags` for
+1
refs/packed-backend.c
··· 9 #include "../iterator.h" 10 #include "../lockfile.h" 11 #include "../chdir-notify.h" 12 13 enum mmap_strategy { 14 /*
··· 9 #include "../iterator.h" 10 #include "../lockfile.h" 11 #include "../chdir-notify.h" 12 + #include "../write-or-die.h" 13 14 enum mmap_strategy { 15 /*
+1
remote-curl.c
··· 22 #include "protocol.h" 23 #include "quote.h" 24 #include "transport.h" 25 26 static struct remote *remote; 27 /* always ends with a trailing slash */
··· 22 #include "protocol.h" 23 #include "quote.h" 24 #include "transport.h" 25 + #include "write-or-die.h" 26 27 static struct remote *remote; 28 /* always ends with a trailing slash */
+2 -1
send-pack.c
··· 16 #include "version.h" 17 #include "oid-array.h" 18 #include "gpg-interface.h" 19 - #include "cache.h" 20 #include "shallow.h" 21 22 int option_parse_push_signed(const struct option *opt, 23 const char *arg, int unset)
··· 16 #include "version.h" 17 #include "oid-array.h" 18 #include "gpg-interface.h" 19 #include "shallow.h" 20 + #include "trace2.h" 21 + #include "write-or-die.h" 22 23 int option_parse_push_signed(const struct option *opt, 24 const char *arg, int unset)
+1
sideband.c
··· 5 #include "sideband.h" 6 #include "help.h" 7 #include "pkt-line.h" 8 9 struct keyword_entry { 10 /*
··· 5 #include "sideband.h" 6 #include "help.h" 7 #include "pkt-line.h" 8 + #include "write-or-die.h" 9 10 struct keyword_entry { 11 /*
+2 -1
t/helper/test-pkt-line.c
··· 1 - #include "cache.h" 2 #include "test-tool.h" 3 #include "pkt-line.h" 4 5 static void pack_line(const char *line) 6 {
··· 1 + #include "git-compat-util.h" 2 #include "test-tool.h" 3 #include "pkt-line.h" 4 + #include "write-or-die.h" 5 6 static void pack_line(const char *line) 7 {
+1
upload-pack.c
··· 30 #include "commit-graph.h" 31 #include "commit-reach.h" 32 #include "shallow.h" 33 34 /* Remember to update object flag allocation in object.h */ 35 #define THEY_HAVE (1u << 11)
··· 30 #include "commit-graph.h" 31 #include "commit-reach.h" 32 #include "shallow.h" 33 + #include "write-or-die.h" 34 35 /* Remember to update object flag allocation in object.h */ 36 #define THEY_HAVE (1u << 11)
+2 -1
write-or-die.c
··· 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
··· 1 + #include "git-compat-util.h" 2 #include "config.h" 3 #include "run-command.h" 4 #include "wrapper.h" 5 + #include "write-or-die.h" 6 7 /* 8 * Some cases use stdio, but want to flush after the write
+78
write-or-die.h
···
··· 1 + #ifndef WRITE_OR_DIE_H 2 + #define WRITE_OR_DIE_H 3 + 4 + void maybe_flush_or_die(FILE *, const char *); 5 + __attribute__((format (printf, 2, 3))) 6 + void fprintf_or_die(FILE *, const char *fmt, ...); 7 + void fwrite_or_die(FILE *f, const void *buf, size_t count); 8 + void fflush_or_die(FILE *f); 9 + void write_or_die(int fd, const void *buf, size_t count); 10 + 11 + /* 12 + * These values are used to help identify parts of a repository to fsync. 13 + * FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the 14 + * repository and so shouldn't be fsynced. 15 + */ 16 + enum fsync_component { 17 + FSYNC_COMPONENT_NONE, 18 + FSYNC_COMPONENT_LOOSE_OBJECT = 1 << 0, 19 + FSYNC_COMPONENT_PACK = 1 << 1, 20 + FSYNC_COMPONENT_PACK_METADATA = 1 << 2, 21 + FSYNC_COMPONENT_COMMIT_GRAPH = 1 << 3, 22 + FSYNC_COMPONENT_INDEX = 1 << 4, 23 + FSYNC_COMPONENT_REFERENCE = 1 << 5, 24 + }; 25 + 26 + #define FSYNC_COMPONENTS_OBJECTS (FSYNC_COMPONENT_LOOSE_OBJECT | \ 27 + FSYNC_COMPONENT_PACK) 28 + 29 + #define FSYNC_COMPONENTS_DERIVED_METADATA (FSYNC_COMPONENT_PACK_METADATA | \ 30 + FSYNC_COMPONENT_COMMIT_GRAPH) 31 + 32 + #define FSYNC_COMPONENTS_DEFAULT ((FSYNC_COMPONENTS_OBJECTS | \ 33 + FSYNC_COMPONENTS_DERIVED_METADATA) & \ 34 + ~FSYNC_COMPONENT_LOOSE_OBJECT) 35 + 36 + #define FSYNC_COMPONENTS_COMMITTED (FSYNC_COMPONENTS_OBJECTS | \ 37 + FSYNC_COMPONENT_REFERENCE) 38 + 39 + #define FSYNC_COMPONENTS_ADDED (FSYNC_COMPONENTS_COMMITTED | \ 40 + FSYNC_COMPONENT_INDEX) 41 + 42 + #define FSYNC_COMPONENTS_ALL (FSYNC_COMPONENT_LOOSE_OBJECT | \ 43 + FSYNC_COMPONENT_PACK | \ 44 + FSYNC_COMPONENT_PACK_METADATA | \ 45 + FSYNC_COMPONENT_COMMIT_GRAPH | \ 46 + FSYNC_COMPONENT_INDEX | \ 47 + FSYNC_COMPONENT_REFERENCE) 48 + 49 + #ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT 50 + #define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT 51 + #endif 52 + 53 + /* IO helper functions */ 54 + void fsync_or_die(int fd, const char *); 55 + int fsync_component(enum fsync_component component, int fd); 56 + void fsync_component_or_die(enum fsync_component component, int fd, const char *msg); 57 + 58 + /* 59 + * A bitmask indicating which components of the repo should be fsynced. 60 + */ 61 + extern enum fsync_component fsync_components; 62 + extern int fsync_object_files; 63 + extern int use_fsync; 64 + 65 + enum fsync_method { 66 + FSYNC_METHOD_FSYNC, 67 + FSYNC_METHOD_WRITEOUT_ONLY, 68 + FSYNC_METHOD_BATCH, 69 + }; 70 + 71 + extern enum fsync_method fsync_method; 72 + 73 + static inline int batch_fsync_enabled(enum fsync_component component) 74 + { 75 + return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH); 76 + } 77 + 78 + #endif /* WRITE_OR_DIE_H */