@@ -44,9 +44,9 @@ static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr,
4444 memset (p -> parent , 0 ,
4545 sizeof (p -> parent [0 ]) * num_parent );
4646
47- hashcpy (p -> sha1 , q -> queue [i ]-> two -> sha1 );
47+ hashcpy (p -> oid . hash , q -> queue [i ]-> two -> sha1 );
4848 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 );
5050 p -> parent [n ].mode = q -> queue [i ]-> one -> mode ;
5151 p -> parent [n ].status = q -> queue [i ]-> status ;
5252 * tail = p ;
@@ -77,7 +77,7 @@ static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr,
7777 continue ;
7878 }
7979
80- hashcpy (p -> parent [n ].sha1 , q -> queue [i ]-> one -> sha1 );
80+ hashcpy (p -> parent [n ].oid . hash , q -> queue [i ]-> one -> sha1 );
8181 p -> parent [n ].mode = q -> queue [i ]-> one -> mode ;
8282 p -> parent [n ].status = q -> queue [i ]-> status ;
8383
@@ -284,7 +284,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
284284 return base ;
285285}
286286
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 ,
288288 unsigned long * size , struct userdiff_driver * textconv ,
289289 const char * path )
290290{
@@ -294,20 +294,20 @@ static char *grab_blob(const unsigned char *sha1, unsigned int mode,
294294 if (S_ISGITLINK (mode )) {
295295 blob = xmalloc (100 );
296296 * 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 )) {
299299 /* deleted blob */
300300 * size = 0 ;
301301 return xcalloc (1 , 1 );
302302 } else if (textconv ) {
303303 struct diff_filespec * df = alloc_filespec (path );
304- fill_filespec (df , sha1 , 1 , mode );
304+ fill_filespec (df , oid -> hash , 1 , mode );
305305 * size = fill_textconv (textconv , df , & blob );
306306 free_filespec (df );
307307 } else {
308- blob = read_sha1_file (sha1 , & type , size );
308+ blob = read_sha1_file (oid -> hash , & type , size );
309309 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 ));
311311 }
312312 return blob ;
313313}
@@ -389,7 +389,7 @@ static void consume_line(void *state_, char *line, unsigned long len)
389389 }
390390}
391391
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 ,
393393 mmfile_t * result_file ,
394394 struct sline * sline , unsigned int cnt , int n ,
395395 int num_parent , int result_deleted ,
@@ -897,7 +897,7 @@ static void show_combined_header(struct combine_diff_path *elem,
897897 int show_file_header )
898898{
899899 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 ;
901901 const char * a_prefix = opt -> a_prefix ? opt -> a_prefix : "a/" ;
902902 const char * b_prefix = opt -> b_prefix ? opt -> b_prefix : "b/" ;
903903 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,
914914 "" , elem -> path , line_prefix , c_meta , c_reset );
915915 printf ("%s%sindex " , line_prefix , c_meta );
916916 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 ,
918918 abbrev );
919919 printf ("%s%s" , i ? "," : "" , abb );
920920 }
921- abb = find_unique_abbrev (elem -> sha1 , abbrev );
921+ abb = find_unique_abbrev (elem -> oid . hash , abbrev );
922922 printf ("..%s%s\n" , abb , c_reset );
923923
924924 if (mode_differs ) {
@@ -991,7 +991,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
991991
992992 /* Read the result of merge first */
993993 if (!working_tree_file )
994- result = grab_blob (elem -> sha1 , elem -> mode , & result_size ,
994+ result = grab_blob (& elem -> oid , elem -> mode , & result_size ,
995995 textconv , elem -> path );
996996 else {
997997 /* 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,
10131013 result = strbuf_detach (& buf , NULL );
10141014 elem -> mode = canon_mode (st .st_mode );
10151015 } 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 ,
10191019 & result_size , NULL , NULL );
10201020 else
1021- result = grab_blob (sha1 , elem -> mode ,
1021+ result = grab_blob (& oid , elem -> mode ,
10221022 & result_size , NULL , NULL );
10231023 } else if (textconv ) {
10241024 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,
10901090 for (i = 0 ; !is_binary && i < num_parent ; i ++ ) {
10911091 char * buf ;
10921092 unsigned long size ;
1093- buf = grab_blob (elem -> parent [i ].sha1 ,
1093+ buf = grab_blob (& elem -> parent [i ].oid ,
10941094 elem -> parent [i ].mode ,
10951095 & size , NULL , NULL );
10961096 if (buffer_is_binary (buf , size ))
@@ -1139,14 +1139,14 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
11391139 for (i = 0 ; i < num_parent ; i ++ ) {
11401140 int j ;
11411141 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 )) {
11441144 reuse_combine_diff (sline , cnt , i , j );
11451145 break ;
11461146 }
11471147 }
11481148 if (i <= j )
1149- combine_diff (elem -> parent [i ].sha1 ,
1149+ combine_diff (& elem -> parent [i ].oid ,
11501150 elem -> parent [i ].mode ,
11511151 & result_file , sline ,
11521152 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
12061206
12071207 /* Show sha1's */
12081208 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 ,
12101210 opt -> abbrev ));
1211- printf (" %s " , diff_unique_abbrev (p -> sha1 , opt -> abbrev ));
1211+ printf (" %s " , diff_unique_abbrev (p -> oid . hash , opt -> abbrev ));
12121212 }
12131213
12141214 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,
12711271 for (i = 0 ; i < num_parent ; i ++ ) {
12721272 pair -> one [i ].path = p -> path ;
12731273 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 );
12761276 pair -> one [i ].has_more_entries = 1 ;
12771277 }
12781278 pair -> one [num_parent - 1 ].has_more_entries = 0 ;
12791279
12801280 pair -> two -> path = p -> path ;
12811281 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 );
12841284 return pair ;
12851285}
12861286
0 commit comments