[PATCH 9/9 v5] bisect: add "--no-replace" option to bisect without using replace refs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
---
 Documentation/git-bisect.txt |    6 +++++-
 git-bisect.sh                |   26 ++++++++++++++++++++------
 t/t6035-bisect-replace.sh    |   10 ++++++++++
 3 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index be7518c..8d892bb 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -16,7 +16,7 @@ The command takes various subcommands, and different options depending
 on the subcommand:
 
  git bisect help
- git bisect start [<bad> [<good>...]] [--] [<paths>...]
+ git bisect start [--no-replace] [<bad> [<good>...]] [--] [<paths>...]
  git bisect bad [<rev>]
  git bisect good [<rev>...]
  git bisect skip [<rev>...]
@@ -247,6 +247,10 @@ As the refs created by "git bisect replace" can be shared between
 developers, this feature might be especially usefull on big projects
 where many people often bisect the same code base.
 
+If you give the `--no-replace` to "git bisect start", then the
+"refs/replace/bisect/*" refs will not be used for the bisection you
+start.
+
 Bisect run
 ~~~~~~~~~~
 
diff --git a/git-bisect.sh b/git-bisect.sh
index c8d5905..7d09bb0 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -3,7 +3,7 @@
 USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|replace|run]'
 LONG_USAGE='git bisect help
         print this long help message.
-git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
+git bisect start [--no-replace] [<bad> [<good>...]] [--] [<pathspec>...]
         reset bisect state and start bisection.
 git bisect bad [<rev>]
         mark <rev> a known-bad revision.
@@ -119,6 +119,10 @@ bisect_start() {
 		shift
 		break
 		;;
+	    --no-replace)
+		shift
+		touch "$GIT_DIR/BISECT_NO_REPLACE"
+		;;
 	    *)
 		rev=$(git rev-parse -q --verify "$arg^{commit}") || {
 		    test $has_double_dash -eq 1 &&
@@ -386,6 +390,16 @@ We continue anyway.
 EOF
 }
 
+replace_option() {
+	test -f "$GIT_DIR/BISECT_NO_REPLACE" ||
+		echo "--bisect-replace"
+}
+
+no_replace_option() {
+	test ! -f "$GIT_DIR/BISECT_NO_REPLACE" ||
+		echo "--no-bisect-replace"
+}
+
 #
 # "check_merge_bases" checks that merge bases are not "bad".
 #
@@ -401,7 +415,7 @@ check_merge_bases() {
 	_bad="$1"
 	_good="$2"
 	_skip="$3"
-	for _mb in $(git merge-base --all --bisect-replace $_bad $_good)
+	for _mb in $(git merge-base --all $(replace_option) $_bad $_good)
 	do
 		if is_among "$_mb" "$_good"; then
 			continue
@@ -436,7 +450,7 @@ check_good_are_ancestors_of_bad() {
 	# Bisecting with no good rev is ok
 	test -z "$_good" && return
 
-	_side=$(git rev-list --bisect-replace $_good ^$_bad)
+	_side=$(git rev-list $(replace_option) $_good ^$_bad)
 	if test -n "$_side"; then
 		# Return if a checkout was done
 		check_merge_bases "$_bad" "$_good" "$_skip" || return
@@ -465,9 +479,8 @@ bisect_next() {
 	test "$?" -eq "1" && return
 
 	# Get bisection information
-	BISECT_OPT=''
-	test -n "$skip" && BISECT_OPT='--bisect-all'
-	eval="git rev-list --bisect-vars $BISECT_OPT $good $bad --" &&
+	BISECT_OPTS="$(no_replace_option) --bisect-vars ${skip:+--bisect-all}"
+	eval="git rev-list $BISECT_OPTS $good $bad --" &&
 	eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
 	eval=$(filter_skipped "$eval" "$skip") &&
 	eval "$eval" || exit
@@ -534,6 +547,7 @@ bisect_clean_state() {
 	do
 		git update-ref -d $ref $hash || exit
 	done
+	rm -f "$GIT_DIR/BISECT_NO_REPLACE" &&
 	rm -f "$GIT_DIR/BISECT_EXPECTED_REV" &&
 	rm -f "$GIT_DIR/BISECT_ANCESTORS_OK" &&
 	rm -f "$GIT_DIR/BISECT_LOG" &&
diff --git a/t/t6035-bisect-replace.sh b/t/t6035-bisect-replace.sh
index f22a2e5..b9cc739 100755
--- a/t/t6035-bisect-replace.sh
+++ b/t/t6035-bisect-replace.sh
@@ -164,6 +164,16 @@ test_expect_success '"git rev-list --no-bisect-replace" works' '
      grep $HASH4 rev_list.txt
 '
 
+test_expect_success 'git bisect works with --no-replace' '
+     git bisect start --no-replace $HASH5 $HASH1 &&
+     test "$(git rev-parse --verify HEAD)" = "$HASH3" &&
+     git bisect good &&
+     test "$(git rev-parse --verify HEAD)" = "$HASH4" &&
+     git bisect bad > my_bisect_log.txt &&
+     grep "$HASH4 is first bad commit" my_bisect_log.txt &&
+     git bisect reset
+'
+
 #
 #
 test_done
-- 
1.5.6.1.1657.g6a50

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux