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

[PATCH 6/6] Read an object from a pack file

From
HCHervé Cauwelier <herve@itaapy.com>
Date
Oct 3, 2009, 18:10 UTC
Message-ID
<1254593401-18801-7-git-send-email-herve@itaapy.com>
In-Reply-To
<1254593401-18801-6-git-send-email-herve@itaapy.com>
Signed-off-by: Hervé Cauwelier <herve@itaapy.com>
---
 src/odb.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/odb.c b/src/odb.c
index dd3c142..a712d71 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1263,13 +1263,16 @@ static int read_packed(git_obj *out, git_pack *p, const git_oid *id)
 
 	if (pack_openidx(p))
 		return GIT_ERROR;
+	if (pack_openpack(p)) {
+		pack_decidx(p);
+		return GIT_ERROR;
+	}
 	res = p->idx_search(&pos, p, id);
 	pack_decidx(p);
+	assert(pos < p->pack_map.len);
 
-	if (!res) {
-		/* TODO unpack object at pos */
-		res = GIT_ERROR;
-	}
+	if (res == GIT_SUCCESS)
+		return inflate_pack_obj(out, p, pos);
 
 	return res;
 }
-- 
1.6.4.4
Previous: Hervé CauwelierNext: Shawn O. Pearce
Message 7 of 8 in “Patches for libgit2”
  1. Hervé CauwelierOct 3, 2009
  2. 1/6 Open the pack file and keep a map on it.Hervé Cauwelier, Oct 3, 2009
  3. 2/6 Read the base offset or name of delta objectsHervé Cauwelier, Oct 3, 2009
  4. 3/6 Allow zlib to read a pack buffer longer than the actual dataHervé Cauwelier, Oct 3, 2009
  5. 4/6 Inflate an object from a pack fileHervé Cauwelier, Oct 3, 2009
  6. 5/6 This assertion is valid for both loose and packed objectsHervé Cauwelier, Oct 3, 2009
  7. 6/6 Read an object from a pack fileHervé Cauwelier, Oct 3, 2009
  8. Shawn O. PearceOct 5, 2009

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.