From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: gitster@pobox.com
Cc: git@vger.kernel.org, antoine.delaite@ensimag.grenoble-inp.fr,
louis--alexandre.stuber@ensimag.grenoble-inp.fr,
chriscool@tuxfamily.org, thomasxnguy@gmail.com,
valentinduperray@gmail.com,
Louis Stuber <stuberl@ensimag.grenoble-inp.fr>,
Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH v7 5/5] bisect: allows any terms set by user
Date: Tue, 23 Jun 2015 14:54:44 +0200 [thread overview]
Message-ID: <1435064084-5554-6-git-send-email-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <1435064084-5554-1-git-send-email-Matthieu.Moy@imag.fr>
From: Antoine Delaite <antoine.delaite@ensimag.grenoble-inp.fr>
Introduction of the git bisect terms function.
The user can set its own terms.
It will work exactly like before. The terms must be set
before the start.
Signed-off-by: Antoine Delaite <antoine.delaite@ensimag.grenoble-inp.fr>
Signed-off-by: Louis Stuber <stuberl@ensimag.grenoble-inp.fr>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Documentation/git-bisect.txt | 19 +++++++++++++
git-bisect.sh | 68 ++++++++++++++++++++++++++++++++++++++++----
t/t6030-bisect-porcelain.sh | 43 ++++++++++++++++++++++++++++
3 files changed, 125 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index 3c3021a..ef0c03c 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -133,6 +133,25 @@ You must run `git bisect start` without commits as argument and run
`git bisect new <rev>`/`git bisect old <rev>...` after to add the
commits.
+Alternative terms: use your own terms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If the builtins terms bad/good and new/old do not satisfy you, you can
+set your own terms.
+
+------------------------------------------------
+git bisect terms term1 term2
+------------------------------------------------
+
+This command has to be used before a bisection has started.
+The term1 must be associated with the latest revisions and term2 with the
+ancestors of term1.
+
+Only the first bisection following the 'git bisect terms' will use the terms.
+If you mistyped one of the terms you can do again 'git bisect terms term1
+term2'.
+
+
Bisect visualize
~~~~~~~~~~~~~~~~
diff --git a/git-bisect.sh b/git-bisect.sh
index 73763a2..8ef2b94 100644
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-USAGE='[help|start|bad|good|new|old|skip|next|reset|visualize|replay|log|run]'
+USAGE='[help|start|bad|good|new|old|terms|skip|next|reset|visualize|replay|log|run]'
LONG_USAGE='git bisect help
print this long help message.
git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
@@ -11,6 +11,8 @@ git bisect (bad|new) [<rev>]
git bisect (good|old) [<rev>...]
mark <rev>... known-good revisions/
revisions before change in a given property.
+git bisect terms term1 term2
+ set up term1 and term2 as bisection terms.
git bisect skip [(<rev>|<range>)...]
mark <rev>... untestable revisions.
git bisect next
@@ -82,6 +84,14 @@ bisect_start() {
# revision_seen is true if a git bisect start
# has revision as arguments
revision_seen=0
+ # terms_defined is used to detect if the user
+ # defined his own terms with git bisect terms
+ terms_defined=0
+ if test -s "$GIT_DIR/TERMS_DEFINED"
+ then
+ terms_defined=1
+ get_terms
+ fi
if test "z$(git rev-parse --is-bare-repository)" != zfalse
then
mode=--no-checkout
@@ -180,10 +190,14 @@ bisect_start() {
} &&
git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" &&
eval "$eval true" &&
- if test $revision_seen -eq 1 && test ! -s "$GIT_DIR/BISECT_TERMS"
+ if test $revision_seen -eq 1 && test ! -s "$GIT_DIR/BISECT_TERMS" || test $terms_defined -eq 1
then
echo "$NAME_BAD" >"$GIT_DIR/BISECT_TERMS" &&
- echo "$NAME_GOOD" >>"$GIT_DIR/BISECT_TERMS"
+ echo "$NAME_GOOD" >>"$GIT_DIR/BISECT_TERMS" &&
+ if test $terms_defined -eq 1
+ then
+ echo "git bisect terms $NAME_BAD $NAME_GOOD" >>"$GIT_DIR/BISECT_LOG" || exit
+ fi
fi &&
echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
#
@@ -419,6 +433,7 @@ bisect_clean_state() {
rm -f "$GIT_DIR/BISECT_NAMES" &&
rm -f "$GIT_DIR/BISECT_RUN" &&
rm -f "$GIT_DIR/BISECT_TERMS" &&
+ rm -f "$GIT_DIR/TERMS_DEFINED" &&
# Cleanup head-name if it got left by an old version of git-bisect
rm -f "$GIT_DIR/head-name" &&
git update-ref -d --no-deref BISECT_HEAD &&
@@ -447,6 +462,8 @@ bisect_replay () {
eval "$cmd" ;;
"$NAME_GOOD"|"$NAME_BAD"|skip)
bisect_write "$command" "$rev" ;;
+ terms)
+ bisect_terms $rev ;;
*)
die "$(gettext "?? what are you talking about?")" ;;
esac
@@ -531,7 +548,8 @@ get_terms () {
check_and_set_terms () {
cmd="$1"
case "$cmd" in
- bad|good|new|old)
+ skip|start|terms) ;;
+ *)
if test -s "$GIT_DIR/BISECT_TERMS" && test "$cmd" != "$NAME_BAD" && test "$cmd" != "$NAME_GOOD"
then
die "$(eval_gettext "Invalid command: you're currently in a \$NAME_BAD/\$NAME_GOOD bisect.")"
@@ -564,6 +582,44 @@ bisect_voc () {
esac
}
+bisect_terms () {
+ case "$#" in
+ 0)
+ if test -s "$GIT_DIR/BISECT_TERMS"
+ then
+ {
+ read term1
+ read term2
+ }<"$GIT_DIR/BISECT_TERMS"
+ gettextln "Your current terms are $term1 and $term2."
+ else
+ die "$(gettext "No terms defined.")"
+ fi ;;
+ 2)
+ check_term_format refs/bisect/"$1"
+ check_term_format refs/bisect/"$2"
+ if ! test -s "$GIT_DIR/BISECT_START"
+ then
+ echo $1 >"$GIT_DIR/BISECT_TERMS" &&
+ echo $2 >>"$GIT_DIR/BISECT_TERMS" &&
+ echo "1" >"$GIT_DIR/TERMS_DEFINED"
+ echo "git bisect terms $NAME_BAD $NAME_GOOD" >>"$GIT_DIR/BISECT_LOG" || exit
+ else
+ die "$(gettext "A bisection has already started, and you can't change terms in the middle of it.
+Use 'git bisect terms' to see the current terms.
+Otherwise, to start a new bisection with new terms, please use 'git bisect reset' and set the terms before the start")"
+ fi ;;
+ *)
+ usage ;;
+ esac
+}
+
+check_term_format () {
+ arg="$1"
+ git check-ref-format $arg ||
+ die "$(eval_gettext "'\$arg' is not a valid term")"
+}
+
case "$#" in
0)
usage ;;
@@ -576,7 +632,7 @@ case "$#" in
git bisect -h ;;
start)
bisect_start "$@" ;;
- bad|good|new|old)
+ bad|good|new|old|"$NAME_BAD"|"$NAME_GOOD")
bisect_state "$cmd" "$@" ;;
skip)
bisect_skip "$@" ;;
@@ -593,6 +649,8 @@ case "$#" in
bisect_log ;;
run)
bisect_run "$@" ;;
+ terms)
+ bisect_terms "$@" ;;
*)
usage ;;
esac
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 983c503..289dbb0 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -797,4 +797,47 @@ test_expect_success 'bisect cannot mix old/new and good/bad' '
test_must_fail git bisect old $HASH1
'
+test_expect_success 'bisect start with one term1 and term2' '
+ git bisect reset &&
+ git bisect terms term1 term2 &&
+ git bisect start &&
+ git bisect term2 $HASH1 &&
+ git bisect term1 $HASH4 &&
+ git bisect term1 &&
+ git bisect term1 >bisect_result &&
+ grep "$HASH2 is the first term1 commit" bisect_result &&
+ git bisect log >log_to_replay.txt &&
+ git bisect reset
+'
+
+test_expect_success 'bisect replay with term1 and term2' '
+ git bisect replay log_to_replay.txt >bisect_result &&
+ grep "$HASH2 is the first term1 commit" bisect_result &&
+ git bisect reset
+'
+
+test_expect_success 'bisect start term1 term2' '
+ git bisect reset &&
+ git bisect terms term1 term2 &&
+ git bisect start $HASH4 $HASH1 &&
+ git bisect term1 &&
+ git bisect term1 >bisect_result &&
+ grep "$HASH2 is the first term1 commit" bisect_result &&
+ git bisect log >log_to_replay.txt &&
+ git bisect reset
+'
+
+test_expect_success 'bisect cannot mix terms' '
+ git bisect reset &&
+ git bisect terms a b &&
+ git bisect terms term1 term2 &&
+ git bisect start $HASH4 $HASH1 &&
+ test_must_fail git bisect a &&
+ test_must_fail git bisect b &&
+ test_must_fail git bisect bad &&
+ test_must_fail git bisect good &&
+ test_must_fail git bisect new &&
+ test_must_fail git bisect old
+'
+
test_done
--
2.4.4.414.ge37915c
next prev parent reply other threads:[~2015-06-23 17:30 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 21:00 [PATCH v3 1/6] bisect: correction of typo Antoine Delaite
2015-06-22 21:00 ` [PATCH v3 2/6] bisect: replace hardcoded "bad|good" by variables Antoine Delaite
2015-06-22 21:00 ` [PATCH v3 3/6] bisect: simplify the addition of new bisect terms Antoine Delaite
2015-06-22 21:00 ` [PATCH v3 4/6] bisect: add the terms old/new Antoine Delaite
2015-06-22 21:00 ` [PATCH v3 5/6] revision: fix rev-list --bisect in old/new mode Antoine Delaite
2015-06-22 21:00 ` [PATCH v3 6/6] bisect: allows any terms set by user Antoine Delaite
2015-06-23 12:54 ` [PATCH v7 0/5] git bisect old/new Matthieu Moy
2015-06-23 12:54 ` [PATCH v7 1/5] bisect: correction of typo Matthieu Moy
2015-06-23 12:54 ` [PATCH v7 2/5] bisect: replace hardcoded "bad|good" by variables Matthieu Moy
2015-06-23 12:54 ` [PATCH v7 3/5] bisect: simplify the addition of new bisect terms Matthieu Moy
2015-06-23 17:49 ` Eric Sunshine
2015-06-23 18:18 ` Matthieu Moy
2015-06-23 12:54 ` [PATCH v7 4/5] bisect: add the terms old/new Matthieu Moy
2015-06-23 19:27 ` Remi Galan Alfonso
2015-06-23 20:26 ` Matthieu Moy
2015-06-23 12:54 ` Matthieu Moy [this message]
2015-06-23 18:48 ` [PATCH v7 5/5] bisect: allows any terms set by user Junio C Hamano
2015-06-23 19:04 ` [PATCH v7 0/5] git bisect old/new Junio C Hamano
2015-06-23 20:16 ` Matthieu Moy
2015-06-23 20:34 ` Junio C Hamano
2015-06-24 15:17 ` [PATCH v8 0/5] Bisect terms Matthieu Moy
2015-06-24 15:17 ` [PATCH v8 1/5] bisect: correction of typo Matthieu Moy
2015-06-24 15:17 ` [PATCH v8 2/5] bisect: replace hardcoded "bad|good" by variables Matthieu Moy
2015-06-24 15:17 ` [PATCH v8 3/5] bisect: simplify the addition of new bisect terms Matthieu Moy
2015-06-24 17:29 ` Junio C Hamano
2015-06-24 21:26 ` Matthieu Moy
2015-06-24 15:17 ` [PATCH v8 4/5] bisect: add the terms old/new Matthieu Moy
2015-06-24 15:17 ` [PATCH v8 5/5] bisect: allow any terms set by user Matthieu Moy
2015-06-24 17:46 ` Junio C Hamano
2015-06-24 21:23 ` Matthieu Moy
2015-06-24 17:27 ` [PATCH v8 0/5] Bisect terms Junio C Hamano
2015-06-24 19:41 ` Junio C Hamano
2015-06-25 18:50 ` [PATCH v9 0/5] bisect terms Matthieu Moy
2015-06-25 18:50 ` [PATCH v9 1/5] bisect: correction of typo Matthieu Moy
2015-06-25 18:50 ` [PATCH v9 2/5] bisect: replace hardcoded "bad|good" by variables Matthieu Moy
2015-06-25 18:50 ` [PATCH v9 3/5] bisect: simplify the addition of new bisect terms Matthieu Moy
2015-06-25 18:50 ` [PATCH v9 4/5] bisect: add the terms old/new Matthieu Moy
2015-06-26 4:11 ` Christian Couder
2015-06-26 7:00 ` Matthieu Moy
2015-06-25 18:50 ` [PATCH v9 5/5] bisect: allow any terms set by user Matthieu Moy
2015-06-25 21:41 ` Junio C Hamano
2015-06-25 22:10 ` Junio C Hamano
2015-06-26 8:20 ` Matthieu Moy
2015-06-26 16:48 ` Junio C Hamano
2015-06-26 17:08 ` Matthieu Moy
2015-06-26 18:08 ` Junio C Hamano
2015-06-26 20:18 ` Matthieu Moy
2015-06-26 6:59 ` Matthieu Moy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435064084-5554-6-git-send-email-Matthieu.Moy@imag.fr \
--to=matthieu.moy@imag.fr \
--cc=antoine.delaite@ensimag.grenoble-inp.fr \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=louis--alexandre.stuber@ensimag.grenoble-inp.fr \
--cc=stuberl@ensimag.grenoble-inp.fr \
--cc=thomasxnguy@gmail.com \
--cc=valentinduperray@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).