Coverage Report

Created: 2026-03-31 06:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/git/write-or-die.h
Line
Count
Source
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
void writev_or_die(int fd, struct iovec *iov, int iovlen);
11
12
/*
13
 * These values are used to help identify parts of a repository to fsync.
14
 * FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the
15
 * repository and so shouldn't be fsynced.
16
 */
17
enum fsync_component {
18
  FSYNC_COMPONENT_NONE,
19
  FSYNC_COMPONENT_LOOSE_OBJECT    = 1 << 0,
20
  FSYNC_COMPONENT_PACK      = 1 << 1,
21
  FSYNC_COMPONENT_PACK_METADATA   = 1 << 2,
22
  FSYNC_COMPONENT_COMMIT_GRAPH    = 1 << 3,
23
  FSYNC_COMPONENT_INDEX     = 1 << 4,
24
  FSYNC_COMPONENT_REFERENCE   = 1 << 5,
25
  FSYNC_COMPONENT_OBJECT_MAP    = 1 << 6,
26
};
27
28
0
#define FSYNC_COMPONENTS_OBJECTS (FSYNC_COMPONENT_LOOSE_OBJECT | \
29
0
          FSYNC_COMPONENT_PACK)
30
31
0
#define FSYNC_COMPONENTS_DERIVED_METADATA (FSYNC_COMPONENT_PACK_METADATA | \
32
0
             FSYNC_COMPONENT_COMMIT_GRAPH)
33
34
0
#define FSYNC_COMPONENTS_DEFAULT ((FSYNC_COMPONENTS_OBJECTS | \
35
0
           FSYNC_COMPONENTS_DERIVED_METADATA) & \
36
0
          ~FSYNC_COMPONENT_LOOSE_OBJECT)
37
38
#define FSYNC_COMPONENTS_COMMITTED (FSYNC_COMPONENTS_OBJECTS | \
39
            FSYNC_COMPONENT_REFERENCE)
40
41
#define FSYNC_COMPONENTS_ADDED (FSYNC_COMPONENTS_COMMITTED | \
42
        FSYNC_COMPONENT_INDEX)
43
44
#define FSYNC_COMPONENTS_ALL (FSYNC_COMPONENT_LOOSE_OBJECT | \
45
            FSYNC_COMPONENT_PACK | \
46
            FSYNC_COMPONENT_PACK_METADATA | \
47
            FSYNC_COMPONENT_COMMIT_GRAPH | \
48
            FSYNC_COMPONENT_INDEX | \
49
            FSYNC_COMPONENT_REFERENCE | \
50
            FSYNC_COMPONENT_OBJECT_MAP)
51
52
#ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT
53
0
#define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT
54
#endif
55
56
/* IO helper functions */
57
void fsync_or_die(int fd, const char *);
58
int fsync_component(enum fsync_component component, int fd);
59
void fsync_component_or_die(enum fsync_component component, int fd, const char *msg);
60
61
/*
62
 * A bitmask indicating which components of the repo should be fsynced.
63
 */
64
extern enum fsync_component fsync_components;
65
extern int fsync_object_files;
66
extern int use_fsync;
67
68
enum fsync_method {
69
  FSYNC_METHOD_FSYNC,
70
  FSYNC_METHOD_WRITEOUT_ONLY,
71
  FSYNC_METHOD_BATCH,
72
};
73
74
extern enum fsync_method fsync_method;
75
76
static inline int batch_fsync_enabled(enum fsync_component component)
77
0
{
78
0
  return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH);
79
0
}
Unexecuted instantiation: config.c:batch_fsync_enabled
Unexecuted instantiation: environment.c:batch_fsync_enabled
Unexecuted instantiation: object-file.c:batch_fsync_enabled
Unexecuted instantiation: odb.c:batch_fsync_enabled
Unexecuted instantiation: source-files.c:batch_fsync_enabled
Unexecuted instantiation: pack-write.c:batch_fsync_enabled
Unexecuted instantiation: packfile.c:batch_fsync_enabled
Unexecuted instantiation: read-cache.c:batch_fsync_enabled
Unexecuted instantiation: files-backend.c:batch_fsync_enabled
Unexecuted instantiation: reftable-backend.c:batch_fsync_enabled
Unexecuted instantiation: packed-backend.c:batch_fsync_enabled
Unexecuted instantiation: repo-settings.c:batch_fsync_enabled
Unexecuted instantiation: write-or-die.c:batch_fsync_enabled
Unexecuted instantiation: bundle.c:batch_fsync_enabled
Unexecuted instantiation: chunk-format.c:batch_fsync_enabled
Unexecuted instantiation: commit-graph.c:batch_fsync_enabled
Unexecuted instantiation: csum-file.c:batch_fsync_enabled
Unexecuted instantiation: fetch-pack.c:batch_fsync_enabled
Unexecuted instantiation: log-tree.c:batch_fsync_enabled
Unexecuted instantiation: midx.c:batch_fsync_enabled
Unexecuted instantiation: pack-check.c:batch_fsync_enabled
Unexecuted instantiation: pack-revindex.c:batch_fsync_enabled
Unexecuted instantiation: pkt-line.c:batch_fsync_enabled
Unexecuted instantiation: send-pack.c:batch_fsync_enabled
Unexecuted instantiation: sideband.c:batch_fsync_enabled
80
81
#endif /* WRITE_OR_DIE_H */