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

[PATCH 2/2] read-cache.c: use INDEX_FORMAT_{LB,UB} in verify_hdr()

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Feb 22, 2013, 12:09 UTC
Message-ID
<1361534964-4232-2-git-send-email-pclouds@gmail.com>
In-Reply-To
<1361534964-4232-1-git-send-email-pclouds@gmail.com>

9d22778 (read-cache.c: write prefix-compressed names in the index - 2012-04-04) defined these. Interestingly, they were not used by read-cache.c, or anywhere in that patch. They were used in builtin/update-index.c later for checking supported index versions. Use them here too.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/read-cache.c b/read-cache.c
index 827ae55..298161f 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1260,7 +1260,8 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
 	if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
 		return error("bad signature");
 	hdr_version = ntohl(hdr->hdr_version);
-	if (hdr_version < 2 || 4 < hdr_version)
+	if (hdr_version < INDEX_FORMAT_LB ||
+	    hdr_version > INDEX_FORMAT_UB)
 		return error("bad index version %d", hdr_version);
 	git_SHA1_Init(&c);
 	git_SHA1_Update(&c, hdr, size - 20);
-- 
1.8.1.2.536.gf441e6d
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 2 of 10 in “index-format.txt: mention of v4 is missing in some places”
  1. 1/2 index-format.txt: mention of v4 is missing in some placesNguyễn Thái Ngọc Duy, Feb 22, 2013
  2. 2/2 read-cache.c: use INDEX_FORMAT_{LB,UB} in verify_hdr()Nguyễn Thái Ngọc Duy, Feb 22, 2013
  3. Junio C HamanoFeb 22, 2013
  4. 3/2 update-index: list supported idx versions and their featuresNguyễn Thái Ngọc Duy, Feb 23, 2013
  5. Jonathan NiederFeb 23, 2013
  6. Junio C HamanoFeb 23, 2013
  7. Jonathan NiederFeb 23, 2013
  8. 3/2 update-index: list supported idx versions and their featuresNguyễn Thái Ngọc Duy, Feb 23, 2013
  9. Jonathan NiederFeb 23, 2013
  10. Junio C HamanoFeb 22, 2013

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.