Skip to content

Commit

Permalink
refs.c: remove unlock_ref/close_ref/commit_ref from the refs api
Browse files Browse the repository at this point in the history
unlock|close|commit_ref can be made static since there are no more external
callers.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Ronnie Sahlberg authored and Junio C Hamano committed Dec 22, 2014
1 parent fa5b183 commit 0b1e654
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
24 changes: 12 additions & 12 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,16 @@ int refname_match(const char *abbrev_name, const char *full_name)
return 0;
}

static void unlock_ref(struct ref_lock *lock)
{
/* 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);
}

/* This function should make sure errno is meaningful on error */
static struct ref_lock *verify_lock(struct ref_lock *lock,
const unsigned char *old_sha1, int mustexist)
Expand Down Expand Up @@ -2888,32 +2898,22 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
return 1;
}

int close_ref(struct ref_lock *lock)
static 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)
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 (lock->lk)
rollback_lock_file(lock->lk);
free(lock->ref_name);
free(lock->orig_ref_name);
free(lock);
}

/*
* copy the reflog message msg to buf, which has been allocated sufficiently
* large, while cleaning up the whitespaces. Especially, convert LF to space,
Expand Down
9 changes: 0 additions & 9 deletions refs.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,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);

/** Release any lock taken but not written. **/
extern void unlock_ref(struct ref_lock *lock);

/*
* Setup reflog before using. Set errno to something meaningful on failure.
*/
Expand Down

0 comments on commit 0b1e654

Please sign in to comment.