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

[PATCH] fsck-objects: adjust to resolve_ref() clean-up.

From
Junio C Hamano <junkio@cox.net>
Date
Sep 18, 2006, 18:44 UTC
Message-ID
<7vac4xovzq.fsf@assigned-by-dhcp.cox.net>
Clean-up the same "ref to path and then back to ref" confusion.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 fsck-objects.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/fsck-objects.c b/fsck-objects.c
index 4d994f3..456c17e 100644
--- a/fsck-objects.c
+++ b/fsck-objects.c
@@ -458,15 +458,13 @@ static void fsck_object_dir(const char *
 static int fsck_head_link(void)
 {
 	unsigned char sha1[20];
-	const char *git_HEAD = xstrdup(git_path("HEAD"));
-	const char *git_refs_heads_master = resolve_ref(git_HEAD, sha1, 1);
-	int pfxlen = strlen(git_HEAD) - 4; /* strip .../.git/ part */
+	const char *head_points_at = resolve_ref("HEAD", sha1, 1);
 
-	if (!git_refs_heads_master)
+	if (!head_points_at)
 		return error("HEAD is not a symbolic ref");
-	if (strncmp(git_refs_heads_master + pfxlen, "refs/heads/", 11))
+	if (strncmp(head_points_at, "refs/heads/", 11))
 		return error("HEAD points to something strange (%s)",
-			     git_refs_heads_master + pfxlen);
+			     head_points_at);
 	if (is_null_sha1(sha1))
 		return error("HEAD: not a valid git pointer");
 	return 0;
-- 
1.4.2.1.g01ff
Message 1 of 1 in “fsck-objects: adjust to resolve_ref() clean-up.”
  1. fsck-objects: adjust to resolve_ref() clean-up.Junio C Hamano, Sep 18, 2006

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.