@@ -21,6 +21,9 @@ static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
21
21
static const char * argv_show_branch [] = {"show-branch" , NULL , NULL };
22
22
static const char * argv_update_ref [] = {"update-ref" , "--no-deref" , "BISECT_HEAD" , NULL , NULL };
23
23
24
+ static const char * term_bad ;
25
+ static const char * term_good ;
26
+
24
27
/* Remember to update object flag allocation in object.h */
25
28
#define COUNTED (1u<<16)
26
29
@@ -403,15 +406,21 @@ struct commit_list *find_bisection(struct commit_list *list,
403
406
static int register_ref (const char * refname , const struct object_id * oid ,
404
407
int flags , void * cb_data )
405
408
{
406
- if (!strcmp (refname , "bad" )) {
409
+ struct strbuf good_prefix = STRBUF_INIT ;
410
+ strbuf_addstr (& good_prefix , term_good );
411
+ strbuf_addstr (& good_prefix , "-" );
412
+
413
+ if (!strcmp (refname , term_bad )) {
407
414
current_bad_oid = xmalloc (sizeof (* current_bad_oid ));
408
415
oidcpy (current_bad_oid , oid );
409
- } else if (starts_with (refname , "good-" )) {
416
+ } else if (starts_with (refname , good_prefix . buf )) {
410
417
sha1_array_append (& good_revs , oid -> hash );
411
418
} else if (starts_with (refname , "skip-" )) {
412
419
sha1_array_append (& skipped_revs , oid -> hash );
413
420
}
414
421
422
+ strbuf_release (& good_prefix );
423
+
415
424
return 0 ;
416
425
}
417
426
@@ -634,7 +643,7 @@ static void exit_if_skipped_commits(struct commit_list *tried,
634
643
return ;
635
644
636
645
printf ("There are only 'skip'ped commits left to test.\n"
637
- "The first bad commit could be any of:\n" );
646
+ "The first %s commit could be any of:\n" , term_bad );
638
647
print_commit_list (tried , "%s\n" , "%s\n" );
639
648
if (bad )
640
649
printf ("%s\n" , oid_to_hex (bad ));
@@ -732,18 +741,24 @@ static void handle_bad_merge_base(void)
732
741
if (is_expected_rev (current_bad_oid )) {
733
742
char * bad_hex = oid_to_hex (current_bad_oid );
734
743
char * good_hex = join_sha1_array_hex (& good_revs , ' ' );
735
-
736
- fprintf (stderr , "The merge base %s is bad.\n"
737
- "This means the bug has been fixed "
738
- "between %s and [%s].\n" ,
739
- bad_hex , bad_hex , good_hex );
740
-
744
+ if (!strcmp (term_bad , "bad" ) && !strcmp (term_good , "good" )) {
745
+ fprintf (stderr , "The merge base %s is bad.\n"
746
+ "This means the bug has been fixed "
747
+ "between %s and [%s].\n" ,
748
+ bad_hex , bad_hex , good_hex );
749
+ } else {
750
+ fprintf (stderr , "The merge base %s is %s.\n"
751
+ "This means the first '%s' commit is "
752
+ "between %s and [%s].\n" ,
753
+ bad_hex , term_bad , term_good , bad_hex , good_hex );
754
+ }
741
755
exit (3 );
742
756
}
743
757
744
- fprintf (stderr , "Some good revs are not ancestor of the bad rev.\n"
758
+ fprintf (stderr , "Some %s revs are not ancestor of the %s rev.\n"
745
759
"git bisect cannot work properly in this case.\n"
746
- "Maybe you mistook good and bad revs?\n" );
760
+ "Maybe you mistook %s and %s revs?\n" ,
761
+ term_good , term_bad , term_good , term_bad );
747
762
exit (1 );
748
763
}
749
764
@@ -755,10 +770,10 @@ static void handle_skipped_merge_base(const unsigned char *mb)
755
770
756
771
warning ("the merge base between %s and [%s] "
757
772
"must be skipped.\n"
758
- "So we cannot be sure the first bad commit is "
773
+ "So we cannot be sure the first %s commit is "
759
774
"between %s and %s.\n"
760
775
"We continue anyway." ,
761
- bad_hex , good_hex , mb_hex , bad_hex );
776
+ bad_hex , good_hex , term_bad , mb_hex , bad_hex );
762
777
free (good_hex );
763
778
}
764
779
@@ -839,7 +854,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
839
854
int fd ;
840
855
841
856
if (!current_bad_oid )
842
- die ("a bad revision is needed" );
857
+ die ("a %s revision is needed" , term_bad );
843
858
844
859
/* Check if file BISECT_ANCESTORS_OK exists. */
845
860
if (!stat (filename , & st ) && S_ISREG (st .st_mode ))
@@ -905,6 +920,8 @@ int bisect_next_all(const char *prefix, int no_checkout)
905
920
const unsigned char * bisect_rev ;
906
921
char bisect_rev_hex [GIT_SHA1_HEXSZ + 1 ];
907
922
923
+ term_bad = "bad" ;
924
+ term_good = "good" ;
908
925
if (read_bisect_refs ())
909
926
die ("reading bisect refs failed" );
910
927
@@ -926,8 +943,10 @@ int bisect_next_all(const char *prefix, int no_checkout)
926
943
*/
927
944
exit_if_skipped_commits (tried , NULL );
928
945
929
- printf ("%s was both good and bad\n" ,
930
- oid_to_hex (current_bad_oid ));
946
+ printf ("%s was both %s and %s\n" ,
947
+ oid_to_hex (current_bad_oid ),
948
+ term_good ,
949
+ term_bad );
931
950
exit (1 );
932
951
}
933
952
@@ -942,7 +961,8 @@ int bisect_next_all(const char *prefix, int no_checkout)
942
961
943
962
if (!hashcmp (bisect_rev , current_bad_oid -> hash )) {
944
963
exit_if_skipped_commits (tried , current_bad_oid );
945
- printf ("%s is the first bad commit\n" , bisect_rev_hex );
964
+ printf ("%s is the first %s commit\n" , bisect_rev_hex ,
965
+ term_bad );
946
966
show_diff_tree (prefix , revs .commits -> item );
947
967
/* This means the bisection process succeeded. */
948
968
exit (10 );
0 commit comments