@@ -1813,7 +1813,8 @@ static void check_tag(const void *buf, size_t size)
18131813 die (_ ("corrupt tag" ));
18141814}
18151815
1816- static int index_mem (struct object_id * oid , void * buf , size_t size ,
1816+ static int index_mem (struct index_state * istate ,
1817+ struct object_id * oid , void * buf , size_t size ,
18171818 enum object_type type ,
18181819 const char * path , unsigned flags )
18191820{
@@ -1828,7 +1829,7 @@ static int index_mem(struct object_id *oid, void *buf, size_t size,
18281829 */
18291830 if ((type == OBJ_BLOB ) && path ) {
18301831 struct strbuf nbuf = STRBUF_INIT ;
1831- if (convert_to_git (& the_index , path , buf , size , & nbuf ,
1832+ if (convert_to_git (istate , path , buf , size , & nbuf ,
18321833 get_conv_flags (flags ))) {
18331834 buf = strbuf_detach (& nbuf , & size );
18341835 re_allocated = 1 ;
@@ -1852,17 +1853,20 @@ static int index_mem(struct object_id *oid, void *buf, size_t size,
18521853 return ret ;
18531854}
18541855
1855- static int index_stream_convert_blob (struct object_id * oid , int fd ,
1856- const char * path , unsigned flags )
1856+ static int index_stream_convert_blob (struct index_state * istate ,
1857+ struct object_id * oid ,
1858+ int fd ,
1859+ const char * path ,
1860+ unsigned flags )
18571861{
18581862 int ret ;
18591863 const int write_object = flags & HASH_WRITE_OBJECT ;
18601864 struct strbuf sbuf = STRBUF_INIT ;
18611865
18621866 assert (path );
1863- assert (would_convert_to_git_filter_fd (& the_index , path ));
1867+ assert (would_convert_to_git_filter_fd (istate , path ));
18641868
1865- convert_to_git_filter_fd (& the_index , path , fd , & sbuf ,
1869+ convert_to_git_filter_fd (istate , path , fd , & sbuf ,
18661870 get_conv_flags (flags ));
18671871
18681872 if (write_object )
@@ -1875,14 +1879,15 @@ static int index_stream_convert_blob(struct object_id *oid, int fd,
18751879 return ret ;
18761880}
18771881
1878- static int index_pipe (struct object_id * oid , int fd , enum object_type type ,
1882+ static int index_pipe (struct index_state * istate , struct object_id * oid ,
1883+ int fd , enum object_type type ,
18791884 const char * path , unsigned flags )
18801885{
18811886 struct strbuf sbuf = STRBUF_INIT ;
18821887 int ret ;
18831888
18841889 if (strbuf_read (& sbuf , fd , 4096 ) >= 0 )
1885- ret = index_mem (oid , sbuf .buf , sbuf .len , type , path , flags );
1890+ ret = index_mem (istate , oid , sbuf .buf , sbuf .len , type , path , flags );
18861891 else
18871892 ret = -1 ;
18881893 strbuf_release (& sbuf );
@@ -1891,14 +1896,15 @@ static int index_pipe(struct object_id *oid, int fd, enum object_type type,
18911896
18921897#define SMALL_FILE_SIZE (32*1024)
18931898
1894- static int index_core (struct object_id * oid , int fd , size_t size ,
1899+ static int index_core (struct index_state * istate ,
1900+ struct object_id * oid , int fd , size_t size ,
18951901 enum object_type type , const char * path ,
18961902 unsigned flags )
18971903{
18981904 int ret ;
18991905
19001906 if (!size ) {
1901- ret = index_mem (oid , "" , size , type , path , flags );
1907+ ret = index_mem (istate , oid , "" , size , type , path , flags );
19021908 } else if (size <= SMALL_FILE_SIZE ) {
19031909 char * buf = xmalloc (size );
19041910 ssize_t read_result = read_in_full (fd , buf , size );
@@ -1909,11 +1915,11 @@ static int index_core(struct object_id *oid, int fd, size_t size,
19091915 ret = error (_ ("short read while indexing %s" ),
19101916 path ? path : "<unknown>" );
19111917 else
1912- ret = index_mem (oid , buf , size , type , path , flags );
1918+ ret = index_mem (istate , oid , buf , size , type , path , flags );
19131919 free (buf );
19141920 } else {
19151921 void * buf = xmmap (NULL , size , PROT_READ , MAP_PRIVATE , fd , 0 );
1916- ret = index_mem (oid , buf , size , type , path , flags );
1922+ ret = index_mem (istate , oid , buf , size , type , path , flags );
19171923 munmap (buf , size );
19181924 }
19191925 return ret ;
@@ -1941,7 +1947,8 @@ static int index_stream(struct object_id *oid, int fd, size_t size,
19411947 return index_bulk_checkin (oid , fd , size , type , path , flags );
19421948}
19431949
1944- int index_fd (struct object_id * oid , int fd , struct stat * st ,
1950+ int index_fd (struct index_state * istate , struct object_id * oid ,
1951+ int fd , struct stat * st ,
19451952 enum object_type type , const char * path , unsigned flags )
19461953{
19471954 int ret ;
@@ -1950,22 +1957,23 @@ int index_fd(struct object_id *oid, int fd, struct stat *st,
19501957 * Call xsize_t() only when needed to avoid potentially unnecessary
19511958 * die() for large files.
19521959 */
1953- if (type == OBJ_BLOB && path && would_convert_to_git_filter_fd (& the_index , path ))
1954- ret = index_stream_convert_blob (oid , fd , path , flags );
1960+ if (type == OBJ_BLOB && path && would_convert_to_git_filter_fd (istate , path ))
1961+ ret = index_stream_convert_blob (istate , oid , fd , path , flags );
19551962 else if (!S_ISREG (st -> st_mode ))
1956- ret = index_pipe (oid , fd , type , path , flags );
1963+ ret = index_pipe (istate , oid , fd , type , path , flags );
19571964 else if (st -> st_size <= big_file_threshold || type != OBJ_BLOB ||
1958- (path && would_convert_to_git (& the_index , path )))
1959- ret = index_core (oid , fd , xsize_t (st -> st_size ), type , path ,
1960- flags );
1965+ (path && would_convert_to_git (istate , path )))
1966+ ret = index_core (istate , oid , fd , xsize_t (st -> st_size ),
1967+ type , path , flags );
19611968 else
19621969 ret = index_stream (oid , fd , xsize_t (st -> st_size ), type , path ,
19631970 flags );
19641971 close (fd );
19651972 return ret ;
19661973}
19671974
1968- int index_path (struct object_id * oid , const char * path , struct stat * st , unsigned flags )
1975+ int index_path (struct index_state * istate , struct object_id * oid ,
1976+ const char * path , struct stat * st , unsigned flags )
19691977{
19701978 int fd ;
19711979 struct strbuf sb = STRBUF_INIT ;
@@ -1976,7 +1984,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
19761984 fd = open (path , O_RDONLY );
19771985 if (fd < 0 )
19781986 return error_errno ("open(\"%s\")" , path );
1979- if (index_fd (oid , fd , st , OBJ_BLOB , path , flags ) < 0 )
1987+ if (index_fd (istate , oid , fd , st , OBJ_BLOB , path , flags ) < 0 )
19801988 return error (_ ("%s: failed to insert into database" ),
19811989 path );
19821990 break ;
0 commit comments