Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorBrandon Casey <casey@nrlssc.navy.mil>2008-01-16 22:12:46 +0300
committerJunio C Hamano <gitster@pobox.com>2008-01-17 02:35:35 +0300
commit4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb (patch)
treee3b03a59cd0bca192fb396522f813210451404b8 /refs.c
parentd6cf61bfd4bccffcc8b095f8469dbe749d70abdf (diff)
Improve use of lockfile API
Remove remaining double close(2)'s. i.e. close() before commit_locked_index() or commit_lock_file(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/refs.c b/refs.c
index c3ffe0393b..8a42d39fd7 100644
--- a/refs.c
+++ b/refs.c
@@ -864,7 +864,6 @@ static int repack_without_ref(const char *refname)
die("too long a refname '%s'", list->name);
write_or_die(fd, line, len);
}
- close(fd);
return commit_lock_file(&packlock);
}
@@ -1021,12 +1020,9 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
void unlock_ref(struct ref_lock *lock)
{
- if (lock->lock_fd >= 0) {
- close(lock->lock_fd);
- /* Do not free lock->lk -- atexit() still looks at them */
- if (lock->lk)
- rollback_lock_file(lock->lk);
- }
+ /* Do not free lock->lk -- atexit() still looks at them */
+ if (lock->lk)
+ rollback_lock_file(lock->lk);
free(lock->ref_name);
free(lock->orig_ref_name);
free(lock);
@@ -1151,7 +1147,7 @@ int write_ref_sha1(struct ref_lock *lock,
}
if (write_in_full(lock->lock_fd, sha1_to_hex(sha1), 40) != 40 ||
write_in_full(lock->lock_fd, &term, 1) != 1
- || close(lock->lock_fd) < 0) {
+ || close_lock_file(lock->lk) < 0) {
error("Couldn't write %s", lock->lk->filename);
unlock_ref(lock);
return -1;