@@ -37,6 +37,41 @@ const unsigned char null_sha1[20];
3737
3838static int git_open_noatime (const char * name , struct packed_git * p );
3939
40+ /*
41+ * This is meant to hold a *small* number of objects that you would
42+ * want read_sha1_file() to be able to return, but yet you do not want
43+ * to write them into the object store (e.g. a browse-only
44+ * application).
45+ */
46+ static struct cached_object {
47+ unsigned char sha1 [20 ];
48+ enum object_type type ;
49+ void * buf ;
50+ unsigned long size ;
51+ } * cached_objects ;
52+ static int cached_object_nr , cached_object_alloc ;
53+
54+ static struct cached_object empty_tree = {
55+ EMPTY_TREE_SHA1_BIN ,
56+ OBJ_TREE ,
57+ "" ,
58+ 0
59+ };
60+
61+ static struct cached_object * find_cached_object (const unsigned char * sha1 )
62+ {
63+ int i ;
64+ struct cached_object * co = cached_objects ;
65+
66+ for (i = 0 ; i < cached_object_nr ; i ++ , co ++ ) {
67+ if (!hashcmp (co -> sha1 , sha1 ))
68+ return co ;
69+ }
70+ if (!hashcmp (sha1 , empty_tree .sha1 ))
71+ return & empty_tree ;
72+ return NULL ;
73+ }
74+
4075int safe_create_leading_directories (char * path )
4176{
4277 char * pos = path + offset_1st_component (path );
@@ -2033,41 +2068,6 @@ static void *read_packed_sha1(const unsigned char *sha1,
20332068 return data ;
20342069}
20352070
2036- /*
2037- * This is meant to hold a *small* number of objects that you would
2038- * want read_sha1_file() to be able to return, but yet you do not want
2039- * to write them into the object store (e.g. a browse-only
2040- * application).
2041- */
2042- static struct cached_object {
2043- unsigned char sha1 [20 ];
2044- enum object_type type ;
2045- void * buf ;
2046- unsigned long size ;
2047- } * cached_objects ;
2048- static int cached_object_nr , cached_object_alloc ;
2049-
2050- static struct cached_object empty_tree = {
2051- EMPTY_TREE_SHA1_BIN ,
2052- OBJ_TREE ,
2053- "" ,
2054- 0
2055- };
2056-
2057- static struct cached_object * find_cached_object (const unsigned char * sha1 )
2058- {
2059- int i ;
2060- struct cached_object * co = cached_objects ;
2061-
2062- for (i = 0 ; i < cached_object_nr ; i ++ , co ++ ) {
2063- if (!hashcmp (co -> sha1 , sha1 ))
2064- return co ;
2065- }
2066- if (!hashcmp (sha1 , empty_tree .sha1 ))
2067- return & empty_tree ;
2068- return NULL ;
2069- }
2070-
20712071int pretend_sha1_file (void * buf , unsigned long len , enum object_type type ,
20722072 unsigned char * sha1 )
20732073{
0 commit comments