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, Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH v10 7/7] bisect: allow any terms set by user
Date: Fri, 26 Jun 2015 18:58:16 +0200 [thread overview]
Message-ID: <1435337896-20709-8-git-send-email-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <1435337896-20709-1-git-send-email-Matthieu.Moy@imag.fr>
From: Antoine Delaite <antoine.delaite@ensimag.grenoble-inp.fr>
Introduction of the git bisect terms command. The user can set his 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 | 36 +++++++++++++++++++-
git-bisect.sh | 65 +++++++++++++++++++++++++++++++++---
t/t6030-bisect-porcelain.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 175 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index 24171a5..b1ef41c 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -19,6 +19,7 @@ on the subcommand:
git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<paths>...]
git bisect (bad|new) [<rev>]
git bisect (good|old) [<rev>...]
+ git bisect terms <term-old> <term-new>
git bisect skip [(<rev>|<range>)...]
git bisect reset [<commit>]
git bisect visualize
@@ -40,7 +41,7 @@ In fact, `git bisect` can be used to find the commit that changed
*any* property of your project; e.g., the commit that fixed a bug, or
the commit that caused a benchmark's performance to improve. To
support this more general usage, the terms "old" and "new" can be used
-in place of "good" and "bad". See
+in place of "good" and "bad", or you can choose your own terms. See
section "Alternate terms" below for more information.
Basic bisect commands: start, bad, good
@@ -157,6 +158,31 @@ git bisect new [<rev>...]
to indicate that it was after.
+If you would like to use your own terms instead of "bad"/"good" or
+"new"/"old", you can choose any names you like by typing
+
+------------------------------------------------
+git bisect terms <term-new> <term-old>
+------------------------------------------------
+
+before starting a bisection session. For example, if you are looking
+for a commit that introduced a performance regression, you might use
+
+------------------------------------------------
+git bisect terms slow fast
+------------------------------------------------
+
+Or if you are looking for the commit that fixed a bug, you might use
+
+------------------------------------------------
+git bisect terms fixed broken
+------------------------------------------------
+
+Only the bisection following the `git bisect terms` will use the
+terms. If you mistyped one of the terms you can do again `git bisect
+terms <term-new> <term-old>`, but that is possible only before you
+start the bisection.
+
Bisect visualize
~~~~~~~~~~~~~~~~
@@ -440,6 +466,14 @@ $ git bisect start
$ git bisect new HEAD # current commit is marked as new
$ git bisect old HEAD~10 # the tenth commit from now is marked as old
------------
++
+or:
+------------
+$ git bisect terms fixed broken
+$ git bisect start
+$ git bisect fixed
+$ git bisect broken HEAD~10
+------------
Getting help
~~~~~~~~~~~~
diff --git a/git-bisect.sh b/git-bisect.sh
index 5769eaf..64ea122 100755
--- 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 <term-new> <term-old>
+ set up <term-new> and <term-old> as terms (default: bad, good)
git bisect skip [(<rev>|<range>)...]
mark <rev>... untestable revisions.
git bisect next
@@ -80,6 +82,16 @@ bisect_start() {
bad_seen=0
eval=''
must_write_terms=0
+ must_log_terms=0
+ if test -s "$GIT_DIR/BISECT_TERMS"
+ then
+ # We're going to restart from a clean state and the
+ # file will be deleted. Record the old state in
+ # variables and restore it below.
+ must_write_terms=1
+ must_log_terms=1
+ get_terms
+ fi
if test "z$(git rev-parse --is-bare-repository)" != zfalse
then
mode=--no-checkout
@@ -185,7 +197,12 @@ bisect_start() {
eval "$eval true" &&
if test $must_write_terms -eq 1
then
- write_terms "$NAME_BAD" "$NAME_GOOD"
+ write_terms "$NAME_BAD" "$NAME_GOOD" &&
+ if test $must_log_terms -eq 1
+ then
+ echo "git bisect terms $NAME_BAD $NAME_GOOD" \
+ >>"$GIT_DIR/BISECT_LOG"
+ fi
fi &&
echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
#
@@ -449,6 +466,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
@@ -533,13 +552,22 @@ get_terms () {
write_terms () {
NAME_BAD=$1
NAME_GOOD=$2
+ check_term_format "$NAME_BAD"
+ check_term_format "$NAME_GOOD"
printf '%s\n%s\n' "$NAME_BAD" "$NAME_GOOD" >"$GIT_DIR/BISECT_TERMS"
}
+check_term_format () {
+ term=$1
+ git check-ref-format refs/bisect/"$term" ||
+ die "$(eval_gettext "'\$term' is not a valid term")"
+}
+
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.")"
@@ -568,6 +596,33 @@ bisect_voc () {
esac
}
+bisect_terms () {
+ case "$#" in
+ 0)
+ if test -s "$GIT_DIR/BISECT_TERMS"
+ then
+ get_terms
+ gettextln "Your current terms are $NAME_GOOD for the old state
+and $NAME_BAD for the new state."
+ else
+ die "$(gettext "No terms defined.")"
+ fi ;;
+ 2)
+ if ! test -s "$GIT_DIR/BISECT_START"
+ then
+ write_terms "$1" "$2"
+ 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
+}
+
case "$#" in
0)
usage ;;
@@ -580,7 +635,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 "$@" ;;
@@ -597,6 +652,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..83254d2 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -797,4 +797,83 @@ 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_expect_success 'bisect terms rejects invalid terms' '
+ git bisect reset &&
+ test_must_fail git bisect terms invalid..term term2 &&
+ test_must_fail git bisect terms term1 invalid..term &&
+ test_path_is_missing .git/BISECT_TERMS
+'
+
+test_expect_success 'bisect terms needs 0 or 2 arguments' '
+ git bisect reset &&
+ test_must_fail git bisect terms only-one &&
+ test_must_fail git bisect terms 1 2 3 &&
+ test_must_fail git bisect terms 2>actual
+'
+
+test_expect_success 'bisect terms does store terms' '
+ echo "No terms defined." >expected &&
+ test_cmp expected actual &&
+ git bisect terms one two &&
+ git bisect terms >actual &&
+ cat <<-EOF >expected &&
+ Your current terms are two for the old state
+ and one for the new state.
+ EOF
+ test_cmp expected actual'
+
+test_expect_success 'bisect start keeps defined terms' '
+ git bisect terms one two &&
+ git bisect start &&
+ git bisect terms >actual &&
+ cat <<-EOF >expected &&
+ Your current terms are two for the old state
+ and one for the new state.
+ EOF
+ test_cmp expected actual
+'
+
test_done
--
2.4.4.414.g318df7a.dirty
next prev parent reply other threads:[~2015-06-26 16:58 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 16:58 [PATCH v10 0/7] bisect terms Matthieu Moy
2015-06-26 16:58 ` [PATCH v10 1/7] bisect: correction of typo Matthieu Moy
2015-06-26 16:58 ` [PATCH v10 2/7] Documentation/bisect: move getting help section to the end Matthieu Moy
2015-06-26 16:58 ` [PATCH v10 3/7] Documentation/bisect: revise overall content Matthieu Moy
2015-06-26 16:58 ` [PATCH v10 4/7] bisect: replace hardcoded "bad|good" by variables Matthieu Moy
2015-06-26 16:58 ` [PATCH v10 5/7] bisect: simplify the addition of new bisect terms Matthieu Moy
2015-06-26 19:22 ` Christian Couder
2015-06-26 20:32 ` [PATCH v10.1 " Matthieu Moy
2015-06-26 21:27 ` Junio C Hamano
2015-06-26 21:37 ` Matthieu Moy
2015-06-26 16:58 ` [PATCH v10 6/7] bisect: add the terms old/new Matthieu Moy
2015-06-26 16:58 ` Matthieu Moy [this message]
2015-06-26 18:16 ` [PATCH v10 7/7] bisect: allow any terms set by user Junio C Hamano
2015-06-26 20:39 ` [PATCH v10.1 " Matthieu Moy
2015-06-26 22:25 ` Junio C Hamano
2015-06-27 4:10 ` Christian Couder
2015-06-27 4:25 ` Junio C Hamano
2015-06-27 4:51 ` Christian Couder
2015-06-27 8:32 ` Matthieu Moy
2015-06-27 18:41 ` Junio C Hamano
2015-06-29 9:51 ` Matthieu Moy
2015-06-29 16:35 ` Junio C Hamano
2015-06-28 5:51 ` Michael Haggerty
2015-06-28 6:15 ` Junio C Hamano
2015-06-28 6:46 ` Michael Haggerty
2015-06-28 7:32 ` Junio C Hamano
2015-06-28 11:31 ` Michael Haggerty
2015-06-28 18:51 ` Junio C Hamano
2015-06-29 7:27 ` Matthieu Moy
2015-06-29 16:40 ` Junio C Hamano
2015-06-29 5:08 ` Christian Couder
2015-06-29 7:34 ` Matthieu Moy
2015-06-29 8:08 ` Christian Couder
2015-06-29 9:32 ` Matthieu Moy
2015-06-29 10:55 ` Christian Couder
2015-06-29 15:19 ` Matthieu Moy
2015-06-26 20:29 ` [PATCH v10 " Christian Couder
2015-06-26 20: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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435337896-20709-8-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=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.
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 NNTP newsgroup(s).