{"thread":{"id":"40208","subject":"[PATCH] lockfile: remove function \"hold_lock_file_for_append\"","startedAt":"2015-08-28T16:55:52Z","lastAt":"2015-08-28T17:32:10Z","messageCount":2,"participants":["Ralf Thielow","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"268846","messageId":"1440780952-5859-1-git-send-email-ralf.thielow@gmail.com","threadId":"40208","inReplyTo":null,"subject":"[PATCH] lockfile: remove function \"hold_lock_file_for_append\"","fromName":"Ralf Thielow","fromEmail":"ralf.thielow@gmail.com","sentAt":"2015-08-28T16:55:52Z","receivedAt":"2015-08-28T16:55:52Z","isPatch":true,"sender":{"key":"ralf.thielow@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1275832?v=4"},"body":"With 77b9b1d (add_to_alternates_file: don't add duplicate entries,\n2015-08-10) the last caller of function \"hold_lock_file_for_append\"\nhas been removed, so we can remove the function as well.\n\nSigned-off-by: Ralf Thielow <ralf.thielow@gmail.com>\n---\nThis is the second bullet point in\nhttp://git-blame.blogspot.de/p/leftover-bits.html\n\n lockfile.c | 38 --------------------------------------\n lockfile.h | 26 +++++++-------------------\n 2 files changed, 7 insertions(+), 57 deletions(-)\n\ndiff --git a/lockfile.c b/lockfile.c\nindex 637b8cf..80d056d 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -177,44 +177,6 @@ int hold_lock_file_for_update_timeout(struct lock_file *lk, const char *path,\n \treturn fd;\n }\n \n-int hold_lock_file_for_append(struct lock_file *lk, const char *path, int flags)\n-{\n-\tint fd, orig_fd;\n-\n-\tfd = lock_file(lk, path, flags);\n-\tif (fd < 0) {\n-\t\tif (flags & LOCK_DIE_ON_ERROR)\n-\t\t\tunable_to_lock_die(path, errno);\n-\t\treturn fd;\n-\t}\n-\n-\torig_fd = open(path, O_RDONLY);\n-\tif (orig_fd < 0) {\n-\t\tif (errno != ENOENT) {\n-\t\t\tint save_errno = errno;\n-\n-\t\t\tif (flags & LOCK_DIE_ON_ERROR)\n-\t\t\t\tdie(\"cannot open '%s' for copying\", path);\n-\t\t\trollback_lock_file(lk);\n-\t\t\terror(\"cannot open '%s' for copying\", path);\n-\t\t\terrno = save_errno;\n-\t\t\treturn -1;\n-\t\t}\n-\t} else if (copy_fd(orig_fd, fd)) {\n-\t\tint save_errno = errno;\n-\n-\t\tif (flags & LOCK_DIE_ON_ERROR)\n-\t\t\tdie(\"failed to prepare '%s' for appending\", path);\n-\t\tclose(orig_fd);\n-\t\trollback_lock_file(lk);\n-\t\terrno = save_errno;\n-\t\treturn -1;\n-\t} else {\n-\t\tclose(orig_fd);\n-\t}\n-\treturn fd;\n-}\n-\n char *get_locked_file_path(struct lock_file *lk)\n {\n \tstruct strbuf ret = STRBUF_INIT;\ndiff --git a/lockfile.h b/lockfile.h\nindex 8131fa3..3d30193 100644\n--- a/lockfile.h\n+++ b/lockfile.h\n@@ -44,8 +44,7 @@\n  *   throughout the life of the program (i.e. you cannot use an\n  *   on-stack variable to hold this structure).\n  *\n- * * Attempts to create a lockfile by calling\n- *   `hold_lock_file_for_update()` or `hold_lock_file_for_append()`.\n+ * * Attempts to create a lockfile by calling `hold_lock_file_for_update()`.\n  *\n  * * Writes new content for the destination file by either:\n  *\n@@ -73,7 +72,7 @@\n  * Even after the lockfile is committed or rolled back, the\n  * `lock_file` object must not be freed or altered by the caller.\n  * However, it may be reused; just pass it to another call of\n- * `hold_lock_file_for_update()` or `hold_lock_file_for_append()`.\n+ * `hold_lock_file_for_update()`.\n  *\n  * If the program exits before `commit_lock_file()`,\n  * `commit_lock_file_to()`, or `rollback_lock_file()` is called, the\n@@ -120,8 +119,7 @@ struct lock_file {\n  * Flags\n  * -----\n  *\n- * The following flags can be passed to `hold_lock_file_for_update()`\n- * or `hold_lock_file_for_append()`.\n+ * The following flags can be passed to `hold_lock_file_for_update()`.\n  */\n \n /*\n@@ -168,27 +166,17 @@ static inline int hold_lock_file_for_update(\n }\n \n /*\n- * Like `hold_lock_file_for_update()`, but before returning copy the\n- * existing contents of the file (if any) to the lockfile and position\n- * its write pointer at the end of the file. The flags argument and\n- * error handling are described above.\n- */\n-extern int hold_lock_file_for_append(struct lock_file *lk,\n-\t\t\t\t     const char *path, int flags);\n-\n-/*\n  * Append an appropriate error message to `buf` following the failure\n- * of `hold_lock_file_for_update()` or `hold_lock_file_for_append()`\n- * to lock `path`. `err` should be the `errno` set by the failing\n- * call.\n+ * of `hold_lock_file_for_update()` to lock `path`. `err` should be the\n+ * `errno` set by the failing call.\n  */\n extern void unable_to_lock_message(const char *path, int err,\n \t\t\t\t   struct strbuf *buf);\n \n /*\n  * Emit an appropriate error message and `die()` following the failure\n- * of `hold_lock_file_for_update()` or `hold_lock_file_for_append()`\n- * to lock `path`. `err` should be the `errno` set by the failing\n+ * of `hold_lock_file_for_update()` to lock `path`. `err` should be the\n+ * `errno` set by the failing\n  * call.\n  */\n extern NORETURN void unable_to_lock_die(const char *path, int err);\n-- \n2.5.0.614.g6f325f9\n"},{"id":"268855","messageId":"20150828173210.GB9126@sigill.intra.peff.net","threadId":"40208","inReplyTo":"1440780952-5859-1-git-send-email-ralf.thielow@gmail.com","subject":"Re: [PATCH] lockfile: remove function \"hold_lock_file_for_append\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-08-28T17:32:10Z","receivedAt":"2015-08-28T17:32:10Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Aug 28, 2015 at 06:55:52PM +0200, Ralf Thielow wrote:\n\n> With 77b9b1d (add_to_alternates_file: don't add duplicate entries,\n> 2015-08-10) the last caller of function \"hold_lock_file_for_append\"\n> has been removed, so we can remove the function as well.\n\nHeh. I have the same patch, but was holding it back until mh/tempfile\ngraduated to master, which it did a few days ago.  I diffed mine against\nyours, and came up empty aside from one or two minor wrapping choices.\n\nSo looks good to me.\n\n-Peff\n"}]}