summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-10-01 12:28:39 +0200
committerJunio C Hamano <gitster@pobox.com>2014-10-01 13:53:54 -0700
commitec38b4e482e96e62762452cab5714e55abdb48c3 (patch)
tree7b9e0268013d641289da53c9630ebd7af5aba8d7 /refs.c
parent316683bd37608e31cc3f5e932c4e5c7dde1b39f0 (diff)
downloadgit-ec38b4e482e96e62762452cab5714e55abdb48c3.tar.gz
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 <sahlberg@google.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c4
1 files changed, 1 insertions, 3 deletions
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)