lockfile: remove function "hold_lock_file_for_append"
With 77b9b1d (add_to_alternates_file: don't add duplicate entries, 2015-08-10) the last caller of function "hold_lock_file_for_append" has been removed, so we can remove the function as well. Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ralf Thielow committed
Aug 28, 2015 at 18:55 UTC
aae42e43c42911a3c260ae9fa8681e779c6d5943
2 files changed
+7
-57
lockfile.c
-38
@@ -177,44 +177,6 @@ int hold_lock_file_for_update_timeout(struct lock_file *lk, const char *path,
177
return fd;
178
}
179
180
-int hold_lock_file_for_append(struct lock_file *lk, const char *path, int flags)
181
-{
182
- int fd, orig_fd;
183
-
184
- fd = lock_file(lk, path, flags);
185
- if (fd < 0) {
186
- if (flags & LOCK_DIE_ON_ERROR)
187
- unable_to_lock_die(path, errno);
188
- return fd;
189
- }
190
-
191
- orig_fd = open(path, O_RDONLY);
192
- if (orig_fd < 0) {
193
- if (errno != ENOENT) {
194
- int save_errno = errno;
195
-
196
- if (flags & LOCK_DIE_ON_ERROR)
197
- die("cannot open '%s' for copying", path);
198
- rollback_lock_file(lk);
199
- error("cannot open '%s' for copying", path);
200
- errno = save_errno;
201
- return -1;
202
- }
203
- } else if (copy_fd(orig_fd, fd)) {
204
- int save_errno = errno;
205
-
206
- if (flags & LOCK_DIE_ON_ERROR)
207
- die("failed to prepare '%s' for appending", path);
208
- close(orig_fd);
209
- rollback_lock_file(lk);
210
- errno = save_errno;
211
- return -1;
212
- } else {
213
- close(orig_fd);
214
- }
215
- return fd;
216
-}
217
-
180
char *get_locked_file_path(struct lock_file *lk)
181
{
182
struct strbuf ret = STRBUF_INIT;
lockfile.h
+7
-19
@@ -44,8 +44,7 @@
44
* throughout the life of the program (i.e. you cannot use an
45
* on-stack variable to hold this structure).
46
*
47
- * * Attempts to create a lockfile by calling
48
- * `hold_lock_file_for_update()` or `hold_lock_file_for_append()`.
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
*
@@ -73,7 +72,7 @@
72
* Even after the lockfile is committed or rolled back, the
73
* `lock_file` object must not be freed or altered by the caller.
74
* However, it may be reused; just pass it to another call of
76
- * `hold_lock_file_for_update()` or `hold_lock_file_for_append()`.
75
+ * `hold_lock_file_for_update()`.
76
*
77
* If the program exits before `commit_lock_file()`,
78
* `commit_lock_file_to()`, or `rollback_lock_file()` is called, the
@@ -120,8 +119,7 @@ struct lock_file {
119
* Flags
120
* -----
121
*
123
- * The following flags can be passed to `hold_lock_file_for_update()`
124
- * or `hold_lock_file_for_append()`.
122
+ * The following flags can be passed to `hold_lock_file_for_update()`.
123
*/
124
125
/*
@@ -167,28 +165,18 @@ static inline int hold_lock_file_for_update(
165
return hold_lock_file_for_update_timeout(lk, path, flags, 0);
166
}
167
170
-/*
171
- * Like `hold_lock_file_for_update()`, but before returning copy the
172
- * existing contents of the file (if any) to the lockfile and position
173
- * its write pointer at the end of the file. The flags argument and
174
- * error handling are described above.
175
- */
176
-extern int hold_lock_file_for_append(struct lock_file *lk,
177
- const char *path, int flags);
178
-
168
/*
169
* Append an appropriate error message to `buf` following the failure
181
- * of `hold_lock_file_for_update()` or `hold_lock_file_for_append()`
182
- * to lock `path`. `err` should be the `errno` set by the failing
183
- * call.
170
+ * of `hold_lock_file_for_update()` to lock `path`. `err` should be the
171
+ * `errno` set by the failing call.
172
*/
173
extern void unable_to_lock_message(const char *path, int err,
174
struct strbuf *buf);
175
176
/*
177
* Emit an appropriate error message and `die()` following the failure
190
- * of `hold_lock_file_for_update()` or `hold_lock_file_for_append()`
191
- * to lock `path`. `err` should be the `errno` set by the failing
178
+ * of `hold_lock_file_for_update()` to lock `path`. `err` should be the
179
+ * `errno` set by the failing
180
* call.
181
*/
182
extern NORETURN void unable_to_lock_die(const char *path, int err);