Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef LOCKFILE_H |
2 | | #define LOCKFILE_H |
3 | | |
4 | | /* |
5 | | * File write-locks as used by Git. |
6 | | * |
7 | | * The lockfile API serves two purposes: |
8 | | * |
9 | | * * Mutual exclusion and atomic file updates. When we want to change |
10 | | * a file, we create a lockfile `<filename>.lock`, write the new |
11 | | * file contents into it, and then rename the lockfile to its final |
12 | | * destination `<filename>`. We create the `<filename>.lock` file |
13 | | * with `O_CREAT|O_EXCL` so that we can notice and fail if somebody |
14 | | * else has already locked the file, then atomically rename the |
15 | | * lockfile to its final destination to commit the changes and |
16 | | * unlock the file. |
17 | | * |
18 | | * * Automatic cruft removal. If the program exits after we lock a |
19 | | * file but before the changes have been committed, we want to make |
20 | | * sure that we remove the lockfile. This is done by remembering the |
21 | | * lockfiles we have created in a linked list and setting up an |
22 | | * `atexit(3)` handler and a signal handler that clean up the |
23 | | * lockfiles. This mechanism ensures that outstanding lockfiles are |
24 | | * cleaned up if the program exits (including when `die()` is |
25 | | * called) or if the program is terminated by a signal. |
26 | | * |
27 | | * Please note that lockfiles only block other writers. Readers do not |
28 | | * block, but they are guaranteed to see either the old contents of |
29 | | * the file or the new contents of the file (assuming that the |
30 | | * filesystem implements `rename(2)` atomically). |
31 | | * |
32 | | * Most of the heavy lifting is done by the tempfile module (see |
33 | | * "tempfile.h"). |
34 | | * |
35 | | * Calling sequence |
36 | | * ---------------- |
37 | | * |
38 | | * The caller: |
39 | | * |
40 | | * * Allocates a `struct lock_file` with whatever storage duration you |
41 | | * desire. The struct does not have to be initialized before being |
42 | | * used, but it is good practice to do so using by setting it to |
43 | | * all-zeros (or using the LOCK_INIT macro). This puts the object in a |
44 | | * consistent state that allows you to call rollback_lock_file() even |
45 | | * if the lock was never taken (in which case it is a noop). |
46 | | * |
47 | | * * Attempts to create a lockfile by calling `hold_lock_file_for_update()`. |
48 | | * |
49 | | * * Writes new content for the destination file by either: |
50 | | * |
51 | | * * writing to the file descriptor returned by the |
52 | | * `hold_lock_file_for_*()` functions (also available via |
53 | | * `lock->fd`). |
54 | | * |
55 | | * * calling `fdopen_lock_file()` to get a `FILE` pointer for the |
56 | | * open file and writing to the file using stdio. |
57 | | * |
58 | | * Note that the file descriptor returned by hold_lock_file_for_update() |
59 | | * is marked O_CLOEXEC, so the new contents must be written by the |
60 | | * current process, not a spawned one. |
61 | | * |
62 | | * When finished writing, the caller can: |
63 | | * |
64 | | * * Close the file descriptor and rename the lockfile to its final |
65 | | * destination by calling `commit_lock_file()` or |
66 | | * `commit_lock_file_to()`. |
67 | | * |
68 | | * * Close the file descriptor and remove the lockfile by calling |
69 | | * `rollback_lock_file()`. |
70 | | * |
71 | | * * Close the file descriptor without removing or renaming the |
72 | | * lockfile by calling `close_lock_file_gently()`, and later call |
73 | | * `commit_lock_file()`, `commit_lock_file_to()`, |
74 | | * `rollback_lock_file()`, or `reopen_lock_file()`. |
75 | | * |
76 | | * After the lockfile is committed or rolled back, the `lock_file` |
77 | | * object can be discarded or reused. |
78 | | * |
79 | | * If the program exits before `commit_lock_file()`, |
80 | | * `commit_lock_file_to()`, or `rollback_lock_file()` is called, the |
81 | | * tempfile module will close and remove the lockfile, thereby rolling |
82 | | * back any uncommitted changes. |
83 | | * |
84 | | * If you need to close the file descriptor you obtained from a |
85 | | * `hold_lock_file_for_*()` function yourself, do so by calling |
86 | | * `close_lock_file_gently()`. See "tempfile.h" for more information. |
87 | | * |
88 | | * |
89 | | * Under the covers, a lockfile is just a tempfile with a few helper |
90 | | * functions. In particular, the state diagram and the cleanup |
91 | | * machinery are all implemented in the tempfile module. |
92 | | * |
93 | | * Permission bits |
94 | | * --------------- |
95 | | * |
96 | | * If you call either `hold_lock_file_for_update_mode` or |
97 | | * `hold_lock_file_for_update_timeout_mode`, you can specify a suggested |
98 | | * mode for the underlying temporary file. Note that the file isn't |
99 | | * guaranteed to have this exact mode, since it may be limited by either |
100 | | * the umask, 'core.sharedRepository', or both. See `adjust_shared_perm` |
101 | | * for more. |
102 | | * |
103 | | * Error handling |
104 | | * -------------- |
105 | | * |
106 | | * The `hold_lock_file_for_*()` functions return a file descriptor on |
107 | | * success or -1 on failure (unless `LOCK_DIE_ON_ERROR` is used; see |
108 | | * "flags" below). On errors, `errno` describes the reason for |
109 | | * failure. Errors can be reported by passing `errno` to |
110 | | * `unable_to_lock_message()` or `unable_to_lock_die()`. |
111 | | * |
112 | | * Similarly, `commit_lock_file`, `commit_lock_file_to`, and |
113 | | * `close_lock_file` return 0 on success. On failure they set `errno` |
114 | | * appropriately and return -1. The `commit` variants (but not `close`) |
115 | | * do their best to delete the temporary file before returning. |
116 | | */ |
117 | | |
118 | | #include "tempfile.h" |
119 | | |
120 | | struct lock_file { |
121 | | struct tempfile *tempfile; |
122 | | }; |
123 | | |
124 | 13.5k | #define LOCK_INIT { 0 } |
125 | | |
126 | | /* String appended to a filename to derive the lockfile name: */ |
127 | 543k | #define LOCK_SUFFIX ".lock" |
128 | 3.28M | #define LOCK_SUFFIX_LEN 5 |
129 | | |
130 | | |
131 | | /* |
132 | | * Flags |
133 | | * ----- |
134 | | * |
135 | | * The following flags can be passed to `hold_lock_file_for_update()`. |
136 | | */ |
137 | | |
138 | | /* |
139 | | * If a lock is already taken for the file, `die()` with an error |
140 | | * message. If this flag is not specified, trying to lock a file that |
141 | | * is already locked silently returns -1 to the caller, or ... |
142 | | */ |
143 | 18.3k | #define LOCK_DIE_ON_ERROR 1 |
144 | | |
145 | | /* |
146 | | * ... this flag can be passed instead to return -1 and give the usual |
147 | | * error message upon an error. |
148 | | */ |
149 | 0 | #define LOCK_REPORT_ON_ERROR 4 |
150 | | |
151 | | /* |
152 | | * Usually symbolic links in the destination path are resolved. This |
153 | | * means that (1) the lockfile is created by adding ".lock" to the |
154 | | * resolved path, and (2) upon commit, the resolved path is |
155 | | * overwritten. However, if `LOCK_NO_DEREF` is set, then the lockfile |
156 | | * is created by adding ".lock" to the path argument itself. This |
157 | | * option is used, for example, when detaching a symbolic reference, |
158 | | * which for backwards-compatibility reasons, can be a symbolic link |
159 | | * containing the name of the referred-to-reference. |
160 | | */ |
161 | 91.8k | #define LOCK_NO_DEREF 2 |
162 | | |
163 | | /* |
164 | | * Attempt to create a lockfile for the file at `path` and return a |
165 | | * file descriptor for writing to it, or -1 on error. If the file is |
166 | | * currently locked, retry with quadratic backoff for at least |
167 | | * timeout_ms milliseconds. If timeout_ms is 0, try exactly once; if |
168 | | * timeout_ms is -1, retry indefinitely. The flags argument, error |
169 | | * handling, and mode are described above. |
170 | | */ |
171 | | int hold_lock_file_for_update_timeout_mode( |
172 | | struct lock_file *lk, const char *path, |
173 | | int flags, long timeout_ms, int mode); |
174 | | |
175 | | static inline int hold_lock_file_for_update_timeout( |
176 | | struct lock_file *lk, const char *path, |
177 | | int flags, long timeout_ms) |
178 | 61.8k | { |
179 | 61.8k | return hold_lock_file_for_update_timeout_mode(lk, path, flags, |
180 | 61.8k | timeout_ms, 0666); |
181 | 61.8k | } Unexecuted instantiation: add.c:hold_lock_file_for_update_timeout Unexecuted instantiation: am.c:hold_lock_file_for_update_timeout Unexecuted instantiation: apply.c:hold_lock_file_for_update_timeout Unexecuted instantiation: checkout-index.c:hold_lock_file_for_update_timeout Unexecuted instantiation: checkout.c:hold_lock_file_for_update_timeout Unexecuted instantiation: clone.c:hold_lock_file_for_update_timeout Unexecuted instantiation: commit.c:hold_lock_file_for_update_timeout Unexecuted instantiation: credential-store.c:hold_lock_file_for_update_timeout Unexecuted instantiation: describe.c:hold_lock_file_for_update_timeout Unexecuted instantiation: diff.c:hold_lock_file_for_update_timeout Unexecuted instantiation: difftool.c:hold_lock_file_for_update_timeout Unexecuted instantiation: fast-import.c:hold_lock_file_for_update_timeout Unexecuted instantiation: fetch.c:hold_lock_file_for_update_timeout Unexecuted instantiation: gc.c:hold_lock_file_for_update_timeout Unexecuted instantiation: merge.c:hold_lock_file_for_update_timeout Unexecuted instantiation: mv.c:hold_lock_file_for_update_timeout Unexecuted instantiation: pack-objects.c:hold_lock_file_for_update_timeout Unexecuted instantiation: prune.c:hold_lock_file_for_update_timeout Unexecuted instantiation: read-tree.c:hold_lock_file_for_update_timeout Unexecuted instantiation: rebase.c:hold_lock_file_for_update_timeout Unexecuted instantiation: receive-pack.c:hold_lock_file_for_update_timeout Unexecuted instantiation: repack.c:hold_lock_file_for_update_timeout Unexecuted instantiation: replay.c:hold_lock_file_for_update_timeout Unexecuted instantiation: reset.c:hold_lock_file_for_update_timeout Unexecuted instantiation: rev-parse.c:hold_lock_file_for_update_timeout Unexecuted instantiation: rm.c:hold_lock_file_for_update_timeout Unexecuted instantiation: sparse-checkout.c:hold_lock_file_for_update_timeout Unexecuted instantiation: stash.c:hold_lock_file_for_update_timeout Unexecuted instantiation: update-index.c:hold_lock_file_for_update_timeout Unexecuted instantiation: git.c:hold_lock_file_for_update_timeout Unexecuted instantiation: add-interactive.c:hold_lock_file_for_update_timeout Unexecuted instantiation: bulk-checkin.c:hold_lock_file_for_update_timeout Unexecuted instantiation: bundle.c:hold_lock_file_for_update_timeout Unexecuted instantiation: cache-tree.c:hold_lock_file_for_update_timeout Unexecuted instantiation: commit-graph.c:hold_lock_file_for_update_timeout config.c:hold_lock_file_for_update_timeout Line | Count | Source | 178 | 4.39k | { | 179 | 4.39k | return hold_lock_file_for_update_timeout_mode(lk, path, flags, | 180 | 4.39k | timeout_ms, 0666); | 181 | 4.39k | } |
Unexecuted instantiation: environment.c:hold_lock_file_for_update_timeout Unexecuted instantiation: fetch-pack.c:hold_lock_file_for_update_timeout Unexecuted instantiation: lockfile.c:hold_lock_file_for_update_timeout Unexecuted instantiation: merge-recursive.c:hold_lock_file_for_update_timeout Unexecuted instantiation: midx-write.c:hold_lock_file_for_update_timeout Unexecuted instantiation: object-file.c:hold_lock_file_for_update_timeout Unexecuted instantiation: path.c:hold_lock_file_for_update_timeout Unexecuted instantiation: range-diff.c:hold_lock_file_for_update_timeout Unexecuted instantiation: read-cache.c:hold_lock_file_for_update_timeout Unexecuted instantiation: refs.c:hold_lock_file_for_update_timeout files-backend.c:hold_lock_file_for_update_timeout Line | Count | Source | 178 | 30.0k | { | 179 | 30.0k | return hold_lock_file_for_update_timeout_mode(lk, path, flags, | 180 | 30.0k | timeout_ms, 0666); | 181 | 30.0k | } |
Unexecuted instantiation: reftable-backend.c:hold_lock_file_for_update_timeout packed-backend.c:hold_lock_file_for_update_timeout Line | Count | Source | 178 | 9.08k | { | 179 | 9.08k | return hold_lock_file_for_update_timeout_mode(lk, path, flags, | 180 | 9.08k | timeout_ms, 0666); | 181 | 9.08k | } |
repository.c:hold_lock_file_for_update_timeout Line | Count | Source | 178 | 18.3k | { | 179 | 18.3k | return hold_lock_file_for_update_timeout_mode(lk, path, flags, | 180 | 18.3k | timeout_ms, 0666); | 181 | 18.3k | } |
Unexecuted instantiation: rerere.c:hold_lock_file_for_update_timeout Unexecuted instantiation: send-pack.c:hold_lock_file_for_update_timeout Unexecuted instantiation: sequencer.c:hold_lock_file_for_update_timeout Unexecuted instantiation: shallow.c:hold_lock_file_for_update_timeout Unexecuted instantiation: upload-pack.c:hold_lock_file_for_update_timeout Unexecuted instantiation: wt-status.c:hold_lock_file_for_update_timeout Unexecuted instantiation: loose.c:hold_lock_file_for_update_timeout Unexecuted instantiation: error.c:hold_lock_file_for_update_timeout Unexecuted instantiation: iter.c:hold_lock_file_for_update_timeout Unexecuted instantiation: publicbasics.c:hold_lock_file_for_update_timeout Unexecuted instantiation: reader.c:hold_lock_file_for_update_timeout Unexecuted instantiation: record.c:hold_lock_file_for_update_timeout Unexecuted instantiation: stack.c:hold_lock_file_for_update_timeout Unexecuted instantiation: writer.c:hold_lock_file_for_update_timeout Unexecuted instantiation: basics.c:hold_lock_file_for_update_timeout Unexecuted instantiation: block.c:hold_lock_file_for_update_timeout Unexecuted instantiation: blocksource.c:hold_lock_file_for_update_timeout Unexecuted instantiation: merged.c:hold_lock_file_for_update_timeout Unexecuted instantiation: pq.c:hold_lock_file_for_update_timeout Unexecuted instantiation: tree.c:hold_lock_file_for_update_timeout |
182 | | |
183 | | /* |
184 | | * Attempt to create a lockfile for the file at `path` and return a |
185 | | * file descriptor for writing to it, or -1 on error. The flags |
186 | | * argument and error handling are described above. |
187 | | */ |
188 | | static inline int hold_lock_file_for_update( |
189 | | struct lock_file *lk, const char *path, |
190 | | int flags) |
191 | 22.7k | { |
192 | 22.7k | return hold_lock_file_for_update_timeout(lk, path, flags, 5000); |
193 | 22.7k | } Unexecuted instantiation: add.c:hold_lock_file_for_update Unexecuted instantiation: am.c:hold_lock_file_for_update Unexecuted instantiation: apply.c:hold_lock_file_for_update Unexecuted instantiation: checkout-index.c:hold_lock_file_for_update Unexecuted instantiation: checkout.c:hold_lock_file_for_update Unexecuted instantiation: clone.c:hold_lock_file_for_update Unexecuted instantiation: commit.c:hold_lock_file_for_update Unexecuted instantiation: credential-store.c:hold_lock_file_for_update Unexecuted instantiation: describe.c:hold_lock_file_for_update Unexecuted instantiation: diff.c:hold_lock_file_for_update Unexecuted instantiation: difftool.c:hold_lock_file_for_update Unexecuted instantiation: fast-import.c:hold_lock_file_for_update Unexecuted instantiation: fetch.c:hold_lock_file_for_update Unexecuted instantiation: gc.c:hold_lock_file_for_update Unexecuted instantiation: merge.c:hold_lock_file_for_update Unexecuted instantiation: mv.c:hold_lock_file_for_update Unexecuted instantiation: pack-objects.c:hold_lock_file_for_update Unexecuted instantiation: prune.c:hold_lock_file_for_update Unexecuted instantiation: read-tree.c:hold_lock_file_for_update Unexecuted instantiation: rebase.c:hold_lock_file_for_update Unexecuted instantiation: receive-pack.c:hold_lock_file_for_update Unexecuted instantiation: repack.c:hold_lock_file_for_update Unexecuted instantiation: replay.c:hold_lock_file_for_update Unexecuted instantiation: reset.c:hold_lock_file_for_update Unexecuted instantiation: rev-parse.c:hold_lock_file_for_update Unexecuted instantiation: rm.c:hold_lock_file_for_update Unexecuted instantiation: sparse-checkout.c:hold_lock_file_for_update Unexecuted instantiation: stash.c:hold_lock_file_for_update Unexecuted instantiation: update-index.c:hold_lock_file_for_update Unexecuted instantiation: git.c:hold_lock_file_for_update Unexecuted instantiation: add-interactive.c:hold_lock_file_for_update Unexecuted instantiation: bulk-checkin.c:hold_lock_file_for_update Unexecuted instantiation: bundle.c:hold_lock_file_for_update Unexecuted instantiation: cache-tree.c:hold_lock_file_for_update Unexecuted instantiation: commit-graph.c:hold_lock_file_for_update config.c:hold_lock_file_for_update Line | Count | Source | 191 | 4.39k | { | 192 | 4.39k | return hold_lock_file_for_update_timeout(lk, path, flags, 5000); | 193 | 4.39k | } |
Unexecuted instantiation: environment.c:hold_lock_file_for_update Unexecuted instantiation: fetch-pack.c:hold_lock_file_for_update Unexecuted instantiation: lockfile.c:hold_lock_file_for_update Unexecuted instantiation: merge-recursive.c:hold_lock_file_for_update Unexecuted instantiation: midx-write.c:hold_lock_file_for_update Unexecuted instantiation: object-file.c:hold_lock_file_for_update Unexecuted instantiation: path.c:hold_lock_file_for_update Unexecuted instantiation: range-diff.c:hold_lock_file_for_update Unexecuted instantiation: read-cache.c:hold_lock_file_for_update Unexecuted instantiation: refs.c:hold_lock_file_for_update Unexecuted instantiation: files-backend.c:hold_lock_file_for_update Unexecuted instantiation: reftable-backend.c:hold_lock_file_for_update Unexecuted instantiation: packed-backend.c:hold_lock_file_for_update repository.c:hold_lock_file_for_update Line | Count | Source | 191 | 18.3k | { | 192 | 18.3k | return hold_lock_file_for_update_timeout(lk, path, flags, 5000); | 193 | 18.3k | } |
Unexecuted instantiation: rerere.c:hold_lock_file_for_update Unexecuted instantiation: send-pack.c:hold_lock_file_for_update Unexecuted instantiation: sequencer.c:hold_lock_file_for_update Unexecuted instantiation: shallow.c:hold_lock_file_for_update Unexecuted instantiation: upload-pack.c:hold_lock_file_for_update Unexecuted instantiation: wt-status.c:hold_lock_file_for_update Unexecuted instantiation: loose.c:hold_lock_file_for_update Unexecuted instantiation: error.c:hold_lock_file_for_update Unexecuted instantiation: iter.c:hold_lock_file_for_update Unexecuted instantiation: publicbasics.c:hold_lock_file_for_update Unexecuted instantiation: reader.c:hold_lock_file_for_update Unexecuted instantiation: record.c:hold_lock_file_for_update Unexecuted instantiation: stack.c:hold_lock_file_for_update Unexecuted instantiation: writer.c:hold_lock_file_for_update Unexecuted instantiation: basics.c:hold_lock_file_for_update Unexecuted instantiation: block.c:hold_lock_file_for_update Unexecuted instantiation: blocksource.c:hold_lock_file_for_update Unexecuted instantiation: merged.c:hold_lock_file_for_update Unexecuted instantiation: pq.c:hold_lock_file_for_update Unexecuted instantiation: tree.c:hold_lock_file_for_update |
194 | | |
195 | | static inline int hold_lock_file_for_update_mode( |
196 | | struct lock_file *lk, const char *path, |
197 | | int flags, int mode) |
198 | 0 | { |
199 | 0 | return hold_lock_file_for_update_timeout_mode(lk, path, flags, 0, mode); |
200 | 0 | } Unexecuted instantiation: add.c:hold_lock_file_for_update_mode Unexecuted instantiation: am.c:hold_lock_file_for_update_mode Unexecuted instantiation: apply.c:hold_lock_file_for_update_mode Unexecuted instantiation: checkout-index.c:hold_lock_file_for_update_mode Unexecuted instantiation: checkout.c:hold_lock_file_for_update_mode Unexecuted instantiation: clone.c:hold_lock_file_for_update_mode Unexecuted instantiation: commit.c:hold_lock_file_for_update_mode Unexecuted instantiation: credential-store.c:hold_lock_file_for_update_mode Unexecuted instantiation: describe.c:hold_lock_file_for_update_mode Unexecuted instantiation: diff.c:hold_lock_file_for_update_mode Unexecuted instantiation: difftool.c:hold_lock_file_for_update_mode Unexecuted instantiation: fast-import.c:hold_lock_file_for_update_mode Unexecuted instantiation: fetch.c:hold_lock_file_for_update_mode Unexecuted instantiation: gc.c:hold_lock_file_for_update_mode Unexecuted instantiation: merge.c:hold_lock_file_for_update_mode Unexecuted instantiation: mv.c:hold_lock_file_for_update_mode Unexecuted instantiation: pack-objects.c:hold_lock_file_for_update_mode Unexecuted instantiation: prune.c:hold_lock_file_for_update_mode Unexecuted instantiation: read-tree.c:hold_lock_file_for_update_mode Unexecuted instantiation: rebase.c:hold_lock_file_for_update_mode Unexecuted instantiation: receive-pack.c:hold_lock_file_for_update_mode Unexecuted instantiation: repack.c:hold_lock_file_for_update_mode Unexecuted instantiation: replay.c:hold_lock_file_for_update_mode Unexecuted instantiation: reset.c:hold_lock_file_for_update_mode Unexecuted instantiation: rev-parse.c:hold_lock_file_for_update_mode Unexecuted instantiation: rm.c:hold_lock_file_for_update_mode Unexecuted instantiation: sparse-checkout.c:hold_lock_file_for_update_mode Unexecuted instantiation: stash.c:hold_lock_file_for_update_mode Unexecuted instantiation: update-index.c:hold_lock_file_for_update_mode Unexecuted instantiation: git.c:hold_lock_file_for_update_mode Unexecuted instantiation: add-interactive.c:hold_lock_file_for_update_mode Unexecuted instantiation: bulk-checkin.c:hold_lock_file_for_update_mode Unexecuted instantiation: bundle.c:hold_lock_file_for_update_mode Unexecuted instantiation: cache-tree.c:hold_lock_file_for_update_mode Unexecuted instantiation: commit-graph.c:hold_lock_file_for_update_mode Unexecuted instantiation: config.c:hold_lock_file_for_update_mode Unexecuted instantiation: environment.c:hold_lock_file_for_update_mode Unexecuted instantiation: fetch-pack.c:hold_lock_file_for_update_mode Unexecuted instantiation: lockfile.c:hold_lock_file_for_update_mode Unexecuted instantiation: merge-recursive.c:hold_lock_file_for_update_mode Unexecuted instantiation: midx-write.c:hold_lock_file_for_update_mode Unexecuted instantiation: object-file.c:hold_lock_file_for_update_mode Unexecuted instantiation: path.c:hold_lock_file_for_update_mode Unexecuted instantiation: range-diff.c:hold_lock_file_for_update_mode Unexecuted instantiation: read-cache.c:hold_lock_file_for_update_mode Unexecuted instantiation: refs.c:hold_lock_file_for_update_mode Unexecuted instantiation: files-backend.c:hold_lock_file_for_update_mode Unexecuted instantiation: reftable-backend.c:hold_lock_file_for_update_mode Unexecuted instantiation: packed-backend.c:hold_lock_file_for_update_mode Unexecuted instantiation: repository.c:hold_lock_file_for_update_mode Unexecuted instantiation: rerere.c:hold_lock_file_for_update_mode Unexecuted instantiation: send-pack.c:hold_lock_file_for_update_mode Unexecuted instantiation: sequencer.c:hold_lock_file_for_update_mode Unexecuted instantiation: shallow.c:hold_lock_file_for_update_mode Unexecuted instantiation: upload-pack.c:hold_lock_file_for_update_mode Unexecuted instantiation: wt-status.c:hold_lock_file_for_update_mode Unexecuted instantiation: loose.c:hold_lock_file_for_update_mode Unexecuted instantiation: error.c:hold_lock_file_for_update_mode Unexecuted instantiation: iter.c:hold_lock_file_for_update_mode Unexecuted instantiation: publicbasics.c:hold_lock_file_for_update_mode Unexecuted instantiation: reader.c:hold_lock_file_for_update_mode Unexecuted instantiation: record.c:hold_lock_file_for_update_mode Unexecuted instantiation: stack.c:hold_lock_file_for_update_mode Unexecuted instantiation: writer.c:hold_lock_file_for_update_mode Unexecuted instantiation: basics.c:hold_lock_file_for_update_mode Unexecuted instantiation: block.c:hold_lock_file_for_update_mode Unexecuted instantiation: blocksource.c:hold_lock_file_for_update_mode Unexecuted instantiation: merged.c:hold_lock_file_for_update_mode Unexecuted instantiation: pq.c:hold_lock_file_for_update_mode Unexecuted instantiation: tree.c:hold_lock_file_for_update_mode |
201 | | |
202 | | /* |
203 | | * Return a nonzero value iff `lk` is currently locked. |
204 | | */ |
205 | | static inline int is_lock_file_locked(struct lock_file *lk) |
206 | 382k | { |
207 | 382k | return is_tempfile_active(lk->tempfile); |
208 | 382k | } Unexecuted instantiation: add.c:is_lock_file_locked Unexecuted instantiation: am.c:is_lock_file_locked Unexecuted instantiation: apply.c:is_lock_file_locked Unexecuted instantiation: checkout-index.c:is_lock_file_locked Unexecuted instantiation: checkout.c:is_lock_file_locked Unexecuted instantiation: clone.c:is_lock_file_locked Unexecuted instantiation: commit.c:is_lock_file_locked Unexecuted instantiation: credential-store.c:is_lock_file_locked Unexecuted instantiation: describe.c:is_lock_file_locked Unexecuted instantiation: diff.c:is_lock_file_locked Unexecuted instantiation: difftool.c:is_lock_file_locked Unexecuted instantiation: fast-import.c:is_lock_file_locked Unexecuted instantiation: fetch.c:is_lock_file_locked Unexecuted instantiation: gc.c:is_lock_file_locked Unexecuted instantiation: merge.c:is_lock_file_locked Unexecuted instantiation: mv.c:is_lock_file_locked Unexecuted instantiation: pack-objects.c:is_lock_file_locked Unexecuted instantiation: prune.c:is_lock_file_locked Unexecuted instantiation: read-tree.c:is_lock_file_locked Unexecuted instantiation: rebase.c:is_lock_file_locked Unexecuted instantiation: receive-pack.c:is_lock_file_locked Unexecuted instantiation: repack.c:is_lock_file_locked Unexecuted instantiation: replay.c:is_lock_file_locked Unexecuted instantiation: reset.c:is_lock_file_locked Unexecuted instantiation: rev-parse.c:is_lock_file_locked Unexecuted instantiation: rm.c:is_lock_file_locked Unexecuted instantiation: sparse-checkout.c:is_lock_file_locked Unexecuted instantiation: stash.c:is_lock_file_locked Unexecuted instantiation: update-index.c:is_lock_file_locked Unexecuted instantiation: git.c:is_lock_file_locked Unexecuted instantiation: add-interactive.c:is_lock_file_locked Unexecuted instantiation: bulk-checkin.c:is_lock_file_locked Unexecuted instantiation: bundle.c:is_lock_file_locked Unexecuted instantiation: cache-tree.c:is_lock_file_locked Unexecuted instantiation: commit-graph.c:is_lock_file_locked Unexecuted instantiation: config.c:is_lock_file_locked Unexecuted instantiation: environment.c:is_lock_file_locked Unexecuted instantiation: fetch-pack.c:is_lock_file_locked Unexecuted instantiation: lockfile.c:is_lock_file_locked Unexecuted instantiation: merge-recursive.c:is_lock_file_locked Unexecuted instantiation: midx-write.c:is_lock_file_locked Unexecuted instantiation: object-file.c:is_lock_file_locked Unexecuted instantiation: path.c:is_lock_file_locked Unexecuted instantiation: range-diff.c:is_lock_file_locked Unexecuted instantiation: read-cache.c:is_lock_file_locked Unexecuted instantiation: refs.c:is_lock_file_locked Unexecuted instantiation: files-backend.c:is_lock_file_locked Unexecuted instantiation: reftable-backend.c:is_lock_file_locked packed-backend.c:is_lock_file_locked Line | Count | Source | 206 | 382k | { | 207 | 382k | return is_tempfile_active(lk->tempfile); | 208 | 382k | } |
Unexecuted instantiation: repository.c:is_lock_file_locked Unexecuted instantiation: rerere.c:is_lock_file_locked Unexecuted instantiation: send-pack.c:is_lock_file_locked Unexecuted instantiation: sequencer.c:is_lock_file_locked Unexecuted instantiation: shallow.c:is_lock_file_locked Unexecuted instantiation: upload-pack.c:is_lock_file_locked Unexecuted instantiation: wt-status.c:is_lock_file_locked Unexecuted instantiation: loose.c:is_lock_file_locked Unexecuted instantiation: error.c:is_lock_file_locked Unexecuted instantiation: iter.c:is_lock_file_locked Unexecuted instantiation: publicbasics.c:is_lock_file_locked Unexecuted instantiation: reader.c:is_lock_file_locked Unexecuted instantiation: record.c:is_lock_file_locked Unexecuted instantiation: stack.c:is_lock_file_locked Unexecuted instantiation: writer.c:is_lock_file_locked Unexecuted instantiation: basics.c:is_lock_file_locked Unexecuted instantiation: block.c:is_lock_file_locked Unexecuted instantiation: blocksource.c:is_lock_file_locked Unexecuted instantiation: merged.c:is_lock_file_locked Unexecuted instantiation: pq.c:is_lock_file_locked Unexecuted instantiation: tree.c:is_lock_file_locked |
209 | | |
210 | | /* |
211 | | * Append an appropriate error message to `buf` following the failure |
212 | | * of `hold_lock_file_for_update()` to lock `path`. `err` should be the |
213 | | * `errno` set by the failing call. |
214 | | */ |
215 | | void unable_to_lock_message(const char *path, int err, |
216 | | struct strbuf *buf); |
217 | | |
218 | | /* |
219 | | * Emit an appropriate error message and `die()` following the failure |
220 | | * of `hold_lock_file_for_update()` to lock `path`. `err` should be the |
221 | | * `errno` set by the failing |
222 | | * call. |
223 | | */ |
224 | | NORETURN void unable_to_lock_die(const char *path, int err); |
225 | | |
226 | | /* |
227 | | * Associate a stdio stream with the lockfile (which must still be |
228 | | * open). Return `NULL` (*without* rolling back the lockfile) on |
229 | | * error. The stream is closed automatically when |
230 | | * `close_lock_file_gently()` is called or when the file is committed or |
231 | | * rolled back. |
232 | | */ |
233 | | static inline FILE *fdopen_lock_file(struct lock_file *lk, const char *mode) |
234 | 1.38k | { |
235 | 1.38k | return fdopen_tempfile(lk->tempfile, mode); |
236 | 1.38k | } Unexecuted instantiation: add.c:fdopen_lock_file Unexecuted instantiation: am.c:fdopen_lock_file Unexecuted instantiation: apply.c:fdopen_lock_file Unexecuted instantiation: checkout-index.c:fdopen_lock_file Unexecuted instantiation: checkout.c:fdopen_lock_file Unexecuted instantiation: clone.c:fdopen_lock_file Unexecuted instantiation: commit.c:fdopen_lock_file Unexecuted instantiation: credential-store.c:fdopen_lock_file Unexecuted instantiation: describe.c:fdopen_lock_file Unexecuted instantiation: diff.c:fdopen_lock_file Unexecuted instantiation: difftool.c:fdopen_lock_file Unexecuted instantiation: fast-import.c:fdopen_lock_file Unexecuted instantiation: fetch.c:fdopen_lock_file Unexecuted instantiation: gc.c:fdopen_lock_file Unexecuted instantiation: merge.c:fdopen_lock_file Unexecuted instantiation: mv.c:fdopen_lock_file Unexecuted instantiation: pack-objects.c:fdopen_lock_file Unexecuted instantiation: prune.c:fdopen_lock_file Unexecuted instantiation: read-tree.c:fdopen_lock_file Unexecuted instantiation: rebase.c:fdopen_lock_file Unexecuted instantiation: receive-pack.c:fdopen_lock_file Unexecuted instantiation: repack.c:fdopen_lock_file Unexecuted instantiation: replay.c:fdopen_lock_file Unexecuted instantiation: reset.c:fdopen_lock_file Unexecuted instantiation: rev-parse.c:fdopen_lock_file Unexecuted instantiation: rm.c:fdopen_lock_file Unexecuted instantiation: sparse-checkout.c:fdopen_lock_file Unexecuted instantiation: stash.c:fdopen_lock_file Unexecuted instantiation: update-index.c:fdopen_lock_file Unexecuted instantiation: git.c:fdopen_lock_file Unexecuted instantiation: add-interactive.c:fdopen_lock_file Unexecuted instantiation: bulk-checkin.c:fdopen_lock_file Unexecuted instantiation: bundle.c:fdopen_lock_file Unexecuted instantiation: cache-tree.c:fdopen_lock_file Unexecuted instantiation: commit-graph.c:fdopen_lock_file Unexecuted instantiation: config.c:fdopen_lock_file Unexecuted instantiation: environment.c:fdopen_lock_file Unexecuted instantiation: fetch-pack.c:fdopen_lock_file Unexecuted instantiation: lockfile.c:fdopen_lock_file Unexecuted instantiation: merge-recursive.c:fdopen_lock_file Unexecuted instantiation: midx-write.c:fdopen_lock_file Unexecuted instantiation: object-file.c:fdopen_lock_file Unexecuted instantiation: path.c:fdopen_lock_file Unexecuted instantiation: range-diff.c:fdopen_lock_file Unexecuted instantiation: read-cache.c:fdopen_lock_file Unexecuted instantiation: refs.c:fdopen_lock_file files-backend.c:fdopen_lock_file Line | Count | Source | 234 | 1.38k | { | 235 | 1.38k | return fdopen_tempfile(lk->tempfile, mode); | 236 | 1.38k | } |
Unexecuted instantiation: reftable-backend.c:fdopen_lock_file Unexecuted instantiation: packed-backend.c:fdopen_lock_file Unexecuted instantiation: repository.c:fdopen_lock_file Unexecuted instantiation: rerere.c:fdopen_lock_file Unexecuted instantiation: send-pack.c:fdopen_lock_file Unexecuted instantiation: sequencer.c:fdopen_lock_file Unexecuted instantiation: shallow.c:fdopen_lock_file Unexecuted instantiation: upload-pack.c:fdopen_lock_file Unexecuted instantiation: wt-status.c:fdopen_lock_file Unexecuted instantiation: loose.c:fdopen_lock_file Unexecuted instantiation: error.c:fdopen_lock_file Unexecuted instantiation: iter.c:fdopen_lock_file Unexecuted instantiation: publicbasics.c:fdopen_lock_file Unexecuted instantiation: reader.c:fdopen_lock_file Unexecuted instantiation: record.c:fdopen_lock_file Unexecuted instantiation: stack.c:fdopen_lock_file Unexecuted instantiation: writer.c:fdopen_lock_file Unexecuted instantiation: basics.c:fdopen_lock_file Unexecuted instantiation: block.c:fdopen_lock_file Unexecuted instantiation: blocksource.c:fdopen_lock_file Unexecuted instantiation: merged.c:fdopen_lock_file Unexecuted instantiation: pq.c:fdopen_lock_file Unexecuted instantiation: tree.c:fdopen_lock_file |
237 | | |
238 | | /* |
239 | | * Return the path of the lockfile. The return value is a pointer to a |
240 | | * field within the lock_file object and should not be freed. |
241 | | */ |
242 | | static inline const char *get_lock_file_path(struct lock_file *lk) |
243 | 39.6k | { |
244 | 39.6k | return get_tempfile_path(lk->tempfile); |
245 | 39.6k | } Unexecuted instantiation: add.c:get_lock_file_path Unexecuted instantiation: am.c:get_lock_file_path Unexecuted instantiation: apply.c:get_lock_file_path Unexecuted instantiation: checkout-index.c:get_lock_file_path Unexecuted instantiation: checkout.c:get_lock_file_path Unexecuted instantiation: clone.c:get_lock_file_path Unexecuted instantiation: commit.c:get_lock_file_path Unexecuted instantiation: credential-store.c:get_lock_file_path Unexecuted instantiation: describe.c:get_lock_file_path Unexecuted instantiation: diff.c:get_lock_file_path Unexecuted instantiation: difftool.c:get_lock_file_path Unexecuted instantiation: fast-import.c:get_lock_file_path Unexecuted instantiation: fetch.c:get_lock_file_path Unexecuted instantiation: gc.c:get_lock_file_path Unexecuted instantiation: merge.c:get_lock_file_path Unexecuted instantiation: mv.c:get_lock_file_path Unexecuted instantiation: pack-objects.c:get_lock_file_path Unexecuted instantiation: prune.c:get_lock_file_path Unexecuted instantiation: read-tree.c:get_lock_file_path Unexecuted instantiation: rebase.c:get_lock_file_path Unexecuted instantiation: receive-pack.c:get_lock_file_path Unexecuted instantiation: repack.c:get_lock_file_path Unexecuted instantiation: replay.c:get_lock_file_path Unexecuted instantiation: reset.c:get_lock_file_path Unexecuted instantiation: rev-parse.c:get_lock_file_path Unexecuted instantiation: rm.c:get_lock_file_path Unexecuted instantiation: sparse-checkout.c:get_lock_file_path Unexecuted instantiation: stash.c:get_lock_file_path Unexecuted instantiation: update-index.c:get_lock_file_path Unexecuted instantiation: git.c:get_lock_file_path Unexecuted instantiation: add-interactive.c:get_lock_file_path Unexecuted instantiation: bulk-checkin.c:get_lock_file_path Unexecuted instantiation: bundle.c:get_lock_file_path Unexecuted instantiation: cache-tree.c:get_lock_file_path Unexecuted instantiation: commit-graph.c:get_lock_file_path config.c:get_lock_file_path Line | Count | Source | 243 | 3.01k | { | 244 | 3.01k | return get_tempfile_path(lk->tempfile); | 245 | 3.01k | } |
Unexecuted instantiation: environment.c:get_lock_file_path Unexecuted instantiation: fetch-pack.c:get_lock_file_path Unexecuted instantiation: lockfile.c:get_lock_file_path Unexecuted instantiation: merge-recursive.c:get_lock_file_path Unexecuted instantiation: midx-write.c:get_lock_file_path Unexecuted instantiation: object-file.c:get_lock_file_path Unexecuted instantiation: path.c:get_lock_file_path Unexecuted instantiation: range-diff.c:get_lock_file_path read-cache.c:get_lock_file_path Line | Count | Source | 243 | 36.6k | { | 244 | 36.6k | return get_tempfile_path(lk->tempfile); | 245 | 36.6k | } |
Unexecuted instantiation: refs.c:get_lock_file_path Unexecuted instantiation: files-backend.c:get_lock_file_path Unexecuted instantiation: reftable-backend.c:get_lock_file_path Unexecuted instantiation: packed-backend.c:get_lock_file_path Unexecuted instantiation: repository.c:get_lock_file_path Unexecuted instantiation: rerere.c:get_lock_file_path Unexecuted instantiation: send-pack.c:get_lock_file_path Unexecuted instantiation: sequencer.c:get_lock_file_path Unexecuted instantiation: shallow.c:get_lock_file_path Unexecuted instantiation: upload-pack.c:get_lock_file_path Unexecuted instantiation: wt-status.c:get_lock_file_path Unexecuted instantiation: loose.c:get_lock_file_path Unexecuted instantiation: error.c:get_lock_file_path Unexecuted instantiation: iter.c:get_lock_file_path Unexecuted instantiation: publicbasics.c:get_lock_file_path Unexecuted instantiation: reader.c:get_lock_file_path Unexecuted instantiation: record.c:get_lock_file_path Unexecuted instantiation: stack.c:get_lock_file_path Unexecuted instantiation: writer.c:get_lock_file_path Unexecuted instantiation: basics.c:get_lock_file_path Unexecuted instantiation: block.c:get_lock_file_path Unexecuted instantiation: blocksource.c:get_lock_file_path Unexecuted instantiation: merged.c:get_lock_file_path Unexecuted instantiation: pq.c:get_lock_file_path Unexecuted instantiation: tree.c:get_lock_file_path |
246 | | |
247 | | static inline int get_lock_file_fd(struct lock_file *lk) |
248 | 20.9k | { |
249 | 20.9k | return get_tempfile_fd(lk->tempfile); |
250 | 20.9k | } Unexecuted instantiation: add.c:get_lock_file_fd Unexecuted instantiation: am.c:get_lock_file_fd Unexecuted instantiation: apply.c:get_lock_file_fd Unexecuted instantiation: checkout-index.c:get_lock_file_fd Unexecuted instantiation: checkout.c:get_lock_file_fd Unexecuted instantiation: clone.c:get_lock_file_fd Unexecuted instantiation: commit.c:get_lock_file_fd Unexecuted instantiation: credential-store.c:get_lock_file_fd Unexecuted instantiation: describe.c:get_lock_file_fd Unexecuted instantiation: diff.c:get_lock_file_fd Unexecuted instantiation: difftool.c:get_lock_file_fd Unexecuted instantiation: fast-import.c:get_lock_file_fd Unexecuted instantiation: fetch.c:get_lock_file_fd Unexecuted instantiation: gc.c:get_lock_file_fd Unexecuted instantiation: merge.c:get_lock_file_fd Unexecuted instantiation: mv.c:get_lock_file_fd Unexecuted instantiation: pack-objects.c:get_lock_file_fd Unexecuted instantiation: prune.c:get_lock_file_fd Unexecuted instantiation: read-tree.c:get_lock_file_fd Unexecuted instantiation: rebase.c:get_lock_file_fd Unexecuted instantiation: receive-pack.c:get_lock_file_fd Unexecuted instantiation: repack.c:get_lock_file_fd Unexecuted instantiation: replay.c:get_lock_file_fd Unexecuted instantiation: reset.c:get_lock_file_fd Unexecuted instantiation: rev-parse.c:get_lock_file_fd Unexecuted instantiation: rm.c:get_lock_file_fd Unexecuted instantiation: sparse-checkout.c:get_lock_file_fd Unexecuted instantiation: stash.c:get_lock_file_fd Unexecuted instantiation: update-index.c:get_lock_file_fd Unexecuted instantiation: git.c:get_lock_file_fd Unexecuted instantiation: add-interactive.c:get_lock_file_fd Unexecuted instantiation: bulk-checkin.c:get_lock_file_fd Unexecuted instantiation: bundle.c:get_lock_file_fd Unexecuted instantiation: cache-tree.c:get_lock_file_fd Unexecuted instantiation: commit-graph.c:get_lock_file_fd Unexecuted instantiation: config.c:get_lock_file_fd Unexecuted instantiation: environment.c:get_lock_file_fd Unexecuted instantiation: fetch-pack.c:get_lock_file_fd Unexecuted instantiation: lockfile.c:get_lock_file_fd Unexecuted instantiation: merge-recursive.c:get_lock_file_fd Unexecuted instantiation: midx-write.c:get_lock_file_fd Unexecuted instantiation: object-file.c:get_lock_file_fd Unexecuted instantiation: path.c:get_lock_file_fd Unexecuted instantiation: range-diff.c:get_lock_file_fd Unexecuted instantiation: read-cache.c:get_lock_file_fd Unexecuted instantiation: refs.c:get_lock_file_fd files-backend.c:get_lock_file_fd Line | Count | Source | 248 | 20.9k | { | 249 | 20.9k | return get_tempfile_fd(lk->tempfile); | 250 | 20.9k | } |
Unexecuted instantiation: reftable-backend.c:get_lock_file_fd Unexecuted instantiation: packed-backend.c:get_lock_file_fd Unexecuted instantiation: repository.c:get_lock_file_fd Unexecuted instantiation: rerere.c:get_lock_file_fd Unexecuted instantiation: send-pack.c:get_lock_file_fd Unexecuted instantiation: sequencer.c:get_lock_file_fd Unexecuted instantiation: shallow.c:get_lock_file_fd Unexecuted instantiation: upload-pack.c:get_lock_file_fd Unexecuted instantiation: wt-status.c:get_lock_file_fd Unexecuted instantiation: loose.c:get_lock_file_fd Unexecuted instantiation: error.c:get_lock_file_fd Unexecuted instantiation: iter.c:get_lock_file_fd Unexecuted instantiation: publicbasics.c:get_lock_file_fd Unexecuted instantiation: reader.c:get_lock_file_fd Unexecuted instantiation: record.c:get_lock_file_fd Unexecuted instantiation: stack.c:get_lock_file_fd Unexecuted instantiation: writer.c:get_lock_file_fd Unexecuted instantiation: basics.c:get_lock_file_fd Unexecuted instantiation: block.c:get_lock_file_fd Unexecuted instantiation: blocksource.c:get_lock_file_fd Unexecuted instantiation: merged.c:get_lock_file_fd Unexecuted instantiation: pq.c:get_lock_file_fd Unexecuted instantiation: tree.c:get_lock_file_fd |
251 | | |
252 | | static inline FILE *get_lock_file_fp(struct lock_file *lk) |
253 | 1.38k | { |
254 | 1.38k | return get_tempfile_fp(lk->tempfile); |
255 | 1.38k | } Unexecuted instantiation: add.c:get_lock_file_fp Unexecuted instantiation: am.c:get_lock_file_fp Unexecuted instantiation: apply.c:get_lock_file_fp Unexecuted instantiation: checkout-index.c:get_lock_file_fp Unexecuted instantiation: checkout.c:get_lock_file_fp Unexecuted instantiation: clone.c:get_lock_file_fp Unexecuted instantiation: commit.c:get_lock_file_fp Unexecuted instantiation: credential-store.c:get_lock_file_fp Unexecuted instantiation: describe.c:get_lock_file_fp Unexecuted instantiation: diff.c:get_lock_file_fp Unexecuted instantiation: difftool.c:get_lock_file_fp Unexecuted instantiation: fast-import.c:get_lock_file_fp Unexecuted instantiation: fetch.c:get_lock_file_fp Unexecuted instantiation: gc.c:get_lock_file_fp Unexecuted instantiation: merge.c:get_lock_file_fp Unexecuted instantiation: mv.c:get_lock_file_fp Unexecuted instantiation: pack-objects.c:get_lock_file_fp Unexecuted instantiation: prune.c:get_lock_file_fp Unexecuted instantiation: read-tree.c:get_lock_file_fp Unexecuted instantiation: rebase.c:get_lock_file_fp Unexecuted instantiation: receive-pack.c:get_lock_file_fp Unexecuted instantiation: repack.c:get_lock_file_fp Unexecuted instantiation: replay.c:get_lock_file_fp Unexecuted instantiation: reset.c:get_lock_file_fp Unexecuted instantiation: rev-parse.c:get_lock_file_fp Unexecuted instantiation: rm.c:get_lock_file_fp Unexecuted instantiation: sparse-checkout.c:get_lock_file_fp Unexecuted instantiation: stash.c:get_lock_file_fp Unexecuted instantiation: update-index.c:get_lock_file_fp Unexecuted instantiation: git.c:get_lock_file_fp Unexecuted instantiation: add-interactive.c:get_lock_file_fp Unexecuted instantiation: bulk-checkin.c:get_lock_file_fp Unexecuted instantiation: bundle.c:get_lock_file_fp Unexecuted instantiation: cache-tree.c:get_lock_file_fp Unexecuted instantiation: commit-graph.c:get_lock_file_fp Unexecuted instantiation: config.c:get_lock_file_fp Unexecuted instantiation: environment.c:get_lock_file_fp Unexecuted instantiation: fetch-pack.c:get_lock_file_fp Unexecuted instantiation: lockfile.c:get_lock_file_fp Unexecuted instantiation: merge-recursive.c:get_lock_file_fp Unexecuted instantiation: midx-write.c:get_lock_file_fp Unexecuted instantiation: object-file.c:get_lock_file_fp Unexecuted instantiation: path.c:get_lock_file_fp Unexecuted instantiation: range-diff.c:get_lock_file_fp Unexecuted instantiation: read-cache.c:get_lock_file_fp Unexecuted instantiation: refs.c:get_lock_file_fp files-backend.c:get_lock_file_fp Line | Count | Source | 253 | 1.38k | { | 254 | 1.38k | return get_tempfile_fp(lk->tempfile); | 255 | 1.38k | } |
Unexecuted instantiation: reftable-backend.c:get_lock_file_fp Unexecuted instantiation: packed-backend.c:get_lock_file_fp Unexecuted instantiation: repository.c:get_lock_file_fp Unexecuted instantiation: rerere.c:get_lock_file_fp Unexecuted instantiation: send-pack.c:get_lock_file_fp Unexecuted instantiation: sequencer.c:get_lock_file_fp Unexecuted instantiation: shallow.c:get_lock_file_fp Unexecuted instantiation: upload-pack.c:get_lock_file_fp Unexecuted instantiation: wt-status.c:get_lock_file_fp Unexecuted instantiation: loose.c:get_lock_file_fp Unexecuted instantiation: error.c:get_lock_file_fp Unexecuted instantiation: iter.c:get_lock_file_fp Unexecuted instantiation: publicbasics.c:get_lock_file_fp Unexecuted instantiation: reader.c:get_lock_file_fp Unexecuted instantiation: record.c:get_lock_file_fp Unexecuted instantiation: stack.c:get_lock_file_fp Unexecuted instantiation: writer.c:get_lock_file_fp Unexecuted instantiation: basics.c:get_lock_file_fp Unexecuted instantiation: block.c:get_lock_file_fp Unexecuted instantiation: blocksource.c:get_lock_file_fp Unexecuted instantiation: merged.c:get_lock_file_fp Unexecuted instantiation: pq.c:get_lock_file_fp Unexecuted instantiation: tree.c:get_lock_file_fp |
256 | | |
257 | | /* |
258 | | * Return the path of the file that is locked by the specified |
259 | | * lock_file object. The caller must free the memory. |
260 | | */ |
261 | | char *get_locked_file_path(struct lock_file *lk); |
262 | | |
263 | | /* |
264 | | * If the lockfile is still open, close it (and the file pointer if it |
265 | | * has been opened using `fdopen_lock_file()`) without renaming the |
266 | | * lockfile over the file being locked. Return 0 upon success. On |
267 | | * failure to `close(2)`, return a negative value (the lockfile is not |
268 | | * rolled back). Usually `commit_lock_file()`, `commit_lock_file_to()`, |
269 | | * or `rollback_lock_file()` should eventually be called. |
270 | | */ |
271 | | static inline int close_lock_file_gently(struct lock_file *lk) |
272 | 39.0k | { |
273 | 39.0k | return close_tempfile_gently(lk->tempfile); |
274 | 39.0k | } Unexecuted instantiation: add.c:close_lock_file_gently Unexecuted instantiation: am.c:close_lock_file_gently Unexecuted instantiation: apply.c:close_lock_file_gently Unexecuted instantiation: checkout-index.c:close_lock_file_gently Unexecuted instantiation: checkout.c:close_lock_file_gently Unexecuted instantiation: clone.c:close_lock_file_gently Unexecuted instantiation: commit.c:close_lock_file_gently Unexecuted instantiation: credential-store.c:close_lock_file_gently Unexecuted instantiation: describe.c:close_lock_file_gently Unexecuted instantiation: diff.c:close_lock_file_gently Unexecuted instantiation: difftool.c:close_lock_file_gently Unexecuted instantiation: fast-import.c:close_lock_file_gently Unexecuted instantiation: fetch.c:close_lock_file_gently Unexecuted instantiation: gc.c:close_lock_file_gently Unexecuted instantiation: merge.c:close_lock_file_gently Unexecuted instantiation: mv.c:close_lock_file_gently Unexecuted instantiation: pack-objects.c:close_lock_file_gently Unexecuted instantiation: prune.c:close_lock_file_gently Unexecuted instantiation: read-tree.c:close_lock_file_gently Unexecuted instantiation: rebase.c:close_lock_file_gently Unexecuted instantiation: receive-pack.c:close_lock_file_gently Unexecuted instantiation: repack.c:close_lock_file_gently Unexecuted instantiation: replay.c:close_lock_file_gently Unexecuted instantiation: reset.c:close_lock_file_gently Unexecuted instantiation: rev-parse.c:close_lock_file_gently Unexecuted instantiation: rm.c:close_lock_file_gently Unexecuted instantiation: sparse-checkout.c:close_lock_file_gently Unexecuted instantiation: stash.c:close_lock_file_gently Unexecuted instantiation: update-index.c:close_lock_file_gently Unexecuted instantiation: git.c:close_lock_file_gently Unexecuted instantiation: add-interactive.c:close_lock_file_gently Unexecuted instantiation: bulk-checkin.c:close_lock_file_gently Unexecuted instantiation: bundle.c:close_lock_file_gently Unexecuted instantiation: cache-tree.c:close_lock_file_gently Unexecuted instantiation: commit-graph.c:close_lock_file_gently Unexecuted instantiation: config.c:close_lock_file_gently Unexecuted instantiation: environment.c:close_lock_file_gently Unexecuted instantiation: fetch-pack.c:close_lock_file_gently Unexecuted instantiation: lockfile.c:close_lock_file_gently Unexecuted instantiation: merge-recursive.c:close_lock_file_gently Unexecuted instantiation: midx-write.c:close_lock_file_gently Unexecuted instantiation: object-file.c:close_lock_file_gently Unexecuted instantiation: path.c:close_lock_file_gently Unexecuted instantiation: range-diff.c:close_lock_file_gently Unexecuted instantiation: read-cache.c:close_lock_file_gently Unexecuted instantiation: refs.c:close_lock_file_gently files-backend.c:close_lock_file_gently Line | Count | Source | 272 | 30.0k | { | 273 | 30.0k | return close_tempfile_gently(lk->tempfile); | 274 | 30.0k | } |
Unexecuted instantiation: reftable-backend.c:close_lock_file_gently packed-backend.c:close_lock_file_gently Line | Count | Source | 272 | 9.08k | { | 273 | 9.08k | return close_tempfile_gently(lk->tempfile); | 274 | 9.08k | } |
Unexecuted instantiation: repository.c:close_lock_file_gently Unexecuted instantiation: rerere.c:close_lock_file_gently Unexecuted instantiation: send-pack.c:close_lock_file_gently Unexecuted instantiation: sequencer.c:close_lock_file_gently Unexecuted instantiation: shallow.c:close_lock_file_gently Unexecuted instantiation: upload-pack.c:close_lock_file_gently Unexecuted instantiation: wt-status.c:close_lock_file_gently Unexecuted instantiation: loose.c:close_lock_file_gently Unexecuted instantiation: error.c:close_lock_file_gently Unexecuted instantiation: iter.c:close_lock_file_gently Unexecuted instantiation: publicbasics.c:close_lock_file_gently Unexecuted instantiation: reader.c:close_lock_file_gently Unexecuted instantiation: record.c:close_lock_file_gently Unexecuted instantiation: stack.c:close_lock_file_gently Unexecuted instantiation: writer.c:close_lock_file_gently Unexecuted instantiation: basics.c:close_lock_file_gently Unexecuted instantiation: block.c:close_lock_file_gently Unexecuted instantiation: blocksource.c:close_lock_file_gently Unexecuted instantiation: merged.c:close_lock_file_gently Unexecuted instantiation: pq.c:close_lock_file_gently Unexecuted instantiation: tree.c:close_lock_file_gently |
275 | | |
276 | | /* |
277 | | * Re-open a lockfile that has been closed using `close_lock_file_gently()` |
278 | | * but not yet committed or rolled back. This can be used to implement |
279 | | * a sequence of operations like the following: |
280 | | * |
281 | | * * Lock file. |
282 | | * |
283 | | * * Write new contents to lockfile, then `close_lock_file_gently()` to |
284 | | * cause the contents to be written to disk. |
285 | | * |
286 | | * * Pass the name of the lockfile to another program to allow it (and |
287 | | * nobody else) to inspect the contents you wrote, while still |
288 | | * holding the lock yourself. |
289 | | * |
290 | | * * `reopen_lock_file()` to reopen the lockfile, truncating the existing |
291 | | * contents. Write out the new contents. |
292 | | * |
293 | | * * `commit_lock_file()` to make the final version permanent. |
294 | | */ |
295 | | static inline int reopen_lock_file(struct lock_file *lk) |
296 | 0 | { |
297 | 0 | return reopen_tempfile(lk->tempfile); |
298 | 0 | } Unexecuted instantiation: add.c:reopen_lock_file Unexecuted instantiation: am.c:reopen_lock_file Unexecuted instantiation: apply.c:reopen_lock_file Unexecuted instantiation: checkout-index.c:reopen_lock_file Unexecuted instantiation: checkout.c:reopen_lock_file Unexecuted instantiation: clone.c:reopen_lock_file Unexecuted instantiation: commit.c:reopen_lock_file Unexecuted instantiation: credential-store.c:reopen_lock_file Unexecuted instantiation: describe.c:reopen_lock_file Unexecuted instantiation: diff.c:reopen_lock_file Unexecuted instantiation: difftool.c:reopen_lock_file Unexecuted instantiation: fast-import.c:reopen_lock_file Unexecuted instantiation: fetch.c:reopen_lock_file Unexecuted instantiation: gc.c:reopen_lock_file Unexecuted instantiation: merge.c:reopen_lock_file Unexecuted instantiation: mv.c:reopen_lock_file Unexecuted instantiation: pack-objects.c:reopen_lock_file Unexecuted instantiation: prune.c:reopen_lock_file Unexecuted instantiation: read-tree.c:reopen_lock_file Unexecuted instantiation: rebase.c:reopen_lock_file Unexecuted instantiation: receive-pack.c:reopen_lock_file Unexecuted instantiation: repack.c:reopen_lock_file Unexecuted instantiation: replay.c:reopen_lock_file Unexecuted instantiation: reset.c:reopen_lock_file Unexecuted instantiation: rev-parse.c:reopen_lock_file Unexecuted instantiation: rm.c:reopen_lock_file Unexecuted instantiation: sparse-checkout.c:reopen_lock_file Unexecuted instantiation: stash.c:reopen_lock_file Unexecuted instantiation: update-index.c:reopen_lock_file Unexecuted instantiation: git.c:reopen_lock_file Unexecuted instantiation: add-interactive.c:reopen_lock_file Unexecuted instantiation: bulk-checkin.c:reopen_lock_file Unexecuted instantiation: bundle.c:reopen_lock_file Unexecuted instantiation: cache-tree.c:reopen_lock_file Unexecuted instantiation: commit-graph.c:reopen_lock_file Unexecuted instantiation: config.c:reopen_lock_file Unexecuted instantiation: environment.c:reopen_lock_file Unexecuted instantiation: fetch-pack.c:reopen_lock_file Unexecuted instantiation: lockfile.c:reopen_lock_file Unexecuted instantiation: merge-recursive.c:reopen_lock_file Unexecuted instantiation: midx-write.c:reopen_lock_file Unexecuted instantiation: object-file.c:reopen_lock_file Unexecuted instantiation: path.c:reopen_lock_file Unexecuted instantiation: range-diff.c:reopen_lock_file Unexecuted instantiation: read-cache.c:reopen_lock_file Unexecuted instantiation: refs.c:reopen_lock_file Unexecuted instantiation: files-backend.c:reopen_lock_file Unexecuted instantiation: reftable-backend.c:reopen_lock_file Unexecuted instantiation: packed-backend.c:reopen_lock_file Unexecuted instantiation: repository.c:reopen_lock_file Unexecuted instantiation: rerere.c:reopen_lock_file Unexecuted instantiation: send-pack.c:reopen_lock_file Unexecuted instantiation: sequencer.c:reopen_lock_file Unexecuted instantiation: shallow.c:reopen_lock_file Unexecuted instantiation: upload-pack.c:reopen_lock_file Unexecuted instantiation: wt-status.c:reopen_lock_file Unexecuted instantiation: loose.c:reopen_lock_file Unexecuted instantiation: error.c:reopen_lock_file Unexecuted instantiation: iter.c:reopen_lock_file Unexecuted instantiation: publicbasics.c:reopen_lock_file Unexecuted instantiation: reader.c:reopen_lock_file Unexecuted instantiation: record.c:reopen_lock_file Unexecuted instantiation: stack.c:reopen_lock_file Unexecuted instantiation: writer.c:reopen_lock_file Unexecuted instantiation: basics.c:reopen_lock_file Unexecuted instantiation: block.c:reopen_lock_file Unexecuted instantiation: blocksource.c:reopen_lock_file Unexecuted instantiation: merged.c:reopen_lock_file Unexecuted instantiation: pq.c:reopen_lock_file Unexecuted instantiation: tree.c:reopen_lock_file |
299 | | |
300 | | /* |
301 | | * Commit the change represented by `lk`: close the file descriptor |
302 | | * and/or file pointer if they are still open and rename the lockfile |
303 | | * to its final destination. Return 0 upon success. On failure, roll |
304 | | * back the lock file and return -1, with `errno` set to the value |
305 | | * from the failing call to `close(2)` or `rename(2)`. It is a bug to |
306 | | * call `commit_lock_file()` for a `lock_file` object that is not |
307 | | * currently locked. |
308 | | */ |
309 | | int commit_lock_file(struct lock_file *lk); |
310 | | |
311 | | /* |
312 | | * Like `commit_lock_file()`, but rename the lockfile to the provided |
313 | | * `path`. `path` must be on the same filesystem as the lock file. |
314 | | */ |
315 | | static inline int commit_lock_file_to(struct lock_file *lk, const char *path) |
316 | 34.5k | { |
317 | 34.5k | return rename_tempfile(&lk->tempfile, path); |
318 | 34.5k | } Unexecuted instantiation: add.c:commit_lock_file_to Unexecuted instantiation: am.c:commit_lock_file_to Unexecuted instantiation: apply.c:commit_lock_file_to Unexecuted instantiation: checkout-index.c:commit_lock_file_to Unexecuted instantiation: checkout.c:commit_lock_file_to Unexecuted instantiation: clone.c:commit_lock_file_to Unexecuted instantiation: commit.c:commit_lock_file_to Unexecuted instantiation: credential-store.c:commit_lock_file_to Unexecuted instantiation: describe.c:commit_lock_file_to Unexecuted instantiation: diff.c:commit_lock_file_to Unexecuted instantiation: difftool.c:commit_lock_file_to Unexecuted instantiation: fast-import.c:commit_lock_file_to Unexecuted instantiation: fetch.c:commit_lock_file_to Unexecuted instantiation: gc.c:commit_lock_file_to Unexecuted instantiation: merge.c:commit_lock_file_to Unexecuted instantiation: mv.c:commit_lock_file_to Unexecuted instantiation: pack-objects.c:commit_lock_file_to Unexecuted instantiation: prune.c:commit_lock_file_to Unexecuted instantiation: read-tree.c:commit_lock_file_to Unexecuted instantiation: rebase.c:commit_lock_file_to Unexecuted instantiation: receive-pack.c:commit_lock_file_to Unexecuted instantiation: repack.c:commit_lock_file_to Unexecuted instantiation: replay.c:commit_lock_file_to Unexecuted instantiation: reset.c:commit_lock_file_to Unexecuted instantiation: rev-parse.c:commit_lock_file_to Unexecuted instantiation: rm.c:commit_lock_file_to Unexecuted instantiation: sparse-checkout.c:commit_lock_file_to Unexecuted instantiation: stash.c:commit_lock_file_to Unexecuted instantiation: update-index.c:commit_lock_file_to Unexecuted instantiation: git.c:commit_lock_file_to Unexecuted instantiation: add-interactive.c:commit_lock_file_to Unexecuted instantiation: bulk-checkin.c:commit_lock_file_to Unexecuted instantiation: bundle.c:commit_lock_file_to Unexecuted instantiation: cache-tree.c:commit_lock_file_to Unexecuted instantiation: commit-graph.c:commit_lock_file_to Unexecuted instantiation: config.c:commit_lock_file_to Unexecuted instantiation: environment.c:commit_lock_file_to Unexecuted instantiation: fetch-pack.c:commit_lock_file_to lockfile.c:commit_lock_file_to Line | Count | Source | 316 | 34.5k | { | 317 | 34.5k | return rename_tempfile(&lk->tempfile, path); | 318 | 34.5k | } |
Unexecuted instantiation: merge-recursive.c:commit_lock_file_to Unexecuted instantiation: midx-write.c:commit_lock_file_to Unexecuted instantiation: object-file.c:commit_lock_file_to Unexecuted instantiation: path.c:commit_lock_file_to Unexecuted instantiation: range-diff.c:commit_lock_file_to Unexecuted instantiation: read-cache.c:commit_lock_file_to Unexecuted instantiation: refs.c:commit_lock_file_to Unexecuted instantiation: files-backend.c:commit_lock_file_to Unexecuted instantiation: reftable-backend.c:commit_lock_file_to Unexecuted instantiation: packed-backend.c:commit_lock_file_to Unexecuted instantiation: repository.c:commit_lock_file_to Unexecuted instantiation: rerere.c:commit_lock_file_to Unexecuted instantiation: send-pack.c:commit_lock_file_to Unexecuted instantiation: sequencer.c:commit_lock_file_to Unexecuted instantiation: shallow.c:commit_lock_file_to Unexecuted instantiation: upload-pack.c:commit_lock_file_to Unexecuted instantiation: wt-status.c:commit_lock_file_to Unexecuted instantiation: loose.c:commit_lock_file_to Unexecuted instantiation: error.c:commit_lock_file_to Unexecuted instantiation: iter.c:commit_lock_file_to Unexecuted instantiation: publicbasics.c:commit_lock_file_to Unexecuted instantiation: reader.c:commit_lock_file_to Unexecuted instantiation: record.c:commit_lock_file_to Unexecuted instantiation: stack.c:commit_lock_file_to Unexecuted instantiation: writer.c:commit_lock_file_to Unexecuted instantiation: basics.c:commit_lock_file_to Unexecuted instantiation: block.c:commit_lock_file_to Unexecuted instantiation: blocksource.c:commit_lock_file_to Unexecuted instantiation: merged.c:commit_lock_file_to Unexecuted instantiation: pq.c:commit_lock_file_to Unexecuted instantiation: tree.c:commit_lock_file_to |
319 | | |
320 | | /* |
321 | | * Roll back `lk`: close the file descriptor and/or file pointer and |
322 | | * remove the lockfile. It is a NOOP to call `rollback_lock_file()` |
323 | | * for a `lock_file` object that has already been committed or rolled |
324 | | * back. No error will be returned in this case. |
325 | | */ |
326 | | static inline int rollback_lock_file(struct lock_file *lk) |
327 | 61.8k | { |
328 | 61.8k | return delete_tempfile(&lk->tempfile); |
329 | 61.8k | } Unexecuted instantiation: add.c:rollback_lock_file Unexecuted instantiation: am.c:rollback_lock_file Unexecuted instantiation: apply.c:rollback_lock_file Unexecuted instantiation: checkout-index.c:rollback_lock_file Unexecuted instantiation: checkout.c:rollback_lock_file Unexecuted instantiation: clone.c:rollback_lock_file Unexecuted instantiation: commit.c:rollback_lock_file Unexecuted instantiation: credential-store.c:rollback_lock_file Unexecuted instantiation: describe.c:rollback_lock_file Unexecuted instantiation: diff.c:rollback_lock_file Unexecuted instantiation: difftool.c:rollback_lock_file Unexecuted instantiation: fast-import.c:rollback_lock_file Unexecuted instantiation: fetch.c:rollback_lock_file Unexecuted instantiation: gc.c:rollback_lock_file Unexecuted instantiation: merge.c:rollback_lock_file Unexecuted instantiation: mv.c:rollback_lock_file Unexecuted instantiation: pack-objects.c:rollback_lock_file Unexecuted instantiation: prune.c:rollback_lock_file Unexecuted instantiation: read-tree.c:rollback_lock_file Unexecuted instantiation: rebase.c:rollback_lock_file Unexecuted instantiation: receive-pack.c:rollback_lock_file Unexecuted instantiation: repack.c:rollback_lock_file Unexecuted instantiation: replay.c:rollback_lock_file Unexecuted instantiation: reset.c:rollback_lock_file Unexecuted instantiation: rev-parse.c:rollback_lock_file Unexecuted instantiation: rm.c:rollback_lock_file Unexecuted instantiation: sparse-checkout.c:rollback_lock_file Unexecuted instantiation: stash.c:rollback_lock_file Unexecuted instantiation: update-index.c:rollback_lock_file Unexecuted instantiation: git.c:rollback_lock_file Unexecuted instantiation: add-interactive.c:rollback_lock_file Unexecuted instantiation: bulk-checkin.c:rollback_lock_file Unexecuted instantiation: bundle.c:rollback_lock_file Unexecuted instantiation: cache-tree.c:rollback_lock_file Unexecuted instantiation: commit-graph.c:rollback_lock_file config.c:rollback_lock_file Line | Count | Source | 327 | 4.39k | { | 328 | 4.39k | return delete_tempfile(&lk->tempfile); | 329 | 4.39k | } |
Unexecuted instantiation: environment.c:rollback_lock_file Unexecuted instantiation: fetch-pack.c:rollback_lock_file Unexecuted instantiation: lockfile.c:rollback_lock_file Unexecuted instantiation: merge-recursive.c:rollback_lock_file Unexecuted instantiation: midx-write.c:rollback_lock_file Unexecuted instantiation: object-file.c:rollback_lock_file Unexecuted instantiation: path.c:rollback_lock_file Unexecuted instantiation: range-diff.c:rollback_lock_file read-cache.c:rollback_lock_file Line | Count | Source | 327 | 18.3k | { | 328 | 18.3k | return delete_tempfile(&lk->tempfile); | 329 | 18.3k | } |
Unexecuted instantiation: refs.c:rollback_lock_file files-backend.c:rollback_lock_file Line | Count | Source | 327 | 30.0k | { | 328 | 30.0k | return delete_tempfile(&lk->tempfile); | 329 | 30.0k | } |
Unexecuted instantiation: reftable-backend.c:rollback_lock_file packed-backend.c:rollback_lock_file Line | Count | Source | 327 | 9.08k | { | 328 | 9.08k | return delete_tempfile(&lk->tempfile); | 329 | 9.08k | } |
Unexecuted instantiation: repository.c:rollback_lock_file Unexecuted instantiation: rerere.c:rollback_lock_file Unexecuted instantiation: send-pack.c:rollback_lock_file Unexecuted instantiation: sequencer.c:rollback_lock_file Unexecuted instantiation: shallow.c:rollback_lock_file Unexecuted instantiation: upload-pack.c:rollback_lock_file Unexecuted instantiation: wt-status.c:rollback_lock_file Unexecuted instantiation: loose.c:rollback_lock_file Unexecuted instantiation: error.c:rollback_lock_file Unexecuted instantiation: iter.c:rollback_lock_file Unexecuted instantiation: publicbasics.c:rollback_lock_file Unexecuted instantiation: reader.c:rollback_lock_file Unexecuted instantiation: record.c:rollback_lock_file Unexecuted instantiation: stack.c:rollback_lock_file Unexecuted instantiation: writer.c:rollback_lock_file Unexecuted instantiation: basics.c:rollback_lock_file Unexecuted instantiation: block.c:rollback_lock_file Unexecuted instantiation: blocksource.c:rollback_lock_file Unexecuted instantiation: merged.c:rollback_lock_file Unexecuted instantiation: pq.c:rollback_lock_file Unexecuted instantiation: tree.c:rollback_lock_file |
330 | | |
331 | | #endif /* LOCKFILE_H */ |