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

[1'/5] Mark blobs as parsed when they're actually parsed

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Apr 28, 2005, 05:58 UTC
Message-ID
<Pine.LNX.4.21.0504280155320.30848-100000@iabervon.org>
In-Reply-To
<Pine.LNX.4.21.0504280131400.30848-100000@iabervon.org>

This eliminates the special case for blobs versus other types of objects. Now the scheme is entirely regular and I won't introduce stupid bugs. (And fsck-cache doesn't have to do the do-nothing parse)

Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Index: blob.c
===================================================================
--- 89fdfd09b281fdf5071bc13a30ef683bd6851b61/blob.c  (mode:100644 sha1:3d99b93f020d84c5410c2b1056f2d7446b647d1e)
+++ bcb43fecd82fa6f851e266b7e3873973068d51f3/blob.c  (mode:100644 sha1:d4af4a309433744d2fe819886d66741ab016f62b)
@@ -14,10 +14,28 @@
 		ret->object.type = blob_type;
 		return ret;
 	}
-	if (obj->parsed && obj->type != blob_type) {
+	if (obj->type != blob_type) {
 		error("Object %s is a %s, not a blob", 
 		      sha1_to_hex(sha1), obj->type);
 		return NULL;
 	}
 	return (struct blob *) obj;
 }
+
+int parse_blob(struct blob *item)
+{
+        char type[20];
+        void *buffer;
+        unsigned long size;
+        if (item->object.parsed)
+                return 0;
+        item->object.parsed = 1;
+        buffer = read_sha1_file(item->object.sha1, type, &size);
+        if (!buffer)
+                return error("Could not read %s",
+                             sha1_to_hex(item->object.sha1));
+        if (strcmp(type, blob_type))
+                return error("Object %s not a blob",
+                             sha1_to_hex(item->object.sha1));
+	return 0;
+}
Index: blob.h
===================================================================
--- 89fdfd09b281fdf5071bc13a30ef683bd6851b61/blob.h  (mode:100644 sha1:5cbf6d65ee88e1e0c0f1153af4aa7f80c3c48c16)
+++ bcb43fecd82fa6f851e266b7e3873973068d51f3/blob.h  (mode:100644 sha1:4afad0f067e1979d7ccc4778e254cce6962ad136)
@@ -11,4 +11,6 @@
 
 struct blob *lookup_blob(unsigned char *sha1);
 
+int parse_blob(struct blob *item);
+
 #endif /* BLOB_H */
Previous: Daniel BarkalowNext: Daniel Barkalow
Message 5 of 10 in “[0/5] Updates for library, fsck-cache”
  1. Daniel BarkalowApr 28, 2005
  2. 1/5 Consider a blob to be parsedDaniel Barkalow, Apr 28, 2005
  3. Linus TorvaldsApr 28, 2005
  4. Daniel BarkalowApr 28, 2005
  5. [1'/5] Mark blobs as parsed when they're actually parsedDaniel Barkalow, Apr 28, 2005
  6. 2/5 Add tag header/parser to libraryDaniel Barkalow, Apr 28, 2005
  7. 3/5 Add function to parse an object of unspecified typeDaniel Barkalow, Apr 28, 2005
  8. [3'/5] Add function to parse an object of unspecified type (take 2)Daniel Barkalow, Apr 28, 2005
  9. 4/5 Rework fsck-cache to use parse_object()Daniel Barkalow, Apr 28, 2005
  10. 5/5 Make fsck-cache read heads out of .git/refs/*/*Daniel Barkalow, Apr 28, 2005

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.