git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 17/20] delete_ref_loose(): derive loose reference path from lock

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Feb 25, 2016, 13:16 UTC
Message-ID
<592eaa8e9ccebb38df8fd60e35b23892bdc92648.1456405699.git.mhagger@alum.mit.edu>
In-Reply-To
<cover.1456405698.git.mhagger@alum.mit.edu>

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>
---
 refs/files-backend.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 46dcc23..7e825bd 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2345,10 +2345,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;
-- 
2.7.0
Previous: Michael HaggertyNext: Michael Haggerty
Message 18 of 21 in “Delete directories left empty after ref deletion”
  1. 00/20 Delete directories left empty after ref deletionMichael Haggerty, Feb 25, 2016
  2. 01/20 safe_create_leading_directories_const(): preserve errnoMichael Haggerty, Feb 25, 2016
  3. 02/20 safe_create_leading_directories(): set errno on SCLD_EXISTSMichael Haggerty, Feb 25, 2016
  4. 03/20 raceproof_create_file(): new functionMichael Haggerty, Feb 25, 2016
  5. 04/20 lock_ref_sha1_basic(): use raceproof_create_file()Michael Haggerty, Feb 25, 2016
  6. 05/20 rename_tmp_log(): use raceproof_create_file()Michael Haggerty, Feb 25, 2016
  7. 06/20 rename_tmp_log(): improve error reportingMichael Haggerty, Feb 25, 2016
  8. 07/20 log_ref_setup(): separate code for create vs non-createMichael Haggerty, Feb 25, 2016
  9. 08/20 log_ref_setup(): improve robustness against racesMichael Haggerty, Feb 25, 2016
  10. 09/20 log_ref_setup(): pass the open file descriptor back to the callerMichael Haggerty, Feb 25, 2016
  11. 10/20 log_ref_write_1(): don't depend on logfileMichael Haggerty, Feb 25, 2016
  12. 11/20 log_ref_setup(): manage the name of the reflog file internallyMichael Haggerty, Feb 25, 2016
  13. 12/20 log_ref_write_1(): inline functionMichael Haggerty, Feb 25, 2016
  14. 13/20 try_remove_empty_parents(): rename parameter "name" -> "refname"Michael Haggerty, Feb 25, 2016
  15. 14/20 try_remove_empty_parents(): don't trash argument contentsMichael Haggerty, Feb 25, 2016
  16. 15/20 try_remove_empty_parents(): don't accommodate consecutive slashesMichael Haggerty, Feb 25, 2016
  17. 16/20 t5505: use "for-each-ref" to test for the non-existence of referencesMichael Haggerty, Feb 25, 2016
  18. 17/20 delete_ref_loose(): derive loose reference path from lockMichael Haggerty, Feb 25, 2016
  19. 18/20 delete_ref_loose(): inline functionMichael Haggerty, Feb 25, 2016
  20. 19/20 try_remove_empty_parents(): teach to remove parents of reflogs, tooMichael Haggerty, Feb 25, 2016
  21. 20/20 ref_transaction_commit(): clean up empty directoriesMichael Haggerty, Feb 25, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.