@@ -456,7 +456,7 @@ static void alias_all_urls(void)
456
456
static void read_config (void )
457
457
{
458
458
static int loaded ;
459
- unsigned char sha1 [ 20 ] ;
459
+ struct object_id oid ;
460
460
const char * head_ref ;
461
461
int flag ;
462
462
@@ -465,7 +465,7 @@ static void read_config(void)
465
465
loaded = 1 ;
466
466
467
467
current_branch = NULL ;
468
- head_ref = resolve_ref_unsafe ("HEAD" , 0 , sha1 , & flag );
468
+ head_ref = resolve_ref_unsafe ("HEAD" , 0 , oid . hash , & flag );
469
469
if (head_ref && (flag & REF_ISSYMREF ) &&
470
470
skip_prefix (head_ref , "refs/heads/" , & head_ref )) {
471
471
current_branch = make_branch (head_ref , 0 );
@@ -544,12 +544,12 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
544
544
flags = REFNAME_ALLOW_ONELEVEL | (is_glob ? REFNAME_REFSPEC_PATTERN : 0 );
545
545
546
546
if (fetch ) {
547
- unsigned char unused [ 40 ] ;
547
+ struct object_id unused ;
548
548
549
549
/* LHS */
550
550
if (!* rs [i ].src )
551
551
; /* empty is ok; it means "HEAD" */
552
- else if (llen == 40 && !get_sha1_hex (rs [i ].src , unused ))
552
+ else if (llen == GIT_SHA1_HEXSZ && !get_oid_hex (rs [i ].src , & unused ))
553
553
rs [i ].exact_sha1 = 1 ; /* ok */
554
554
else if (!check_refname_format (rs [i ].src , flags ))
555
555
; /* valid looking ref is ok */
@@ -1082,20 +1082,20 @@ static struct ref *alloc_delete_ref(void)
1082
1082
static int try_explicit_object_name (const char * name ,
1083
1083
struct ref * * match )
1084
1084
{
1085
- unsigned char sha1 [ 20 ] ;
1085
+ struct object_id oid ;
1086
1086
1087
1087
if (!* name ) {
1088
1088
if (match )
1089
1089
* match = alloc_delete_ref ();
1090
1090
return 0 ;
1091
1091
}
1092
1092
1093
- if (get_sha1 (name , sha1 ))
1093
+ if (get_sha1 (name , oid . hash ))
1094
1094
return -1 ;
1095
1095
1096
1096
if (match ) {
1097
1097
* match = alloc_ref (name );
1098
- hashcpy ( (* match )-> new_oid . hash , sha1 );
1098
+ oidcpy ( & (* match )-> new_oid , & oid );
1099
1099
}
1100
1100
return 0 ;
1101
1101
}
@@ -1110,10 +1110,10 @@ static struct ref *make_linked_ref(const char *name, struct ref ***tail)
1110
1110
static char * guess_ref (const char * name , struct ref * peer )
1111
1111
{
1112
1112
struct strbuf buf = STRBUF_INIT ;
1113
- unsigned char sha1 [ 20 ] ;
1113
+ struct object_id oid ;
1114
1114
1115
1115
const char * r = resolve_ref_unsafe (peer -> name , RESOLVE_REF_READING ,
1116
- sha1 , NULL );
1116
+ oid . hash , NULL );
1117
1117
if (!r )
1118
1118
return NULL ;
1119
1119
@@ -1171,12 +1171,12 @@ static int match_explicit(struct ref *src, struct ref *dst,
1171
1171
return -1 ;
1172
1172
1173
1173
if (!dst_value ) {
1174
- unsigned char sha1 [ 20 ] ;
1174
+ struct object_id oid ;
1175
1175
int flag ;
1176
1176
1177
1177
dst_value = resolve_ref_unsafe (matched_src -> name ,
1178
1178
RESOLVE_REF_READING ,
1179
- sha1 , & flag );
1179
+ oid . hash , & flag );
1180
1180
if (!dst_value ||
1181
1181
((flag & REF_ISSYMREF ) &&
1182
1182
!starts_with (dst_value , "refs/heads/" )))
@@ -1292,13 +1292,13 @@ struct tips {
1292
1292
int nr , alloc ;
1293
1293
};
1294
1294
1295
- static void add_to_tips (struct tips * tips , const unsigned char * sha1 )
1295
+ static void add_to_tips (struct tips * tips , const struct object_id * oid )
1296
1296
{
1297
1297
struct commit * commit ;
1298
1298
1299
- if (is_null_sha1 ( sha1 ))
1299
+ if (is_null_oid ( oid ))
1300
1300
return ;
1301
- commit = lookup_commit_reference_gently (sha1 , 1 );
1301
+ commit = lookup_commit_reference_gently (oid -> hash , 1 );
1302
1302
if (!commit || (commit -> object .flags & TMP_MARK ))
1303
1303
return ;
1304
1304
commit -> object .flags |= TMP_MARK ;
@@ -1322,9 +1322,9 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1322
1322
for (ref = * dst ; ref ; ref = ref -> next ) {
1323
1323
if (ref -> peer_ref &&
1324
1324
!is_null_oid (& ref -> peer_ref -> new_oid ))
1325
- add_to_tips (& sent_tips , ref -> peer_ref -> new_oid . hash );
1325
+ add_to_tips (& sent_tips , & ref -> peer_ref -> new_oid );
1326
1326
else
1327
- add_to_tips (& sent_tips , ref -> old_oid . hash );
1327
+ add_to_tips (& sent_tips , & ref -> old_oid );
1328
1328
if (starts_with (ref -> name , "refs/tags/" ))
1329
1329
string_list_append (& dst_tag , ref -> name );
1330
1330
}
@@ -1609,7 +1609,7 @@ static void set_merge(struct branch *ret)
1609
1609
{
1610
1610
struct remote * remote ;
1611
1611
char * ref ;
1612
- unsigned char sha1 [ 20 ] ;
1612
+ struct object_id oid ;
1613
1613
int i ;
1614
1614
1615
1615
if (!ret )
@@ -1635,7 +1635,7 @@ static void set_merge(struct branch *ret)
1635
1635
strcmp (ret -> remote_name , "." ))
1636
1636
continue ;
1637
1637
if (dwim_ref (ret -> merge_name [i ], strlen (ret -> merge_name [i ]),
1638
- sha1 , & ref ) == 1 )
1638
+ oid . hash , & ref ) == 1 )
1639
1639
ret -> merge [i ]-> dst = ref ;
1640
1640
else
1641
1641
ret -> merge [i ]-> dst = xstrdup (ret -> merge_name [i ]);
@@ -1795,10 +1795,10 @@ const char *branch_get_push(struct branch *branch, struct strbuf *err)
1795
1795
1796
1796
static int ignore_symref_update (const char * refname )
1797
1797
{
1798
- unsigned char sha1 [ 20 ] ;
1798
+ struct object_id oid ;
1799
1799
int flag ;
1800
1800
1801
- if (!resolve_ref_unsafe (refname , 0 , sha1 , & flag ))
1801
+ if (!resolve_ref_unsafe (refname , 0 , oid . hash , & flag ))
1802
1802
return 0 ; /* non-existing refs are OK */
1803
1803
return (flag & REF_ISSYMREF );
1804
1804
}
@@ -1995,7 +1995,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
1995
1995
int stat_tracking_info (struct branch * branch , int * num_ours , int * num_theirs ,
1996
1996
const char * * upstream_name )
1997
1997
{
1998
- unsigned char sha1 [ 20 ] ;
1998
+ struct object_id oid ;
1999
1999
struct commit * ours , * theirs ;
2000
2000
struct rev_info revs ;
2001
2001
const char * base ;
@@ -2009,15 +2009,15 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
2009
2009
return -1 ;
2010
2010
2011
2011
/* Cannot stat if what we used to build on no longer exists */
2012
- if (read_ref (base , sha1 ))
2012
+ if (read_ref (base , oid . hash ))
2013
2013
return -1 ;
2014
- theirs = lookup_commit_reference (sha1 );
2014
+ theirs = lookup_commit_reference (oid . hash );
2015
2015
if (!theirs )
2016
2016
return -1 ;
2017
2017
2018
- if (read_ref (branch -> refname , sha1 ))
2018
+ if (read_ref (branch -> refname , oid . hash ))
2019
2019
return -1 ;
2020
- ours = lookup_commit_reference (sha1 );
2020
+ ours = lookup_commit_reference (oid . hash );
2021
2021
if (!ours )
2022
2022
return -1 ;
2023
2023
@@ -2328,14 +2328,14 @@ int is_empty_cas(const struct push_cas_option *cas)
2328
2328
* If we cannot do so, return negative to signal an error.
2329
2329
*/
2330
2330
static int remote_tracking (struct remote * remote , const char * refname ,
2331
- unsigned char sha1 [ 20 ] )
2331
+ struct object_id * oid )
2332
2332
{
2333
2333
char * dst ;
2334
2334
2335
2335
dst = apply_refspecs (remote -> fetch , remote -> fetch_refspec_nr , refname );
2336
2336
if (!dst )
2337
2337
return -1 ; /* no tracking ref for refname at remote */
2338
- if (read_ref (dst , sha1 ))
2338
+ if (read_ref (dst , oid -> hash ))
2339
2339
return -1 ; /* we know what the tracking ref is but we cannot read it */
2340
2340
return 0 ;
2341
2341
}
@@ -2354,7 +2354,7 @@ static void apply_cas(struct push_cas_option *cas,
2354
2354
ref -> expect_old_sha1 = 1 ;
2355
2355
if (!entry -> use_tracking )
2356
2356
hashcpy (ref -> old_oid_expect .hash , cas -> entry [i ].expect );
2357
- else if (remote_tracking (remote , ref -> name , ref -> old_oid_expect . hash ))
2357
+ else if (remote_tracking (remote , ref -> name , & ref -> old_oid_expect ))
2358
2358
ref -> expect_old_no_trackback = 1 ;
2359
2359
return ;
2360
2360
}
@@ -2364,7 +2364,7 @@ static void apply_cas(struct push_cas_option *cas,
2364
2364
return ;
2365
2365
2366
2366
ref -> expect_old_sha1 = 1 ;
2367
- if (remote_tracking (remote , ref -> name , ref -> old_oid_expect . hash ))
2367
+ if (remote_tracking (remote , ref -> name , & ref -> old_oid_expect ))
2368
2368
ref -> expect_old_no_trackback = 1 ;
2369
2369
}
2370
2370
0 commit comments