summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4ed7cd3)
raw | patch | inline | side by side (parent: 4ed7cd3)
author | Brandon Casey <casey@nrlssc.navy.mil> | |
Wed, 16 Jan 2008 19:14:30 +0000 (13:14 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 16 Jan 2008 23:36:10 +0000 (15:36 -0800) |
Instead of calling close_lock_file() and commit_lock_file() directly,
which take a struct lock_file argument, add two new functions:
close_ref() and commit_ref(), which handle calling the previous
lock_file functions and modifying the ref_lock structure.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
which take a struct lock_file argument, add two new functions:
close_ref() and commit_ref(), which handle calling the previous
lock_file functions and modifying the ref_lock structure.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c | patch | blob | history |
index 8a42d39fd7ad11948aaa7f84cbf0b1c8fc4d4a9d..67d2a502afb60050f0ce750c21ae1a42fa5cb803 100644 (file)
--- a/refs.c
+++ b/refs.c
return 1;
}
+static int close_ref(struct ref_lock *lock)
+{
+ if (close_lock_file(lock->lk))
+ return -1;
+ lock->lock_fd = -1;
+ return 0;
+}
+
+static int commit_ref(struct ref_lock *lock)
+{
+ if (commit_lock_file(lock->lk))
+ return -1;
+ lock->lock_fd = -1;
+ return 0;
+}
+
void unlock_ref(struct ref_lock *lock)
{
/* Do not free lock->lk -- atexit() still looks at them */
}
if (write_in_full(lock->lock_fd, sha1_to_hex(sha1), 40) != 40 ||
write_in_full(lock->lock_fd, &term, 1) != 1
- || close_lock_file(lock->lk) < 0) {
+ || close_ref(lock) < 0) {
error("Couldn't write %s", lock->lk->filename);
unlock_ref(lock);
return -1;
!strcmp(head_ref, lock->ref_name))
log_ref_write("HEAD", lock->old_sha1, sha1, logmsg);
}
- if (commit_lock_file(lock->lk)) {
+ if (commit_ref(lock)) {
error("Couldn't set %s", lock->ref_name);
unlock_ref(lock);
return -1;
}
- lock->lock_fd = -1;
unlock_ref(lock);
return 0;
}