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>
This commit is contained in:
Ralf Thielow 2015-08-28 18:55:52 +02:00 committed by Junio C Hamano
parent db86e61cbb
commit aae42e43c4
2 changed files with 7 additions and 57 deletions

View File

@ -177,44 +177,6 @@ int hold_lock_file_for_update_timeout(struct lock_file *lk, const char *path,
return fd; return fd;
} }
int hold_lock_file_for_append(struct lock_file *lk, const char *path, int flags)
{
int fd, orig_fd;
fd = lock_file(lk, path, flags);
if (fd < 0) {
if (flags & LOCK_DIE_ON_ERROR)
unable_to_lock_die(path, errno);
return fd;
}
orig_fd = open(path, O_RDONLY);
if (orig_fd < 0) {
if (errno != ENOENT) {
int save_errno = errno;
if (flags & LOCK_DIE_ON_ERROR)
die("cannot open '%s' for copying", path);
rollback_lock_file(lk);
error("cannot open '%s' for copying", path);
errno = save_errno;
return -1;
}
} else if (copy_fd(orig_fd, fd)) {
int save_errno = errno;
if (flags & LOCK_DIE_ON_ERROR)
die("failed to prepare '%s' for appending", path);
close(orig_fd);
rollback_lock_file(lk);
errno = save_errno;
return -1;
} else {
close(orig_fd);
}
return fd;
}
char *get_locked_file_path(struct lock_file *lk) char *get_locked_file_path(struct lock_file *lk)
{ {
struct strbuf ret = STRBUF_INIT; struct strbuf ret = STRBUF_INIT;

View File

@ -44,8 +44,7 @@
* throughout the life of the program (i.e. you cannot use an * throughout the life of the program (i.e. you cannot use an
* on-stack variable to hold this structure). * on-stack variable to hold this structure).
* *
* * Attempts to create a lockfile by calling * * Attempts to create a lockfile by calling `hold_lock_file_for_update()`.
* `hold_lock_file_for_update()` or `hold_lock_file_for_append()`.
* *
* * Writes new content for the destination file by either: * * Writes new content for the destination file by either:
* *
@ -73,7 +72,7 @@
* Even after the lockfile is committed or rolled back, the * Even after the lockfile is committed or rolled back, the
* `lock_file` object must not be freed or altered by the caller. * `lock_file` object must not be freed or altered by the caller.
* However, it may be reused; just pass it to another call of * However, it may be reused; just pass it to another call of
* `hold_lock_file_for_update()` or `hold_lock_file_for_append()`. * `hold_lock_file_for_update()`.
* *
* If the program exits before `commit_lock_file()`, * If the program exits before `commit_lock_file()`,
* `commit_lock_file_to()`, or `rollback_lock_file()` is called, the * `commit_lock_file_to()`, or `rollback_lock_file()` is called, the
@ -120,8 +119,7 @@ struct lock_file {
* Flags * Flags
* ----- * -----
* *
* The following flags can be passed to `hold_lock_file_for_update()` * The following flags can be passed to `hold_lock_file_for_update()`.
* or `hold_lock_file_for_append()`.
*/ */
/* /*
@ -167,28 +165,18 @@ static inline int hold_lock_file_for_update(
return hold_lock_file_for_update_timeout(lk, path, flags, 0); return hold_lock_file_for_update_timeout(lk, path, flags, 0);
} }
/*
* Like `hold_lock_file_for_update()`, but before returning copy the
* existing contents of the file (if any) to the lockfile and position
* its write pointer at the end of the file. The flags argument and
* error handling are described above.
*/
extern int hold_lock_file_for_append(struct lock_file *lk,
const char *path, int flags);
/* /*
* Append an appropriate error message to `buf` following the failure * Append an appropriate error message to `buf` following the failure
* of `hold_lock_file_for_update()` or `hold_lock_file_for_append()` * of `hold_lock_file_for_update()` to lock `path`. `err` should be the
* to lock `path`. `err` should be the `errno` set by the failing * `errno` set by the failing call.
* call.
*/ */
extern void unable_to_lock_message(const char *path, int err, extern void unable_to_lock_message(const char *path, int err,
struct strbuf *buf); struct strbuf *buf);
/* /*
* Emit an appropriate error message and `die()` following the failure * Emit an appropriate error message and `die()` following the failure
* of `hold_lock_file_for_update()` or `hold_lock_file_for_append()` * of `hold_lock_file_for_update()` to lock `path`. `err` should be the
* to lock `path`. `err` should be the `errno` set by the failing * `errno` set by the failing
* call. * call.
*/ */
extern NORETURN void unable_to_lock_die(const char *path, int err); extern NORETURN void unable_to_lock_die(const char *path, int err);