From ec38b4e482e96e62762452cab5714e55abdb48c3 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Wed, 1 Oct 2014 12:28:39 +0200 Subject: get_locked_file_path(): new function Add a function to return the path of the file that is locked by a lock_file object. This reduces the knowledge that callers have to have about the lock_file layout. Suggested-by: Ronnie Sahlberg Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- refs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'refs.c') diff --git a/refs.c b/refs.c index c10eaff57f..e40c47edce 100644 --- a/refs.c +++ b/refs.c @@ -2606,9 +2606,7 @@ static int delete_ref_loose(struct ref_lock *lock, int flag) * loose. The loose file name is the same as the * lockfile name, minus ".lock": */ - char *loose_filename = xmemdupz( - lock->lk->filename.buf, - lock->lk->filename.len - LOCK_SUFFIX_LEN); + char *loose_filename = get_locked_file_path(lock->lk); int err = unlink_or_warn(loose_filename); free(loose_filename); if (err && errno != ENOENT) -- cgit v1.2.1