Skip to content

Commit aae42e4

Browse files
ralfthgitster
authored andcommitted
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>
1 parent db86e61 commit aae42e4

2 files changed

Lines changed: 7 additions & 57 deletions

File tree

lockfile.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -177,44 +177,6 @@ int hold_lock_file_for_update_timeout(struct lock_file *lk, const char *path,
177177
return fd;
178178
}
179179

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-
218180
char *get_locked_file_path(struct lock_file *lk)
219181
{
220182
struct strbuf ret = STRBUF_INIT;

lockfile.h

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
* throughout the life of the program (i.e. you cannot use an
4545
* on-stack variable to hold this structure).
4646
*
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()`.
4948
*
5049
* * Writes new content for the destination file by either:
5150
*
@@ -73,7 +72,7 @@
7372
* Even after the lockfile is committed or rolled back, the
7473
* `lock_file` object must not be freed or altered by the caller.
7574
* 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()`.
7776
*
7877
* If the program exits before `commit_lock_file()`,
7978
* `commit_lock_file_to()`, or `rollback_lock_file()` is called, the
@@ -120,8 +119,7 @@ struct lock_file {
120119
* Flags
121120
* -----
122121
*
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()`.
125123
*/
126124

127125
/*
@@ -167,28 +165,18 @@ static inline int hold_lock_file_for_update(
167165
return hold_lock_file_for_update_timeout(lk, path, flags, 0);
168166
}
169167

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-
179168
/*
180169
* 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.
184172
*/
185173
extern void unable_to_lock_message(const char *path, int err,
186174
struct strbuf *buf);
187175

188176
/*
189177
* 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
192180
* call.
193181
*/
194182
extern NORETURN void unable_to_lock_die(const char *path, int err);

0 commit comments

Comments
 (0)