From: Ronnie Sahlberg <sahlberg@google.com>
To: git@vger.kernel.org
Cc: Ronnie Sahlberg <sahlberg@google.com>
Subject: [PATCH] Remove the close_ref function.
Date: Tue, 8 Apr 2014 14:17:10 -0700 [thread overview]
Message-ID: <1396991830-20938-2-git-send-email-sahlberg@google.com> (raw)
In-Reply-To: <1396991830-20938-1-git-send-email-sahlberg@google.com>
close_ref() is only called from two codepaths semi-immediately before unlock_ref() is called.
Since unlock_ref() will also close the file if it is still open, we can delete close_ref() and
let the file become closed during unlock_ref().
This simplifies the refs.c api by removing a redundant function.
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
---
builtin/reflog.c | 3 +--
refs.c | 11 +----------
refs.h | 3 ---
3 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/builtin/reflog.c b/builtin/reflog.c
index c12a9784..b67fbe6 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -428,8 +428,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
} else if (cmd->updateref &&
(write_in_full(lock->lock_fd,
sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
- write_str_in_full(lock->lock_fd, "\n") != 1 ||
- close_ref(lock) < 0)) {
+ write_str_in_full(lock->lock_fd, "\n") != 1)) {
status |= error("Couldn't write %s",
lock->lk->filename);
unlink(newlog_path);
diff --git a/refs.c b/refs.c
index 28d5eca..094b047 100644
--- a/refs.c
+++ b/refs.c
@@ -2665,14 +2665,6 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
return 1;
}
-int close_ref(struct ref_lock *lock)
-{
- if (close_lock_file(lock->lk))
- return -1;
- lock->lock_fd = -1;
- return 0;
-}
-
int commit_ref(struct ref_lock *lock)
{
if (commit_lock_file(lock->lk))
@@ -2824,8 +2816,7 @@ int write_ref_sha1(struct ref_lock *lock,
return -1;
}
if (write_in_full(lock->lock_fd, sha1_to_hex(sha1), 40) != 40 ||
- write_in_full(lock->lock_fd, &term, 1) != 1
- || close_ref(lock) < 0) {
+ write_in_full(lock->lock_fd, &term, 1) != 1) {
error("Couldn't write %s", lock->lk->filename);
unlock_ref(lock);
return -1;
diff --git a/refs.h b/refs.h
index 87a1a79..d8732a5 100644
--- a/refs.h
+++ b/refs.h
@@ -153,9 +153,6 @@ extern struct ref_lock *lock_any_ref_for_update(const char *refname,
const unsigned char *old_sha1,
int flags, int *type_p);
-/** Close the file descriptor owned by a lock and return the status */
-extern int close_ref(struct ref_lock *lock);
-
/** Close and commit the ref locked by the lock */
extern int commit_ref(struct ref_lock *lock);
--
1.9.1.423.g4596e3a
next prev parent reply other threads:[~2014-04-08 21:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-08 21:17 [PATCH] Remove redundant close_ref function Ronnie Sahlberg
2014-04-08 21:17 ` Ronnie Sahlberg [this message]
2014-04-08 21:50 ` [PATCH] Remove the " Junio C Hamano
2014-04-08 22:23 ` Ronnie Sahlberg
2014-04-08 21:32 ` [PATCH] Remove redundant " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1396991830-20938-2-git-send-email-sahlberg@google.com \
--to=sahlberg@google.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox