@@ -231,12 +231,10 @@ int within_depth(const char *name, int namelen,
231
231
* 1 along with { data, size } of the (possibly augmented) buffer
232
232
* when successful.
233
233
*
234
- * Optionally updates the given sha1_stat with the given OID (when valid).
234
+ * Optionally updates the given oid_stat with the given OID (when valid).
235
235
*/
236
- static int do_read_blob (const struct object_id * oid ,
237
- struct sha1_stat * sha1_stat ,
238
- size_t * size_out ,
239
- char * * data_out )
236
+ static int do_read_blob (const struct object_id * oid , struct oid_stat * oid_stat ,
237
+ size_t * size_out , char * * data_out )
240
238
{
241
239
enum object_type type ;
242
240
unsigned long sz ;
@@ -251,9 +249,9 @@ static int do_read_blob(const struct object_id *oid,
251
249
return -1 ;
252
250
}
253
251
254
- if (sha1_stat ) {
255
- memset (& sha1_stat -> stat , 0 , sizeof (sha1_stat -> stat ));
256
- hashcpy ( sha1_stat -> sha1 , oid -> hash );
252
+ if (oid_stat ) {
253
+ memset (& oid_stat -> stat , 0 , sizeof (oid_stat -> stat ));
254
+ oidcpy ( & oid_stat -> oid , oid );
257
255
}
258
256
259
257
if (sz == 0 ) {
@@ -654,9 +652,8 @@ void add_exclude(const char *string, const char *base,
654
652
655
653
static int read_skip_worktree_file_from_index (const struct index_state * istate ,
656
654
const char * path ,
657
- size_t * size_out ,
658
- char * * data_out ,
659
- struct sha1_stat * sha1_stat )
655
+ size_t * size_out , char * * data_out ,
656
+ struct oid_stat * oid_stat )
660
657
{
661
658
int pos , len ;
662
659
@@ -667,7 +664,7 @@ static int read_skip_worktree_file_from_index(const struct index_state *istate,
667
664
if (!ce_skip_worktree (istate -> cache [pos ]))
668
665
return -1 ;
669
666
670
- return do_read_blob (& istate -> cache [pos ]-> oid , sha1_stat , size_out , data_out );
667
+ return do_read_blob (& istate -> cache [pos ]-> oid , oid_stat , size_out , data_out );
671
668
}
672
669
673
670
/*
@@ -795,9 +792,8 @@ static int add_excludes_from_buffer(char *buf, size_t size,
795
792
* ss_valid is non-zero, "ss" must contain good value as input.
796
793
*/
797
794
static int add_excludes (const char * fname , const char * base , int baselen ,
798
- struct exclude_list * el ,
799
- struct index_state * istate ,
800
- struct sha1_stat * sha1_stat )
795
+ struct exclude_list * el , struct index_state * istate ,
796
+ struct oid_stat * oid_stat )
801
797
{
802
798
struct stat st ;
803
799
int r ;
@@ -815,16 +811,16 @@ static int add_excludes(const char *fname, const char *base, int baselen,
815
811
return -1 ;
816
812
r = read_skip_worktree_file_from_index (istate , fname ,
817
813
& size , & buf ,
818
- sha1_stat );
814
+ oid_stat );
819
815
if (r != 1 )
820
816
return r ;
821
817
} else {
822
818
size = xsize_t (st .st_size );
823
819
if (size == 0 ) {
824
- if (sha1_stat ) {
825
- fill_stat_data (& sha1_stat -> stat , & st );
826
- hashcpy ( sha1_stat -> sha1 , EMPTY_BLOB_SHA1_BIN );
827
- sha1_stat -> valid = 1 ;
820
+ if (oid_stat ) {
821
+ fill_stat_data (& oid_stat -> stat , & st );
822
+ oidcpy ( & oid_stat -> oid , & empty_blob_oid );
823
+ oid_stat -> valid = 1 ;
828
824
}
829
825
close (fd );
830
826
return 0 ;
@@ -837,22 +833,23 @@ static int add_excludes(const char *fname, const char *base, int baselen,
837
833
}
838
834
buf [size ++ ] = '\n' ;
839
835
close (fd );
840
- if (sha1_stat ) {
836
+ if (oid_stat ) {
841
837
int pos ;
842
- if (sha1_stat -> valid &&
843
- !match_stat_data_racy (istate , & sha1_stat -> stat , & st ))
838
+ if (oid_stat -> valid &&
839
+ !match_stat_data_racy (istate , & oid_stat -> stat , & st ))
844
840
; /* no content change, ss->sha1 still good */
845
841
else if (istate &&
846
842
(pos = index_name_pos (istate , fname , strlen (fname ))) >= 0 &&
847
843
!ce_stage (istate -> cache [pos ]) &&
848
844
ce_uptodate (istate -> cache [pos ]) &&
849
845
!would_convert_to_git (istate , fname ))
850
- hashcpy ( sha1_stat -> sha1 ,
851
- istate -> cache [pos ]-> oid . hash );
846
+ oidcpy ( & oid_stat -> oid ,
847
+ & istate -> cache [pos ]-> oid );
852
848
else
853
- hash_sha1_file (buf , size , "blob" , sha1_stat -> sha1 );
854
- fill_stat_data (& sha1_stat -> stat , & st );
855
- sha1_stat -> valid = 1 ;
849
+ hash_sha1_file (buf , size , "blob" ,
850
+ oid_stat -> oid .hash );
851
+ fill_stat_data (& oid_stat -> stat , & st );
852
+ oid_stat -> valid = 1 ;
856
853
}
857
854
}
858
855
@@ -930,7 +927,7 @@ struct exclude_list *add_exclude_list(struct dir_struct *dir,
930
927
* Used to set up core.excludesfile and .git/info/exclude lists.
931
928
*/
932
929
static void add_excludes_from_file_1 (struct dir_struct * dir , const char * fname ,
933
- struct sha1_stat * sha1_stat )
930
+ struct oid_stat * oid_stat )
934
931
{
935
932
struct exclude_list * el ;
936
933
/*
@@ -941,7 +938,7 @@ static void add_excludes_from_file_1(struct dir_struct *dir, const char *fname,
941
938
if (!dir -> untracked )
942
939
dir -> unmanaged_exclude_files ++ ;
943
940
el = add_exclude_list (dir , EXC_FILE , fname );
944
- if (add_excludes (fname , "" , 0 , el , NULL , sha1_stat ) < 0 )
941
+ if (add_excludes (fname , "" , 0 , el , NULL , oid_stat ) < 0 )
945
942
die ("cannot use %s as an exclude file" , fname );
946
943
}
947
944
@@ -1180,7 +1177,7 @@ static void prep_exclude(struct dir_struct *dir,
1180
1177
1181
1178
while (current < baselen ) {
1182
1179
const char * cp ;
1183
- struct sha1_stat sha1_stat ;
1180
+ struct oid_stat oid_stat ;
1184
1181
1185
1182
stk = xcalloc (1 , sizeof (* stk ));
1186
1183
if (current < 0 ) {
@@ -1223,8 +1220,8 @@ static void prep_exclude(struct dir_struct *dir,
1223
1220
}
1224
1221
1225
1222
/* Try to read per-directory file */
1226
- hashclr ( sha1_stat . sha1 );
1227
- sha1_stat .valid = 0 ;
1223
+ oidclr ( & oid_stat . oid );
1224
+ oid_stat .valid = 0 ;
1228
1225
if (dir -> exclude_per_dir &&
1229
1226
/*
1230
1227
* If we know that no files have been added in
@@ -1252,7 +1249,7 @@ static void prep_exclude(struct dir_struct *dir,
1252
1249
strbuf_addstr (& sb , dir -> exclude_per_dir );
1253
1250
el -> src = strbuf_detach (& sb , NULL );
1254
1251
add_excludes (el -> src , el -> src , stk -> baselen , el , istate ,
1255
- untracked ? & sha1_stat : NULL );
1252
+ untracked ? & oid_stat : NULL );
1256
1253
}
1257
1254
/*
1258
1255
* NEEDSWORK: when untracked cache is enabled, prep_exclude()
@@ -1269,9 +1266,9 @@ static void prep_exclude(struct dir_struct *dir,
1269
1266
* order, though, if you do that.
1270
1267
*/
1271
1268
if (untracked &&
1272
- hashcmp (sha1_stat . sha1 , untracked -> exclude_sha1 )) {
1269
+ hashcmp (oid_stat . oid . hash , untracked -> exclude_sha1 )) {
1273
1270
invalidate_gitignore (dir -> untracked , untracked );
1274
- hashcpy (untracked -> exclude_sha1 , sha1_stat . sha1 );
1271
+ hashcpy (untracked -> exclude_sha1 , oid_stat . oid . hash );
1275
1272
}
1276
1273
dir -> exclude_stack = stk ;
1277
1274
current = stk -> baselen ;
@@ -2228,13 +2225,13 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
2228
2225
2229
2226
/* Validate $GIT_DIR/info/exclude and core.excludesfile */
2230
2227
root = dir -> untracked -> root ;
2231
- if (hashcmp ( dir -> ss_info_exclude .sha1 ,
2232
- dir -> untracked -> ss_info_exclude .sha1 )) {
2228
+ if (oidcmp ( & dir -> ss_info_exclude .oid ,
2229
+ & dir -> untracked -> ss_info_exclude .oid )) {
2233
2230
invalidate_gitignore (dir -> untracked , root );
2234
2231
dir -> untracked -> ss_info_exclude = dir -> ss_info_exclude ;
2235
2232
}
2236
- if (hashcmp ( dir -> ss_excludes_file .sha1 ,
2237
- dir -> untracked -> ss_excludes_file .sha1 )) {
2233
+ if (oidcmp ( & dir -> ss_excludes_file .oid ,
2234
+ & dir -> untracked -> ss_excludes_file .oid )) {
2238
2235
invalidate_gitignore (dir -> untracked , root );
2239
2236
dir -> untracked -> ss_excludes_file = dir -> ss_excludes_file ;
2240
2237
}
@@ -2638,8 +2635,8 @@ void write_untracked_extension(struct strbuf *out, struct untracked_cache *untra
2638
2635
FLEX_ALLOC_MEM (ouc , exclude_per_dir , untracked -> exclude_per_dir , len );
2639
2636
stat_data_to_disk (& ouc -> info_exclude_stat , & untracked -> ss_info_exclude .stat );
2640
2637
stat_data_to_disk (& ouc -> excludes_file_stat , & untracked -> ss_excludes_file .stat );
2641
- hashcpy (ouc -> info_exclude_sha1 , untracked -> ss_info_exclude .sha1 );
2642
- hashcpy (ouc -> excludes_file_sha1 , untracked -> ss_excludes_file .sha1 );
2638
+ hashcpy (ouc -> info_exclude_sha1 , untracked -> ss_info_exclude .oid . hash );
2639
+ hashcpy (ouc -> excludes_file_sha1 , untracked -> ss_excludes_file .oid . hash );
2643
2640
ouc -> dir_flags = htonl (untracked -> dir_flags );
2644
2641
2645
2642
varint_len = encode_varint (untracked -> ident .len , varbuf );
@@ -2816,13 +2813,12 @@ static void read_sha1(size_t pos, void *cb)
2816
2813
rd -> data += 20 ;
2817
2814
}
2818
2815
2819
- static void load_sha1_stat (struct sha1_stat * sha1_stat ,
2820
- const unsigned char * data ,
2821
- const unsigned char * sha1 )
2816
+ static void load_oid_stat (struct oid_stat * oid_stat , const unsigned char * data ,
2817
+ const unsigned char * sha1 )
2822
2818
{
2823
- stat_data_from_disk (& sha1_stat -> stat , data );
2824
- hashcpy (sha1_stat -> sha1 , sha1 );
2825
- sha1_stat -> valid = 1 ;
2819
+ stat_data_from_disk (& oid_stat -> stat , data );
2820
+ hashcpy (oid_stat -> oid . hash , sha1 );
2821
+ oid_stat -> valid = 1 ;
2826
2822
}
2827
2823
2828
2824
struct untracked_cache * read_untracked_extension (const void * data , unsigned long sz )
@@ -2850,12 +2846,12 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
2850
2846
uc = xcalloc (1 , sizeof (* uc ));
2851
2847
strbuf_init (& uc -> ident , ident_len );
2852
2848
strbuf_add (& uc -> ident , ident , ident_len );
2853
- load_sha1_stat (& uc -> ss_info_exclude ,
2854
- next + ouc_offset (info_exclude_stat ),
2855
- next + ouc_offset (info_exclude_sha1 ));
2856
- load_sha1_stat (& uc -> ss_excludes_file ,
2857
- next + ouc_offset (excludes_file_stat ),
2858
- next + ouc_offset (excludes_file_sha1 ));
2849
+ load_oid_stat (& uc -> ss_info_exclude ,
2850
+ next + ouc_offset (info_exclude_stat ),
2851
+ next + ouc_offset (info_exclude_sha1 ));
2852
+ load_oid_stat (& uc -> ss_excludes_file ,
2853
+ next + ouc_offset (excludes_file_stat ),
2854
+ next + ouc_offset (excludes_file_sha1 ));
2859
2855
uc -> dir_flags = get_be32 (next + ouc_offset (dir_flags ));
2860
2856
exclude_per_dir = (const char * )next + ouc_offset (exclude_per_dir );
2861
2857
uc -> exclude_per_dir = xstrdup (exclude_per_dir );
0 commit comments