1515static struct sha1_array good_revs ;
1616static struct sha1_array skipped_revs ;
1717
18- static unsigned char * current_bad_sha1 ;
18+ static struct object_id * current_bad_oid ;
1919
2020static const char * argv_checkout [] = {"checkout" , "-q" , NULL , "--" , NULL };
2121static const char * argv_show_branch [] = {"show-branch" , NULL , NULL };
@@ -404,8 +404,8 @@ static int register_ref(const char *refname, const unsigned char *sha1,
404404 int flags , void * cb_data )
405405{
406406 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 );
409409 } else if (starts_with (refname , "good-" )) {
410410 sha1_array_append (& good_revs , sha1 );
411411 } else if (starts_with (refname , "skip-" )) {
@@ -564,7 +564,7 @@ static struct commit_list *skip_away(struct commit_list *list, int count)
564564
565565 for (i = 0 ; cur ; cur = cur -> next , i ++ ) {
566566 if (i == index ) {
567- if (hashcmp (cur -> item -> object .sha1 , current_bad_sha1 ))
567+ if (hashcmp (cur -> item -> object .sha1 , current_bad_oid -> hash ))
568568 return cur ;
569569 if (previous )
570570 return previous ;
@@ -607,7 +607,7 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
607607
608608 /* rev_argv.argv[0] will be ignored by setup_revisions */
609609 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 ));
611611 for (i = 0 ; i < good_revs .nr ; i ++ )
612612 argv_array_pushf (& rev_argv , good_format ,
613613 sha1_to_hex (good_revs .sha1 [i ]));
@@ -628,7 +628,7 @@ static void bisect_common(struct rev_info *revs)
628628}
629629
630630static void exit_if_skipped_commits (struct commit_list * tried ,
631- const unsigned char * bad )
631+ const struct object_id * bad )
632632{
633633 if (!tried )
634634 return ;
@@ -637,12 +637,12 @@ static void exit_if_skipped_commits(struct commit_list *tried,
637637 "The first bad commit could be any of:\n" );
638638 print_commit_list (tried , "%s\n" , "%s\n" );
639639 if (bad )
640- printf ("%s\n" , sha1_to_hex (bad ));
640+ printf ("%s\n" , oid_to_hex (bad ));
641641 printf ("We cannot bisect more!\n" );
642642 exit (2 );
643643}
644644
645- static int is_expected_rev (const unsigned char * sha1 )
645+ static int is_expected_rev (const struct object_id * oid )
646646{
647647 const char * filename = git_path ("BISECT_EXPECTED_REV" );
648648 struct stat st ;
@@ -658,7 +658,7 @@ static int is_expected_rev(const unsigned char *sha1)
658658 return 0 ;
659659
660660 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 ));
662662
663663 strbuf_release (& str );
664664 fclose (fp );
@@ -719,7 +719,7 @@ static struct commit **get_bad_and_good_commits(int *rev_nr)
719719 struct commit * * rev = xmalloc (len * sizeof (* rev ));
720720 int i , n = 0 ;
721721
722- rev [n ++ ] = get_commit_reference (current_bad_sha1 );
722+ rev [n ++ ] = get_commit_reference (current_bad_oid -> hash );
723723 for (i = 0 ; i < good_revs .nr ; i ++ )
724724 rev [n ++ ] = get_commit_reference (good_revs .sha1 [i ]);
725725 * rev_nr = n ;
@@ -729,8 +729,8 @@ static struct commit **get_bad_and_good_commits(int *rev_nr)
729729
730730static void handle_bad_merge_base (void )
731731{
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 );
734734 char * good_hex = join_sha1_array_hex (& good_revs , ' ' );
735735
736736 fprintf (stderr , "The merge base %s is bad.\n"
@@ -750,7 +750,7 @@ static void handle_bad_merge_base(void)
750750static void handle_skipped_merge_base (const unsigned char * mb )
751751{
752752 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 );
754754 char * good_hex = join_sha1_array_hex (& good_revs , ' ' );
755755
756756 warning ("the merge base between %s and [%s] "
@@ -781,7 +781,7 @@ static void check_merge_bases(int no_checkout)
781781
782782 for (; result ; result = result -> next ) {
783783 const unsigned char * mb = result -> item -> object .sha1 ;
784- if (!hashcmp (mb , current_bad_sha1 )) {
784+ if (!hashcmp (mb , current_bad_oid -> hash )) {
785785 handle_bad_merge_base ();
786786 } else if (0 <= sha1_array_lookup (& good_revs , mb )) {
787787 continue ;
@@ -838,7 +838,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
838838 struct stat st ;
839839 int fd ;
840840
841- if (!current_bad_sha1 )
841+ if (!current_bad_oid )
842842 die ("a bad revision is needed" );
843843
844844 /* Check if file BISECT_ANCESTORS_OK exists. */
@@ -903,7 +903,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
903903 struct commit_list * tried ;
904904 int reaches = 0 , all = 0 , nr , steps ;
905905 const unsigned char * bisect_rev ;
906- char bisect_rev_hex [41 ];
906+ char bisect_rev_hex [GIT_SHA1_HEXSZ + 1 ];
907907
908908 if (read_bisect_refs ())
909909 die ("reading bisect refs failed" );
@@ -927,7 +927,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
927927 exit_if_skipped_commits (tried , NULL );
928928
929929 printf ("%s was both good and bad\n" ,
930- sha1_to_hex ( current_bad_sha1 ));
930+ oid_to_hex ( current_bad_oid ));
931931 exit (1 );
932932 }
933933
@@ -938,10 +938,10 @@ int bisect_next_all(const char *prefix, int no_checkout)
938938 }
939939
940940 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 );
942942
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 );
945945 printf ("%s is the first bad commit\n" , bisect_rev_hex );
946946 show_diff_tree (prefix , revs .commits -> item );
947947 /* This means the bisection process succeeded. */
0 commit comments