@@ -1934,7 +1934,7 @@ static void show_dirstat(struct diff_options *options)
19341934 name = p -> two -> path ? p -> two -> path : p -> one -> path ;
19351935
19361936 if (p -> one -> sha1_valid && p -> two -> sha1_valid )
1937- content_changed = hashcmp ( p -> one -> sha1 , p -> two -> sha1 );
1937+ content_changed = oidcmp ( & p -> one -> oid , & p -> two -> oid );
19381938 else
19391939 content_changed = 1 ;
19401940
@@ -2306,7 +2306,8 @@ static void builtin_diff(const char *name_a,
23062306 const char * add = diff_get_color_opt (o , DIFF_FILE_NEW );
23072307 show_submodule_summary (o -> file , one -> path ? one -> path : two -> path ,
23082308 line_prefix ,
2309- one -> sha1 , two -> sha1 , two -> dirty_submodule ,
2309+ one -> oid .hash , two -> oid .hash ,
2310+ two -> dirty_submodule ,
23102311 meta , del , add , reset );
23112312 return ;
23122313 }
@@ -2384,7 +2385,7 @@ static void builtin_diff(const char *name_a,
23842385 if (!one -> data && !two -> data &&
23852386 S_ISREG (one -> mode ) && S_ISREG (two -> mode ) &&
23862387 !DIFF_OPT_TST (o , BINARY )) {
2387- if (!hashcmp ( one -> sha1 , two -> sha1 )) {
2388+ if (!oidcmp ( & one -> oid , & two -> oid )) {
23882389 if (must_show_header )
23892390 fprintf (o -> file , "%s" , header .buf );
23902391 goto free_ab_and_return ;
@@ -2505,7 +2506,7 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
25052506 return ;
25062507 }
25072508
2508- same_contents = !hashcmp ( one -> sha1 , two -> sha1 );
2509+ same_contents = !oidcmp ( & one -> oid , & two -> oid );
25092510
25102511 if (diff_filespec_is_binary (one ) || diff_filespec_is_binary (two )) {
25112512 data -> is_binary = 1 ;
@@ -2638,7 +2639,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
26382639{
26392640 if (mode ) {
26402641 spec -> mode = canon_mode (mode );
2641- hashcpy (spec -> sha1 , sha1 );
2642+ hashcpy (spec -> oid . hash , sha1 );
26422643 spec -> sha1_valid = sha1_valid ;
26432644 }
26442645}
@@ -2721,7 +2722,8 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
27212722 if (s -> dirty_submodule )
27222723 dirty = "-dirty" ;
27232724
2724- strbuf_addf (& buf , "Subproject commit %s%s\n" , sha1_to_hex (s -> sha1 ), dirty );
2725+ strbuf_addf (& buf , "Subproject commit %s%s\n" ,
2726+ oid_to_hex (& s -> oid ), dirty );
27252727 s -> size = buf .len ;
27262728 if (size_only ) {
27272729 s -> data = NULL ;
@@ -2765,7 +2767,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
27652767 return diff_populate_gitlink (s , size_only );
27662768
27672769 if (!s -> sha1_valid ||
2768- reuse_worktree_file (s -> path , s -> sha1 , 0 )) {
2770+ reuse_worktree_file (s -> path , s -> oid . hash , 0 )) {
27692771 struct strbuf buf = STRBUF_INIT ;
27702772 struct stat st ;
27712773 int fd ;
@@ -2822,19 +2824,20 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
28222824 else {
28232825 enum object_type type ;
28242826 if (size_only || (flags & CHECK_BINARY )) {
2825- type = sha1_object_info (s -> sha1 , & s -> size );
2827+ type = sha1_object_info (s -> oid . hash , & s -> size );
28262828 if (type < 0 )
2827- die ("unable to read %s" , sha1_to_hex (s -> sha1 ));
2829+ die ("unable to read %s" ,
2830+ oid_to_hex (& s -> oid ));
28282831 if (size_only )
28292832 return 0 ;
28302833 if (s -> size > big_file_threshold && s -> is_binary == -1 ) {
28312834 s -> is_binary = 1 ;
28322835 return 0 ;
28332836 }
28342837 }
2835- s -> data = read_sha1_file (s -> sha1 , & type , & s -> size );
2838+ s -> data = read_sha1_file (s -> oid . hash , & type , & s -> size );
28362839 if (!s -> data )
2837- die ("unable to read %s" , sha1_to_hex ( s -> sha1 ));
2840+ die ("unable to read %s" , oid_to_hex ( & s -> oid ));
28382841 s -> should_free = 1 ;
28392842 }
28402843 return 0 ;
@@ -2913,7 +2916,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
29132916
29142917 if (!S_ISGITLINK (one -> mode ) &&
29152918 (!one -> sha1_valid ||
2916- reuse_worktree_file (name , one -> sha1 , 1 ))) {
2919+ reuse_worktree_file (name , one -> oid . hash , 1 ))) {
29172920 struct stat st ;
29182921 if (lstat (name , & st ) < 0 ) {
29192922 if (errno == ENOENT )
@@ -2926,7 +2929,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
29262929 die_errno ("readlink(%s)" , name );
29272930 prep_temp_blob (name , temp , sb .buf , sb .len ,
29282931 (one -> sha1_valid ?
2929- one -> sha1 : null_sha1 ),
2932+ one -> oid . hash : null_sha1 ),
29302933 (one -> sha1_valid ?
29312934 one -> mode : S_IFLNK ));
29322935 strbuf_release (& sb );
@@ -2937,7 +2940,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
29372940 if (!one -> sha1_valid )
29382941 sha1_to_hex_r (temp -> hex , null_sha1 );
29392942 else
2940- sha1_to_hex_r (temp -> hex , one -> sha1 );
2943+ sha1_to_hex_r (temp -> hex , one -> oid . hash );
29412944 /* Even though we may sometimes borrow the
29422945 * contents from the work tree, we always want
29432946 * one->mode. mode is trustworthy even when
@@ -2952,7 +2955,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
29522955 if (diff_populate_filespec (one , 0 ))
29532956 die ("cannot read data blob for %s" , one -> path );
29542957 prep_temp_blob (name , temp , one -> data , one -> size ,
2955- one -> sha1 , one -> mode );
2958+ one -> oid . hash , one -> mode );
29562959 }
29572960 return temp ;
29582961}
@@ -3065,7 +3068,7 @@ static void fill_metainfo(struct strbuf *msg,
30653068 default :
30663069 * must_show_header = 0 ;
30673070 }
3068- if (one && two && hashcmp ( one -> sha1 , two -> sha1 )) {
3071+ if (one && two && oidcmp ( & one -> oid , & two -> oid )) {
30693072 int abbrev = DIFF_OPT_TST (o , FULL_INDEX ) ? 40 : DEFAULT_ABBREV ;
30703073
30713074 if (DIFF_OPT_TST (o , BINARY )) {
@@ -3075,8 +3078,8 @@ static void fill_metainfo(struct strbuf *msg,
30753078 abbrev = 40 ;
30763079 }
30773080 strbuf_addf (msg , "%s%sindex %s.." , line_prefix , set ,
3078- find_unique_abbrev (one -> sha1 , abbrev ));
3079- strbuf_addstr (msg , find_unique_abbrev (two -> sha1 , abbrev ));
3081+ find_unique_abbrev (one -> oid . hash , abbrev ));
3082+ strbuf_addstr (msg , find_unique_abbrev (two -> oid . hash , abbrev ));
30803083 if (one -> mode == two -> mode )
30813084 strbuf_addf (msg , " %06o" , one -> mode );
30823085 strbuf_addf (msg , "%s\n" , reset );
@@ -3134,17 +3137,17 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
31343137 if (!one -> sha1_valid ) {
31353138 struct stat st ;
31363139 if (one -> is_stdin ) {
3137- hashclr ( one -> sha1 );
3140+ oidclr ( & one -> oid );
31383141 return ;
31393142 }
31403143 if (lstat (one -> path , & st ) < 0 )
31413144 die_errno ("stat '%s'" , one -> path );
3142- if (index_path (one -> sha1 , one -> path , & st , 0 ))
3145+ if (index_path (one -> oid . hash , one -> path , & st , 0 ))
31433146 die ("cannot hash %s" , one -> path );
31443147 }
31453148 }
31463149 else
3147- hashclr ( one -> sha1 );
3150+ oidclr ( & one -> oid );
31483151}
31493152
31503153static void strip_prefix (int prefix_length , const char * * namep , const char * * otherp )
@@ -4118,8 +4121,9 @@ static void diff_flush_raw(struct diff_filepair *p, struct diff_options *opt)
41184121 fprintf (opt -> file , "%s" , diff_line_prefix (opt ));
41194122 if (!(opt -> output_format & DIFF_FORMAT_NAME_STATUS )) {
41204123 fprintf (opt -> file , ":%06o %06o %s " , p -> one -> mode , p -> two -> mode ,
4121- diff_unique_abbrev (p -> one -> sha1 , opt -> abbrev ));
4122- fprintf (opt -> file , "%s " , diff_unique_abbrev (p -> two -> sha1 , opt -> abbrev ));
4124+ diff_unique_abbrev (p -> one -> oid .hash , opt -> abbrev ));
4125+ fprintf (opt -> file , "%s " ,
4126+ diff_unique_abbrev (p -> two -> oid .hash , opt -> abbrev ));
41234127 }
41244128 if (p -> score ) {
41254129 fprintf (opt -> file , "%c%03d%c" , p -> status , similarity_index (p ),
@@ -4169,7 +4173,7 @@ int diff_unmodified_pair(struct diff_filepair *p)
41694173 * dealing with a change.
41704174 */
41714175 if (one -> sha1_valid && two -> sha1_valid &&
4172- !hashcmp ( one -> sha1 , two -> sha1 ) &&
4176+ !oidcmp ( & one -> oid , & two -> oid ) &&
41734177 !one -> dirty_submodule && !two -> dirty_submodule )
41744178 return 1 ; /* no change */
41754179 if (!one -> sha1_valid && !two -> sha1_valid )
@@ -4233,7 +4237,7 @@ void diff_debug_filespec(struct diff_filespec *s, int x, const char *one)
42334237 s -> path ,
42344238 DIFF_FILE_VALID (s ) ? "valid" : "invalid" ,
42354239 s -> mode ,
4236- s -> sha1_valid ? sha1_to_hex ( s -> sha1 ) : "" );
4240+ s -> sha1_valid ? oid_to_hex ( & s -> oid ) : "" );
42374241 fprintf (stderr , "queue[%d] %s size %lu\n" ,
42384242 x , one ? one : "" ,
42394243 s -> size );
@@ -4303,11 +4307,11 @@ static void diff_resolve_rename_copy(void)
43034307 else
43044308 p -> status = DIFF_STATUS_RENAMED ;
43054309 }
4306- else if (hashcmp ( p -> one -> sha1 , p -> two -> sha1 ) ||
4310+ else if (oidcmp ( & p -> one -> oid , & p -> two -> oid ) ||
43074311 p -> one -> mode != p -> two -> mode ||
43084312 p -> one -> dirty_submodule ||
43094313 p -> two -> dirty_submodule ||
4310- is_null_sha1 ( p -> one -> sha1 ))
4314+ is_null_oid ( & p -> one -> oid ))
43114315 p -> status = DIFF_STATUS_MODIFIED ;
43124316 else {
43134317 /* This is a "no-change" entry and should not
@@ -4523,8 +4527,10 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
45234527
45244528 if (diff_filespec_is_binary (p -> one ) ||
45254529 diff_filespec_is_binary (p -> two )) {
4526- git_SHA1_Update (& ctx , sha1_to_hex (p -> one -> sha1 ), 40 );
4527- git_SHA1_Update (& ctx , sha1_to_hex (p -> two -> sha1 ), 40 );
4530+ git_SHA1_Update (& ctx , oid_to_hex (& p -> one -> oid ),
4531+ 40 );
4532+ git_SHA1_Update (& ctx , oid_to_hex (& p -> two -> oid ),
4533+ 40 );
45284534 continue ;
45294535 }
45304536
@@ -5113,7 +5119,8 @@ size_t fill_textconv(struct userdiff_driver *driver,
51135119 die ("BUG: fill_textconv called with non-textconv driver" );
51145120
51155121 if (driver -> textconv_cache && df -> sha1_valid ) {
5116- * outbuf = notes_cache_get (driver -> textconv_cache , df -> sha1 ,
5122+ * outbuf = notes_cache_get (driver -> textconv_cache ,
5123+ df -> oid .hash ,
51175124 & size );
51185125 if (* outbuf )
51195126 return size ;
@@ -5125,7 +5132,7 @@ size_t fill_textconv(struct userdiff_driver *driver,
51255132
51265133 if (driver -> textconv_cache && df -> sha1_valid ) {
51275134 /* ignore errors, as we might be in a readonly repository */
5128- notes_cache_put (driver -> textconv_cache , df -> sha1 , * outbuf ,
5135+ notes_cache_put (driver -> textconv_cache , df -> oid . hash , * outbuf ,
51295136 size );
51305137 /*
51315138 * we could save up changes and flush them all at the end,
0 commit comments