@@ -24,6 +24,7 @@ struct argv_array {
24
24
25
25
static const char * argv_checkout [] = {"checkout" , "-q" , NULL , "--" , NULL };
26
26
static const char * argv_show_branch [] = {"show-branch" , NULL , NULL };
27
+ static const char * argv_update_ref [] = {"update-ref" , "--no-deref" , "BISECT_HEAD" , NULL , NULL };
27
28
28
29
/* bits #0-15 in revision.h */
29
30
@@ -707,16 +708,23 @@ static void mark_expected_rev(char *bisect_rev_hex)
707
708
die ("closing file %s: %s" , filename , strerror (errno ));
708
709
}
709
710
710
- static int bisect_checkout (char * bisect_rev_hex )
711
+ static int bisect_checkout (char * bisect_rev_hex , int no_checkout )
711
712
{
712
713
int res ;
713
714
714
715
mark_expected_rev (bisect_rev_hex );
715
716
716
717
argv_checkout [2 ] = bisect_rev_hex ;
717
- res = run_command_v_opt (argv_checkout , RUN_GIT_CMD );
718
- if (res )
719
- exit (res );
718
+ if (no_checkout ) {
719
+ argv_update_ref [3 ] = bisect_rev_hex ;
720
+ if (run_command_v_opt (argv_update_ref , RUN_GIT_CMD ))
721
+ die ("update-ref --no-deref HEAD failed on %s" ,
722
+ bisect_rev_hex );
723
+ } else {
724
+ res = run_command_v_opt (argv_checkout , RUN_GIT_CMD );
725
+ if (res )
726
+ exit (res );
727
+ }
720
728
721
729
argv_show_branch [1 ] = bisect_rev_hex ;
722
730
return run_command_v_opt (argv_show_branch , RUN_GIT_CMD );
@@ -788,7 +796,7 @@ static void handle_skipped_merge_base(const unsigned char *mb)
788
796
* - If one is "skipped", we can't know but we should warn.
789
797
* - If we don't know, we should check it out and ask the user to test.
790
798
*/
791
- static void check_merge_bases (void )
799
+ static void check_merge_bases (int no_checkout )
792
800
{
793
801
struct commit_list * result ;
794
802
int rev_nr ;
@@ -806,7 +814,7 @@ static void check_merge_bases(void)
806
814
handle_skipped_merge_base (mb );
807
815
} else {
808
816
printf ("Bisecting: a merge base must be tested\n" );
809
- exit (bisect_checkout (sha1_to_hex (mb )));
817
+ exit (bisect_checkout (sha1_to_hex (mb ), no_checkout ));
810
818
}
811
819
}
812
820
@@ -849,7 +857,7 @@ static int check_ancestors(const char *prefix)
849
857
* If a merge base must be tested by the user, its source code will be
850
858
* checked out to be tested by the user and we will exit.
851
859
*/
852
- static void check_good_are_ancestors_of_bad (const char * prefix )
860
+ static void check_good_are_ancestors_of_bad (const char * prefix , int no_checkout )
853
861
{
854
862
const char * filename = git_path ("BISECT_ANCESTORS_OK" );
855
863
struct stat st ;
@@ -868,7 +876,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix)
868
876
869
877
/* Check if all good revs are ancestor of the bad rev. */
870
878
if (check_ancestors (prefix ))
871
- check_merge_bases ();
879
+ check_merge_bases (no_checkout );
872
880
873
881
/* Create file BISECT_ANCESTORS_OK. */
874
882
fd = open (filename , O_CREAT | O_TRUNC | O_WRONLY , 0600 );
@@ -908,8 +916,11 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
908
916
* We use the convention that exiting with an exit code 10 means that
909
917
* the bisection process finished successfully.
910
918
* In this case the calling shell script should exit 0.
919
+ *
920
+ * If no_checkout is non-zero, the bisection process does not
921
+ * checkout the trial commit but instead simply updates BISECT_HEAD.
911
922
*/
912
- int bisect_next_all (const char * prefix )
923
+ int bisect_next_all (const char * prefix , int no_checkout )
913
924
{
914
925
struct rev_info revs ;
915
926
struct commit_list * tried ;
@@ -920,7 +931,7 @@ int bisect_next_all(const char *prefix)
920
931
if (read_bisect_refs ())
921
932
die ("reading bisect refs failed" );
922
933
923
- check_good_are_ancestors_of_bad (prefix );
934
+ check_good_are_ancestors_of_bad (prefix , no_checkout );
924
935
925
936
bisect_rev_setup (& revs , prefix , "%s" , "^%s" , 1 );
926
937
revs .limited = 1 ;
@@ -966,6 +977,6 @@ int bisect_next_all(const char *prefix)
966
977
"(roughly %d step%s)\n" , nr , (nr == 1 ? "" : "s" ),
967
978
steps , (steps == 1 ? "" : "s" ));
968
979
969
- return bisect_checkout (bisect_rev_hex );
980
+ return bisect_checkout (bisect_rev_hex , no_checkout );
970
981
}
971
982
0 commit comments