15
15
static struct sha1_array good_revs ;
16
16
static struct sha1_array skipped_revs ;
17
17
18
- static unsigned char * current_bad_sha1 ;
18
+ static struct object_id * current_bad_oid ;
19
19
20
20
static const char * argv_checkout [] = {"checkout" , "-q" , NULL , "--" , NULL };
21
21
static const char * argv_show_branch [] = {"show-branch" , NULL , NULL };
@@ -404,8 +404,8 @@ static int register_ref(const char *refname, const unsigned char *sha1,
404
404
int flags , void * cb_data )
405
405
{
406
406
if (!strcmp (refname , "bad" )) {
407
- current_bad_sha1 = xmalloc (20 );
408
- hashcpy (current_bad_sha1 , sha1 );
407
+ current_bad_oid = xmalloc (sizeof ( * current_bad_oid ) );
408
+ hashcpy (current_bad_oid -> hash , sha1 );
409
409
} else if (starts_with (refname , "good-" )) {
410
410
sha1_array_append (& good_revs , sha1 );
411
411
} else if (starts_with (refname , "skip-" )) {
@@ -564,7 +564,7 @@ static struct commit_list *skip_away(struct commit_list *list, int count)
564
564
565
565
for (i = 0 ; cur ; cur = cur -> next , i ++ ) {
566
566
if (i == index ) {
567
- if (hashcmp (cur -> item -> object .sha1 , current_bad_sha1 ))
567
+ if (hashcmp (cur -> item -> object .sha1 , current_bad_oid -> hash ))
568
568
return cur ;
569
569
if (previous )
570
570
return previous ;
@@ -607,7 +607,7 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
607
607
608
608
/* rev_argv.argv[0] will be ignored by setup_revisions */
609
609
argv_array_push (& rev_argv , "bisect_rev_setup" );
610
- argv_array_pushf (& rev_argv , bad_format , sha1_to_hex ( current_bad_sha1 ));
610
+ argv_array_pushf (& rev_argv , bad_format , oid_to_hex ( current_bad_oid ));
611
611
for (i = 0 ; i < good_revs .nr ; i ++ )
612
612
argv_array_pushf (& rev_argv , good_format ,
613
613
sha1_to_hex (good_revs .sha1 [i ]));
@@ -628,7 +628,7 @@ static void bisect_common(struct rev_info *revs)
628
628
}
629
629
630
630
static void exit_if_skipped_commits (struct commit_list * tried ,
631
- const unsigned char * bad )
631
+ const struct object_id * bad )
632
632
{
633
633
if (!tried )
634
634
return ;
@@ -637,12 +637,12 @@ static void exit_if_skipped_commits(struct commit_list *tried,
637
637
"The first bad commit could be any of:\n" );
638
638
print_commit_list (tried , "%s\n" , "%s\n" );
639
639
if (bad )
640
- printf ("%s\n" , sha1_to_hex (bad ));
640
+ printf ("%s\n" , oid_to_hex (bad ));
641
641
printf ("We cannot bisect more!\n" );
642
642
exit (2 );
643
643
}
644
644
645
- static int is_expected_rev (const unsigned char * sha1 )
645
+ static int is_expected_rev (const struct object_id * oid )
646
646
{
647
647
const char * filename = git_path ("BISECT_EXPECTED_REV" );
648
648
struct stat st ;
@@ -658,7 +658,7 @@ static int is_expected_rev(const unsigned char *sha1)
658
658
return 0 ;
659
659
660
660
if (strbuf_getline (& str , fp , '\n' ) != EOF )
661
- res = !strcmp (str .buf , sha1_to_hex ( sha1 ));
661
+ res = !strcmp (str .buf , oid_to_hex ( oid ));
662
662
663
663
strbuf_release (& str );
664
664
fclose (fp );
@@ -719,7 +719,7 @@ static struct commit **get_bad_and_good_commits(int *rev_nr)
719
719
struct commit * * rev = xmalloc (len * sizeof (* rev ));
720
720
int i , n = 0 ;
721
721
722
- rev [n ++ ] = get_commit_reference (current_bad_sha1 );
722
+ rev [n ++ ] = get_commit_reference (current_bad_oid -> hash );
723
723
for (i = 0 ; i < good_revs .nr ; i ++ )
724
724
rev [n ++ ] = get_commit_reference (good_revs .sha1 [i ]);
725
725
* rev_nr = n ;
@@ -729,8 +729,8 @@ static struct commit **get_bad_and_good_commits(int *rev_nr)
729
729
730
730
static void handle_bad_merge_base (void )
731
731
{
732
- if (is_expected_rev (current_bad_sha1 )) {
733
- char * bad_hex = sha1_to_hex ( current_bad_sha1 );
732
+ if (is_expected_rev (current_bad_oid )) {
733
+ char * bad_hex = oid_to_hex ( current_bad_oid );
734
734
char * good_hex = join_sha1_array_hex (& good_revs , ' ' );
735
735
736
736
fprintf (stderr , "The merge base %s is bad.\n"
@@ -750,7 +750,7 @@ static void handle_bad_merge_base(void)
750
750
static void handle_skipped_merge_base (const unsigned char * mb )
751
751
{
752
752
char * mb_hex = sha1_to_hex (mb );
753
- char * bad_hex = sha1_to_hex (current_bad_sha1 );
753
+ char * bad_hex = sha1_to_hex (current_bad_oid -> hash );
754
754
char * good_hex = join_sha1_array_hex (& good_revs , ' ' );
755
755
756
756
warning ("the merge base between %s and [%s] "
@@ -781,7 +781,7 @@ static void check_merge_bases(int no_checkout)
781
781
782
782
for (; result ; result = result -> next ) {
783
783
const unsigned char * mb = result -> item -> object .sha1 ;
784
- if (!hashcmp (mb , current_bad_sha1 )) {
784
+ if (!hashcmp (mb , current_bad_oid -> hash )) {
785
785
handle_bad_merge_base ();
786
786
} else if (0 <= sha1_array_lookup (& good_revs , mb )) {
787
787
continue ;
@@ -838,7 +838,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
838
838
struct stat st ;
839
839
int fd ;
840
840
841
- if (!current_bad_sha1 )
841
+ if (!current_bad_oid )
842
842
die ("a bad revision is needed" );
843
843
844
844
/* Check if file BISECT_ANCESTORS_OK exists. */
@@ -903,7 +903,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
903
903
struct commit_list * tried ;
904
904
int reaches = 0 , all = 0 , nr , steps ;
905
905
const unsigned char * bisect_rev ;
906
- char bisect_rev_hex [41 ];
906
+ char bisect_rev_hex [GIT_SHA1_HEXSZ + 1 ];
907
907
908
908
if (read_bisect_refs ())
909
909
die ("reading bisect refs failed" );
@@ -927,7 +927,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
927
927
exit_if_skipped_commits (tried , NULL );
928
928
929
929
printf ("%s was both good and bad\n" ,
930
- sha1_to_hex ( current_bad_sha1 ));
930
+ oid_to_hex ( current_bad_oid ));
931
931
exit (1 );
932
932
}
933
933
@@ -938,10 +938,10 @@ int bisect_next_all(const char *prefix, int no_checkout)
938
938
}
939
939
940
940
bisect_rev = revs .commits -> item -> object .sha1 ;
941
- memcpy (bisect_rev_hex , sha1_to_hex (bisect_rev ), 41 );
941
+ memcpy (bisect_rev_hex , sha1_to_hex (bisect_rev ), GIT_SHA1_HEXSZ + 1 );
942
942
943
- if (!hashcmp (bisect_rev , current_bad_sha1 )) {
944
- exit_if_skipped_commits (tried , current_bad_sha1 );
943
+ if (!hashcmp (bisect_rev , current_bad_oid -> hash )) {
944
+ exit_if_skipped_commits (tried , current_bad_oid );
945
945
printf ("%s is the first bad commit\n" , bisect_rev_hex );
946
946
show_diff_tree (prefix , revs .commits -> item );
947
947
/* This means the bisection process succeeded. */
0 commit comments