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

[RFC/PATCH 1/7] sha1_file: make "read_object" static

From
Christian Couder <chriscool@tuxfamily.org>
Date
Jan 12, 2009, 17:42 UTC
Message-ID
<20090112184224.31342906.chriscool@tuxfamily.org>
This function is only used from "sha1_file.c".

And as we want to add a "replace_object" hook in "read_sha1_file", we must not let people bypass the hook using something other than "read_sha1_file".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 cache.h     |    3 ---
 sha1_file.c |    7 +++++--
 2 files changed, 5 insertions(+), 5 deletions(-)
	Here is a new patch series. This time the hook is in "read_sha1_file".
	There are still many things to do and to check after this, it's just a start.
	But I try to follow the advise we give to GSoC student so I release early
	and often :-)
diff --git a/cache.h b/cache.h
index 231c06d..8e1af26 100644
--- a/cache.h
+++ b/cache.h
@@ -631,9 +631,6 @@ extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsig
 extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
 extern int force_object_loose(const unsigned char *sha1, time_t mtime);
 
-/* just like read_sha1_file(), but non fatal in presence of bad objects */
-extern void *read_object(const unsigned char *sha1, enum object_type *type, unsigned long *size);
-
 /* global flag to enable extra checks when accessing packed objects */
 extern int do_check_packed_object_crc;
 
diff --git a/sha1_file.c b/sha1_file.c
index 52d1ead..f08493f 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1700,6 +1700,9 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
 	delta_base_cache_lru.prev = &ent->lru;
 }
 
+static void *read_object(const unsigned char *sha1, enum object_type *type,
+			 unsigned long *size);
+
 static void *unpack_delta_entry(struct packed_git *p,
 				struct pack_window **w_curs,
 				off_t curpos,
@@ -2130,8 +2133,8 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,
 	return 0;
 }
 
-void *read_object(const unsigned char *sha1, enum object_type *type,
-		  unsigned long *size)
+static void *read_object(const unsigned char *sha1, enum object_type *type,
+			 unsigned long *size)
 {
 	unsigned long mapsize;
 	void *map, *buf;
-- 
1.6.1.83.g16e5
Message 1 of 1 in “sha1_file: make "read_object" static”
  1. 1/7 sha1_file: make "read_object" staticChristian Couder, Jan 12, 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.