@@ -44,9 +44,9 @@ static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr,
44
44
memset (p -> parent , 0 ,
45
45
sizeof (p -> parent [0 ]) * num_parent );
46
46
47
- hashcpy (p -> sha1 , q -> queue [i ]-> two -> sha1 );
47
+ hashcpy (p -> oid . hash , q -> queue [i ]-> two -> sha1 );
48
48
p -> mode = q -> queue [i ]-> two -> mode ;
49
- hashcpy (p -> parent [n ].sha1 , q -> queue [i ]-> one -> sha1 );
49
+ hashcpy (p -> parent [n ].oid . hash , q -> queue [i ]-> one -> sha1 );
50
50
p -> parent [n ].mode = q -> queue [i ]-> one -> mode ;
51
51
p -> parent [n ].status = q -> queue [i ]-> status ;
52
52
* tail = p ;
@@ -77,7 +77,7 @@ static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr,
77
77
continue ;
78
78
}
79
79
80
- hashcpy (p -> parent [n ].sha1 , q -> queue [i ]-> one -> sha1 );
80
+ hashcpy (p -> parent [n ].oid . hash , q -> queue [i ]-> one -> sha1 );
81
81
p -> parent [n ].mode = q -> queue [i ]-> one -> mode ;
82
82
p -> parent [n ].status = q -> queue [i ]-> status ;
83
83
@@ -284,7 +284,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
284
284
return base ;
285
285
}
286
286
287
- static char * grab_blob (const unsigned char * sha1 , unsigned int mode ,
287
+ static char * grab_blob (const struct object_id * oid , unsigned int mode ,
288
288
unsigned long * size , struct userdiff_driver * textconv ,
289
289
const char * path )
290
290
{
@@ -294,20 +294,20 @@ static char *grab_blob(const unsigned char *sha1, unsigned int mode,
294
294
if (S_ISGITLINK (mode )) {
295
295
blob = xmalloc (100 );
296
296
* size = snprintf (blob , 100 ,
297
- "Subproject commit %s\n" , sha1_to_hex ( sha1 ));
298
- } else if (is_null_sha1 ( sha1 )) {
297
+ "Subproject commit %s\n" , oid_to_hex ( oid ));
298
+ } else if (is_null_oid ( oid )) {
299
299
/* deleted blob */
300
300
* size = 0 ;
301
301
return xcalloc (1 , 1 );
302
302
} else if (textconv ) {
303
303
struct diff_filespec * df = alloc_filespec (path );
304
- fill_filespec (df , sha1 , 1 , mode );
304
+ fill_filespec (df , oid -> hash , 1 , mode );
305
305
* size = fill_textconv (textconv , df , & blob );
306
306
free_filespec (df );
307
307
} else {
308
- blob = read_sha1_file (sha1 , & type , size );
308
+ blob = read_sha1_file (oid -> hash , & type , size );
309
309
if (type != OBJ_BLOB )
310
- die ("object '%s' is not a blob!" , sha1_to_hex ( sha1 ));
310
+ die ("object '%s' is not a blob!" , oid_to_hex ( oid ));
311
311
}
312
312
return blob ;
313
313
}
@@ -389,7 +389,7 @@ static void consume_line(void *state_, char *line, unsigned long len)
389
389
}
390
390
}
391
391
392
- static void combine_diff (const unsigned char * parent , unsigned int mode ,
392
+ static void combine_diff (const struct object_id * parent , unsigned int mode ,
393
393
mmfile_t * result_file ,
394
394
struct sline * sline , unsigned int cnt , int n ,
395
395
int num_parent , int result_deleted ,
@@ -897,7 +897,7 @@ static void show_combined_header(struct combine_diff_path *elem,
897
897
int show_file_header )
898
898
{
899
899
struct diff_options * opt = & rev -> diffopt ;
900
- int abbrev = DIFF_OPT_TST (opt , FULL_INDEX ) ? 40 : DEFAULT_ABBREV ;
900
+ int abbrev = DIFF_OPT_TST (opt , FULL_INDEX ) ? GIT_SHA1_HEXSZ : DEFAULT_ABBREV ;
901
901
const char * a_prefix = opt -> a_prefix ? opt -> a_prefix : "a/" ;
902
902
const char * b_prefix = opt -> b_prefix ? opt -> b_prefix : "b/" ;
903
903
const char * c_meta = diff_get_color_opt (opt , DIFF_METAINFO );
@@ -914,11 +914,11 @@ static void show_combined_header(struct combine_diff_path *elem,
914
914
"" , elem -> path , line_prefix , c_meta , c_reset );
915
915
printf ("%s%sindex " , line_prefix , c_meta );
916
916
for (i = 0 ; i < num_parent ; i ++ ) {
917
- abb = find_unique_abbrev (elem -> parent [i ].sha1 ,
917
+ abb = find_unique_abbrev (elem -> parent [i ].oid . hash ,
918
918
abbrev );
919
919
printf ("%s%s" , i ? "," : "" , abb );
920
920
}
921
- abb = find_unique_abbrev (elem -> sha1 , abbrev );
921
+ abb = find_unique_abbrev (elem -> oid . hash , abbrev );
922
922
printf ("..%s%s\n" , abb , c_reset );
923
923
924
924
if (mode_differs ) {
@@ -991,7 +991,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
991
991
992
992
/* Read the result of merge first */
993
993
if (!working_tree_file )
994
- result = grab_blob (elem -> sha1 , elem -> mode , & result_size ,
994
+ result = grab_blob (& elem -> oid , elem -> mode , & result_size ,
995
995
textconv , elem -> path );
996
996
else {
997
997
/* Used by diff-tree to read from the working tree */
@@ -1013,12 +1013,12 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
1013
1013
result = strbuf_detach (& buf , NULL );
1014
1014
elem -> mode = canon_mode (st .st_mode );
1015
1015
} else if (S_ISDIR (st .st_mode )) {
1016
- unsigned char sha1 [ 20 ] ;
1017
- if (resolve_gitlink_ref (elem -> path , "HEAD" , sha1 ) < 0 )
1018
- result = grab_blob (elem -> sha1 , elem -> mode ,
1016
+ struct object_id oid ;
1017
+ if (resolve_gitlink_ref (elem -> path , "HEAD" , oid . hash ) < 0 )
1018
+ result = grab_blob (& elem -> oid , elem -> mode ,
1019
1019
& result_size , NULL , NULL );
1020
1020
else
1021
- result = grab_blob (sha1 , elem -> mode ,
1021
+ result = grab_blob (& oid , elem -> mode ,
1022
1022
& result_size , NULL , NULL );
1023
1023
} else if (textconv ) {
1024
1024
struct diff_filespec * df = alloc_filespec (elem -> path );
@@ -1090,7 +1090,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
1090
1090
for (i = 0 ; !is_binary && i < num_parent ; i ++ ) {
1091
1091
char * buf ;
1092
1092
unsigned long size ;
1093
- buf = grab_blob (elem -> parent [i ].sha1 ,
1093
+ buf = grab_blob (& elem -> parent [i ].oid ,
1094
1094
elem -> parent [i ].mode ,
1095
1095
& size , NULL , NULL );
1096
1096
if (buffer_is_binary (buf , size ))
@@ -1139,14 +1139,14 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
1139
1139
for (i = 0 ; i < num_parent ; i ++ ) {
1140
1140
int j ;
1141
1141
for (j = 0 ; j < i ; j ++ ) {
1142
- if (!hashcmp ( elem -> parent [i ].sha1 ,
1143
- elem -> parent [j ].sha1 )) {
1142
+ if (!oidcmp ( & elem -> parent [i ].oid ,
1143
+ & elem -> parent [j ].oid )) {
1144
1144
reuse_combine_diff (sline , cnt , i , j );
1145
1145
break ;
1146
1146
}
1147
1147
}
1148
1148
if (i <= j )
1149
- combine_diff (elem -> parent [i ].sha1 ,
1149
+ combine_diff (& elem -> parent [i ].oid ,
1150
1150
elem -> parent [i ].mode ,
1151
1151
& result_file , sline ,
1152
1152
cnt , i , num_parent , result_deleted ,
@@ -1206,9 +1206,9 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
1206
1206
1207
1207
/* Show sha1's */
1208
1208
for (i = 0 ; i < num_parent ; i ++ )
1209
- printf (" %s" , diff_unique_abbrev (p -> parent [i ].sha1 ,
1209
+ printf (" %s" , diff_unique_abbrev (p -> parent [i ].oid . hash ,
1210
1210
opt -> abbrev ));
1211
- printf (" %s " , diff_unique_abbrev (p -> sha1 , opt -> abbrev ));
1211
+ printf (" %s " , diff_unique_abbrev (p -> oid . hash , opt -> abbrev ));
1212
1212
}
1213
1213
1214
1214
if (opt -> output_format & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS )) {
@@ -1271,16 +1271,16 @@ static struct diff_filepair *combined_pair(struct combine_diff_path *p,
1271
1271
for (i = 0 ; i < num_parent ; i ++ ) {
1272
1272
pair -> one [i ].path = p -> path ;
1273
1273
pair -> one [i ].mode = p -> parent [i ].mode ;
1274
- hashcpy (pair -> one [i ].sha1 , p -> parent [i ].sha1 );
1275
- pair -> one [i ].sha1_valid = !is_null_sha1 ( p -> parent [i ].sha1 );
1274
+ hashcpy (pair -> one [i ].sha1 , p -> parent [i ].oid . hash );
1275
+ pair -> one [i ].sha1_valid = !is_null_oid ( & p -> parent [i ].oid );
1276
1276
pair -> one [i ].has_more_entries = 1 ;
1277
1277
}
1278
1278
pair -> one [num_parent - 1 ].has_more_entries = 0 ;
1279
1279
1280
1280
pair -> two -> path = p -> path ;
1281
1281
pair -> two -> mode = p -> mode ;
1282
- hashcpy (pair -> two -> sha1 , p -> sha1 );
1283
- pair -> two -> sha1_valid = !is_null_sha1 ( p -> sha1 );
1282
+ hashcpy (pair -> two -> sha1 , p -> oid . hash );
1283
+ pair -> two -> sha1_valid = !is_null_oid ( & p -> oid );
1284
1284
return pair ;
1285
1285
}
1286
1286
0 commit comments