diff --git a/find_bisect_testcases.sh b/find_bisect_testcases.sh new file mode 100755 index 00000000000000..d1cee54022e479 --- /dev/null +++ b/find_bisect_testcases.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# Find test cases candidates when bisect goes through +# many merge cases + +NB_COMMITS="$1" + +COUNT_LOG="my_count_log.txt" +SCRIPT_DIR="$(pwd)" + +touch "$COUNT_LOG" + +while : +do + randnum=$(eval "shuf -i 1-$NB_COMMITS -n 2") + commit1="$(echo "$randnum" | tail -1)" + commit2="$(echo "$randnum" | head -1)" + hash1=$(eval "git rev-list master -$NB_COMMITS | sed -n $commit1""p") + hash2=$(eval "git rev-list master -$NB_COMMITS | sed -n $commit2""p") + + mb_num=$("$SCRIPT_DIR/merge_bases_count.sh" "$hash1" "$hash2") + if test "$mb_num" -gt 2 + then + echo "$hash1 $hash2 : $mb_num" >> "$COUNT_LOG" + fi +done diff --git a/merge_bases_count.sh b/merge_bases_count.sh index 8852675d7a3808..46d3d438d968f6 100755 --- a/merge_bases_count.sh +++ b/merge_bases_count.sh @@ -2,23 +2,27 @@ # # Count merge bases with bisect -BISECT_LOG="my_bisect_log.txt" -# export LC_ALL=C -touch $BISECT_LOG +trap "git bisect reset" INT + +hash1="$1" +hash2="$2" -hash1=$1 -hash2=$2 +BISECT_LOG="my_bisect_log.txt" -git bisect start $hash1 $hash2 > $BISECT_LOG +git bisect start "$hash1" "$hash2" --no-checkout > "$BISECT_LOG" count=0 -while grep -q "merge base must be tested" $BISECT_LOG +if grep -q "Some good revs are not ancestors of the bad rev" "$BISECT_LOG" +then + return 0 +fi + +while grep -q "merge base must be tested" "$BISECT_LOG" do - git bisect good > $BISECT_LOG + git bisect good > "$BISECT_LOG" count=$(($count + 1)) done -echo "Merge bases: $count" +echo "$count" -git bisect reset -rm $BISECT_LOG +rm "$BISECT_LOG" diff --git a/remove_many_parents.sh b/remove_many_parents.sh index f778d09f16a54f..131de7b6588ae0 100755 --- a/remove_many_parents.sh +++ b/remove_many_parents.sh @@ -16,7 +16,8 @@ while read -r commit do echo "Processing $commit" GIT_EDITOR="$SCRIPT_DIR/remove_parent.sh" git replace --edit "$commit" - test $("$SCRIPT_DIR/merge_bases_count.sh" "$hash1" "$hash2") -eq "$nb_mb" || + mb_counts=$("$SCRIPT_DIR/merge_bases_count.sh" "$hash1" "$hash2") + test "$mb_counts" = "$nb_mb" || git replace -d "$commit" done <"$TMP_MERGE_COMMITS"