delete_ref_loose(): derive loose reference path from lock
authorMichael Haggerty <mhagger@alum.mit.edu>
Fri, 6 Jan 2017 16:22:38 +0000 (17:22 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 8 Jan 2017 03:30:09 +0000 (19:30 -0800)
It is simpler to derive the path to the file that must be deleted from
"lock->ref_name" than from the lock_file object.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c
index 39d6f5b78268a9f496c3283fc22f0256311b9054..4d5536458bf2bb047bfda8c111b75bab0028a9c0 100644 (file)
@@ -2430,10 +2430,7 @@ static int delete_ref_loose(struct ref_lock *lock, int flag, struct strbuf *err)
                 * loose.  The loose file name is the same as the
                 * lockfile name, minus ".lock":
                 */
-               char *loose_filename = get_locked_file_path(lock->lk);
-               int res = unlink_or_msg(loose_filename, err);
-               free(loose_filename);
-               if (res)
+               if (unlink_or_msg(git_path("%s", lock->ref_name), err))
                        return 1;
        }
        return 0;