@@ -66,42 +66,42 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con
6666}
6767
6868typedef int (* each_tag_name_fn )(const char * name , const char * ref ,
69- const unsigned char * sha1 , const void * cb_data );
69+ const struct object_id * oid , const void * cb_data );
7070
7171static int for_each_tag_name (const char * * argv , each_tag_name_fn fn ,
7272 const void * cb_data )
7373{
7474 const char * * p ;
7575 struct strbuf ref = STRBUF_INIT ;
7676 int had_error = 0 ;
77- unsigned char sha1 [ 20 ] ;
77+ struct object_id oid ;
7878
7979 for (p = argv ; * p ; p ++ ) {
8080 strbuf_reset (& ref );
8181 strbuf_addf (& ref , "refs/tags/%s" , * p );
82- if (read_ref (ref .buf , sha1 )) {
82+ if (read_ref (ref .buf , oid . hash )) {
8383 error (_ ("tag '%s' not found." ), * p );
8484 had_error = 1 ;
8585 continue ;
8686 }
87- if (fn (* p , ref .buf , sha1 , cb_data ))
87+ if (fn (* p , ref .buf , & oid , cb_data ))
8888 had_error = 1 ;
8989 }
9090 strbuf_release (& ref );
9191 return had_error ;
9292}
9393
9494static int delete_tag (const char * name , const char * ref ,
95- const unsigned char * sha1 , const void * cb_data )
95+ const struct object_id * oid , const void * cb_data )
9696{
97- if (delete_ref (NULL , ref , sha1 , 0 ))
97+ if (delete_ref (NULL , ref , oid -> hash , 0 ))
9898 return 1 ;
99- printf (_ ("Deleted tag '%s' (was %s)\n" ), name , find_unique_abbrev (sha1 , DEFAULT_ABBREV ));
99+ printf (_ ("Deleted tag '%s' (was %s)\n" ), name , find_unique_abbrev (oid -> hash , DEFAULT_ABBREV ));
100100 return 0 ;
101101}
102102
103103static int verify_tag (const char * name , const char * ref ,
104- const unsigned char * sha1 , const void * cb_data )
104+ const struct object_id * oid , const void * cb_data )
105105{
106106 int flags ;
107107 const char * fmt_pretty = cb_data ;
@@ -110,11 +110,11 @@ static int verify_tag(const char *name, const char *ref,
110110 if (fmt_pretty )
111111 flags = GPG_VERIFY_OMIT_STATUS ;
112112
113- if (gpg_verify_tag (sha1 , name , flags ))
113+ if (gpg_verify_tag (oid -> hash , name , flags ))
114114 return -1 ;
115115
116116 if (fmt_pretty )
117- pretty_print_ref (name , sha1 , fmt_pretty );
117+ pretty_print_ref (name , oid -> hash , fmt_pretty );
118118
119119 return 0 ;
120120}
@@ -182,13 +182,13 @@ static int git_tag_config(const char *var, const char *value, void *cb)
182182 return git_default_config (var , value , cb );
183183}
184184
185- static void write_tag_body (int fd , const unsigned char * sha1 )
185+ static void write_tag_body (int fd , const struct object_id * oid )
186186{
187187 unsigned long size ;
188188 enum object_type type ;
189189 char * buf , * sp ;
190190
191- buf = read_sha1_file (sha1 , & type , & size );
191+ buf = read_sha1_file (oid -> hash , & type , & size );
192192 if (!buf )
193193 return ;
194194 /* skip header */
@@ -204,11 +204,11 @@ static void write_tag_body(int fd, const unsigned char *sha1)
204204 free (buf );
205205}
206206
207- static int build_tag_object (struct strbuf * buf , int sign , unsigned char * result )
207+ static int build_tag_object (struct strbuf * buf , int sign , struct object_id * result )
208208{
209209 if (sign && do_sign (buf ) < 0 )
210210 return error (_ ("unable to sign the tag" ));
211- if (write_sha1_file (buf -> buf , buf -> len , tag_type , result ) < 0 )
211+ if (write_sha1_file (buf -> buf , buf -> len , tag_type , result -> hash ) < 0 )
212212 return error (_ ("unable to write tag file" ));
213213 return 0 ;
214214}
@@ -223,15 +223,15 @@ struct create_tag_options {
223223 } cleanup_mode ;
224224};
225225
226- static void create_tag (const unsigned char * object , const char * tag ,
226+ static void create_tag (const struct object_id * object , const char * tag ,
227227 struct strbuf * buf , struct create_tag_options * opt ,
228- unsigned char * prev , unsigned char * result )
228+ struct object_id * prev , struct object_id * result )
229229{
230230 enum object_type type ;
231231 struct strbuf header = STRBUF_INIT ;
232232 char * path = NULL ;
233233
234- type = sha1_object_info (object , NULL );
234+ type = sha1_object_info (object -> hash , NULL );
235235 if (type <= OBJ_NONE )
236236 die (_ ("bad object type." ));
237237
@@ -240,7 +240,7 @@ static void create_tag(const unsigned char *object, const char *tag,
240240 "type %s\n"
241241 "tag %s\n"
242242 "tagger %s\n\n" ,
243- sha1_to_hex (object ),
243+ oid_to_hex (object ),
244244 typename (type ),
245245 tag ,
246246 git_committer_info (IDENT_STRICT ));
@@ -254,7 +254,7 @@ static void create_tag(const unsigned char *object, const char *tag,
254254 if (fd < 0 )
255255 die_errno (_ ("could not create file '%s'" ), path );
256256
257- if (!is_null_sha1 (prev )) {
257+ if (!is_null_oid (prev )) {
258258 write_tag_body (fd , prev );
259259 } else {
260260 struct strbuf buf = STRBUF_INIT ;
@@ -296,7 +296,7 @@ static void create_tag(const unsigned char *object, const char *tag,
296296 }
297297}
298298
299- static void create_reflog_msg (const unsigned char * sha1 , struct strbuf * sb )
299+ static void create_reflog_msg (const struct object_id * oid , struct strbuf * sb )
300300{
301301 enum object_type type ;
302302 struct commit * c ;
@@ -310,25 +310,25 @@ static void create_reflog_msg(const unsigned char *sha1, struct strbuf *sb)
310310 strbuf_addstr (sb , rla );
311311 } else {
312312 strbuf_addstr (sb , _ ("tag: tagging " ));
313- strbuf_add_unique_abbrev (sb , sha1 , DEFAULT_ABBREV );
313+ strbuf_add_unique_abbrev (sb , oid -> hash , DEFAULT_ABBREV );
314314 }
315315
316316 strbuf_addstr (sb , " (" );
317- type = sha1_object_info (sha1 , NULL );
317+ type = sha1_object_info (oid -> hash , NULL );
318318 switch (type ) {
319319 default :
320320 strbuf_addstr (sb , _ ("object of unknown type" ));
321321 break ;
322322 case OBJ_COMMIT :
323- if ((buf = read_sha1_file (sha1 , & type , & size )) != NULL ) {
323+ if ((buf = read_sha1_file (oid -> hash , & type , & size )) != NULL ) {
324324 subject_len = find_commit_subject (buf , & subject_start );
325325 strbuf_insert (sb , sb -> len , subject_start , subject_len );
326326 } else {
327327 strbuf_addstr (sb , _ ("commit object" ));
328328 }
329329 free (buf );
330330
331- if ((c = lookup_commit_reference (sha1 )) != NULL )
331+ if ((c = lookup_commit_reference (oid -> hash )) != NULL )
332332 strbuf_addf (sb , ", %s" , show_date (c -> date , 0 , DATE_MODE (SHORT )));
333333 break ;
334334 case OBJ_TREE :
@@ -378,7 +378,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
378378 struct strbuf buf = STRBUF_INIT ;
379379 struct strbuf ref = STRBUF_INIT ;
380380 struct strbuf reflog_msg = STRBUF_INIT ;
381- unsigned char object [ 20 ] , prev [ 20 ] ;
381+ struct object_id object , prev ;
382382 const char * object_ref , * tag ;
383383 struct create_tag_options opt ;
384384 char * cleanup_arg = NULL ;
@@ -528,14 +528,14 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
528528 if (argc > 2 )
529529 die (_ ("too many params" ));
530530
531- if (get_sha1 (object_ref , object ))
531+ if (get_oid (object_ref , & object ))
532532 die (_ ("Failed to resolve '%s' as a valid ref." ), object_ref );
533533
534534 if (strbuf_check_tag_ref (& ref , tag ))
535535 die (_ ("'%s' is not a valid tag name." ), tag );
536536
537- if (read_ref (ref .buf , prev ))
538- hashclr ( prev );
537+ if (read_ref (ref .buf , prev . hash ))
538+ oidclr ( & prev );
539539 else if (!force )
540540 die (_ ("tag '%s' already exists" ), tag );
541541
@@ -550,24 +550,24 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
550550 else
551551 die (_ ("Invalid cleanup mode %s" ), cleanup_arg );
552552
553- create_reflog_msg (object , & reflog_msg );
553+ create_reflog_msg (& object , & reflog_msg );
554554
555555 if (create_tag_object ) {
556556 if (force_sign_annotate && !annotate )
557557 opt .sign = 1 ;
558- create_tag (object , tag , & buf , & opt , prev , object );
558+ create_tag (& object , tag , & buf , & opt , & prev , & object );
559559 }
560560
561561 transaction = ref_transaction_begin (& err );
562562 if (!transaction ||
563- ref_transaction_update (transaction , ref .buf , object , prev ,
563+ ref_transaction_update (transaction , ref .buf , object . hash , prev . hash ,
564564 create_reflog ? REF_FORCE_CREATE_REFLOG : 0 ,
565565 reflog_msg .buf , & err ) ||
566566 ref_transaction_commit (transaction , & err ))
567567 die ("%s" , err .buf );
568568 ref_transaction_free (transaction );
569- if (force && !is_null_sha1 ( prev ) && hashcmp ( prev , object ))
570- printf (_ ("Updated tag '%s' (was %s)\n" ), tag , find_unique_abbrev (prev , DEFAULT_ABBREV ));
569+ if (force && !is_null_oid ( & prev ) && oidcmp ( & prev , & object ))
570+ printf (_ ("Updated tag '%s' (was %s)\n" ), tag , find_unique_abbrev (prev . hash , DEFAULT_ABBREV ));
571571
572572 strbuf_release (& err );
573573 strbuf_release (& buf );
0 commit comments