@@ -66,42 +66,42 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con
66
66
}
67
67
68
68
typedef 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 );
70
70
71
71
static int for_each_tag_name (const char * * argv , each_tag_name_fn fn ,
72
72
const void * cb_data )
73
73
{
74
74
const char * * p ;
75
75
struct strbuf ref = STRBUF_INIT ;
76
76
int had_error = 0 ;
77
- unsigned char sha1 [ 20 ] ;
77
+ struct object_id oid ;
78
78
79
79
for (p = argv ; * p ; p ++ ) {
80
80
strbuf_reset (& ref );
81
81
strbuf_addf (& ref , "refs/tags/%s" , * p );
82
- if (read_ref (ref .buf , sha1 )) {
82
+ if (read_ref (ref .buf , oid . hash )) {
83
83
error (_ ("tag '%s' not found." ), * p );
84
84
had_error = 1 ;
85
85
continue ;
86
86
}
87
- if (fn (* p , ref .buf , sha1 , cb_data ))
87
+ if (fn (* p , ref .buf , & oid , cb_data ))
88
88
had_error = 1 ;
89
89
}
90
90
strbuf_release (& ref );
91
91
return had_error ;
92
92
}
93
93
94
94
static 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 )
96
96
{
97
- if (delete_ref (NULL , ref , sha1 , 0 ))
97
+ if (delete_ref (NULL , ref , oid -> hash , 0 ))
98
98
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 ));
100
100
return 0 ;
101
101
}
102
102
103
103
static 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 )
105
105
{
106
106
int flags ;
107
107
const char * fmt_pretty = cb_data ;
@@ -110,11 +110,11 @@ static int verify_tag(const char *name, const char *ref,
110
110
if (fmt_pretty )
111
111
flags = GPG_VERIFY_OMIT_STATUS ;
112
112
113
- if (gpg_verify_tag (sha1 , name , flags ))
113
+ if (gpg_verify_tag (oid -> hash , name , flags ))
114
114
return -1 ;
115
115
116
116
if (fmt_pretty )
117
- pretty_print_ref (name , sha1 , fmt_pretty );
117
+ pretty_print_ref (name , oid -> hash , fmt_pretty );
118
118
119
119
return 0 ;
120
120
}
@@ -182,13 +182,13 @@ static int git_tag_config(const char *var, const char *value, void *cb)
182
182
return git_default_config (var , value , cb );
183
183
}
184
184
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 )
186
186
{
187
187
unsigned long size ;
188
188
enum object_type type ;
189
189
char * buf , * sp ;
190
190
191
- buf = read_sha1_file (sha1 , & type , & size );
191
+ buf = read_sha1_file (oid -> hash , & type , & size );
192
192
if (!buf )
193
193
return ;
194
194
/* skip header */
@@ -204,11 +204,11 @@ static void write_tag_body(int fd, const unsigned char *sha1)
204
204
free (buf );
205
205
}
206
206
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 )
208
208
{
209
209
if (sign && do_sign (buf ) < 0 )
210
210
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 )
212
212
return error (_ ("unable to write tag file" ));
213
213
return 0 ;
214
214
}
@@ -223,15 +223,15 @@ struct create_tag_options {
223
223
} cleanup_mode ;
224
224
};
225
225
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 ,
227
227
struct strbuf * buf , struct create_tag_options * opt ,
228
- unsigned char * prev , unsigned char * result )
228
+ struct object_id * prev , struct object_id * result )
229
229
{
230
230
enum object_type type ;
231
231
struct strbuf header = STRBUF_INIT ;
232
232
char * path = NULL ;
233
233
234
- type = sha1_object_info (object , NULL );
234
+ type = sha1_object_info (object -> hash , NULL );
235
235
if (type <= OBJ_NONE )
236
236
die (_ ("bad object type." ));
237
237
@@ -240,7 +240,7 @@ static void create_tag(const unsigned char *object, const char *tag,
240
240
"type %s\n"
241
241
"tag %s\n"
242
242
"tagger %s\n\n" ,
243
- sha1_to_hex (object ),
243
+ oid_to_hex (object ),
244
244
typename (type ),
245
245
tag ,
246
246
git_committer_info (IDENT_STRICT ));
@@ -254,7 +254,7 @@ static void create_tag(const unsigned char *object, const char *tag,
254
254
if (fd < 0 )
255
255
die_errno (_ ("could not create file '%s'" ), path );
256
256
257
- if (!is_null_sha1 (prev )) {
257
+ if (!is_null_oid (prev )) {
258
258
write_tag_body (fd , prev );
259
259
} else {
260
260
struct strbuf buf = STRBUF_INIT ;
@@ -296,7 +296,7 @@ static void create_tag(const unsigned char *object, const char *tag,
296
296
}
297
297
}
298
298
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 )
300
300
{
301
301
enum object_type type ;
302
302
struct commit * c ;
@@ -310,25 +310,25 @@ static void create_reflog_msg(const unsigned char *sha1, struct strbuf *sb)
310
310
strbuf_addstr (sb , rla );
311
311
} else {
312
312
strbuf_addstr (sb , _ ("tag: tagging " ));
313
- strbuf_add_unique_abbrev (sb , sha1 , DEFAULT_ABBREV );
313
+ strbuf_add_unique_abbrev (sb , oid -> hash , DEFAULT_ABBREV );
314
314
}
315
315
316
316
strbuf_addstr (sb , " (" );
317
- type = sha1_object_info (sha1 , NULL );
317
+ type = sha1_object_info (oid -> hash , NULL );
318
318
switch (type ) {
319
319
default :
320
320
strbuf_addstr (sb , _ ("object of unknown type" ));
321
321
break ;
322
322
case OBJ_COMMIT :
323
- if ((buf = read_sha1_file (sha1 , & type , & size )) != NULL ) {
323
+ if ((buf = read_sha1_file (oid -> hash , & type , & size )) != NULL ) {
324
324
subject_len = find_commit_subject (buf , & subject_start );
325
325
strbuf_insert (sb , sb -> len , subject_start , subject_len );
326
326
} else {
327
327
strbuf_addstr (sb , _ ("commit object" ));
328
328
}
329
329
free (buf );
330
330
331
- if ((c = lookup_commit_reference (sha1 )) != NULL )
331
+ if ((c = lookup_commit_reference (oid -> hash )) != NULL )
332
332
strbuf_addf (sb , ", %s" , show_date (c -> date , 0 , DATE_MODE (SHORT )));
333
333
break ;
334
334
case OBJ_TREE :
@@ -378,7 +378,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
378
378
struct strbuf buf = STRBUF_INIT ;
379
379
struct strbuf ref = STRBUF_INIT ;
380
380
struct strbuf reflog_msg = STRBUF_INIT ;
381
- unsigned char object [ 20 ] , prev [ 20 ] ;
381
+ struct object_id object , prev ;
382
382
const char * object_ref , * tag ;
383
383
struct create_tag_options opt ;
384
384
char * cleanup_arg = NULL ;
@@ -528,14 +528,14 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
528
528
if (argc > 2 )
529
529
die (_ ("too many params" ));
530
530
531
- if (get_sha1 (object_ref , object ))
531
+ if (get_oid (object_ref , & object ))
532
532
die (_ ("Failed to resolve '%s' as a valid ref." ), object_ref );
533
533
534
534
if (strbuf_check_tag_ref (& ref , tag ))
535
535
die (_ ("'%s' is not a valid tag name." ), tag );
536
536
537
- if (read_ref (ref .buf , prev ))
538
- hashclr ( prev );
537
+ if (read_ref (ref .buf , prev . hash ))
538
+ oidclr ( & prev );
539
539
else if (!force )
540
540
die (_ ("tag '%s' already exists" ), tag );
541
541
@@ -550,24 +550,24 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
550
550
else
551
551
die (_ ("Invalid cleanup mode %s" ), cleanup_arg );
552
552
553
- create_reflog_msg (object , & reflog_msg );
553
+ create_reflog_msg (& object , & reflog_msg );
554
554
555
555
if (create_tag_object ) {
556
556
if (force_sign_annotate && !annotate )
557
557
opt .sign = 1 ;
558
- create_tag (object , tag , & buf , & opt , prev , object );
558
+ create_tag (& object , tag , & buf , & opt , & prev , & object );
559
559
}
560
560
561
561
transaction = ref_transaction_begin (& err );
562
562
if (!transaction ||
563
- ref_transaction_update (transaction , ref .buf , object , prev ,
563
+ ref_transaction_update (transaction , ref .buf , object . hash , prev . hash ,
564
564
create_reflog ? REF_FORCE_CREATE_REFLOG : 0 ,
565
565
reflog_msg .buf , & err ) ||
566
566
ref_transaction_commit (transaction , & err ))
567
567
die ("%s" , err .buf );
568
568
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 ));
571
571
572
572
strbuf_release (& err );
573
573
strbuf_release (& buf );
0 commit comments