From: Antoine Delaite <antoine.delaite@ensimag.grenoble-inp.fr>
To: git@vger.kernel.org
Cc: antoine.delaite@ensimag.grenoble-inp.fr,
louis--alexandre.stuber@ensimag.grenoble-inp.fr,
Matthieu.Moy@grenoble-inp.fr, chriscool@tuxfamily.org,
thomasxnguy@gmail.com, valentinduperray@gmail.com
Subject: [PATCH v3 3/6] bisect: simplify the addition of new bisect terms
Date: Mon, 22 Jun 2015 23:00:33 +0200 [thread overview]
Message-ID: <1435006836-18182-3-git-send-email-antoine.delaite@ensimag.grenoble-inp.fr> (raw)
In-Reply-To: <1435006836-18182-1-git-send-email-antoine.delaite@ensimag.grenoble-inp.fr>
We create a file BISECT_TERMS in the repository .git to be read during a
bisection. The fonctions to be changed if we add new terms are quite
few.
In git-bisect.sh :
check_and_set_terms
bisect_voc
Signed-off-by: Antoine Delaite <antoine.delaite@ensimag.grenoble-inp.fr>
Signed-off-by: Louis Stuber <stuberl@ensimag.grenoble-inp.fr>
Signed-off-by: Valentin Duperray <Valentin.Duperray@ensimag.imag.fr>
Signed-off-by: Franck Jonas <Franck.Jonas@ensimag.imag.fr>
Signed-off-by: Lucien Kong <Lucien.Kong@ensimag.imag.fr>
Signed-off-by: Thomas Nguy <Thomas.Nguy@ensimag.imag.fr>
Signed-off-by: Huynh Khoi Nguyen Nguyen <Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
---
bisect.c | 38 ++++++++++++++++++++++++++++--
git-bisect.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 98 insertions(+), 10 deletions(-)
diff --git a/bisect.c b/bisect.c
index cda30fa..2fc8a78 100644
--- a/bisect.c
+++ b/bisect.c
@@ -747,7 +747,10 @@ static void handle_bad_merge_base(void)
"between %s and [%s].\n",
bad_hex, bad_hex, good_hex);
} else {
- die("BUG: terms %s/%s not managed", name_bad, name_good);
+ fprintf(stderr, "The merge base %s is %s.\n"
+ "This means the first commit marked %s is "
+ "between %s and [%s].\n",
+ bad_hex, name_bad, name_bad, bad_hex, good_hex);
}
exit(3);
}
@@ -902,6 +905,36 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
}
/*
+ * The terms used for this bisect session are stored in BISECT_TERMS.
+ * We read them and store them to adapt the messages accordingly.
+ * Default is bad/good.
+ */
+void read_bisect_terms(const char **read_bad, const char **read_good)
+{
+ struct strbuf str = STRBUF_INIT;
+ const char *filename = git_path("BISECT_TERMS");
+ FILE *fp = fopen(filename, "r");
+
+ if (!fp) {
+ if (errno==2) {
+ *read_bad = "bad";
+ *read_good = "good";
+ return;
+ } else {
+ die("could not read file '%s': %s", filename,
+ strerror(errno));
+ }
+ } else {
+ strbuf_getline(&str, fp, '\n');
+ *read_bad = strbuf_detach(&str, NULL);
+ strbuf_getline(&str, fp, '\n');
+ *read_good = strbuf_detach(&str, NULL);
+ }
+ strbuf_release(&str);
+ fclose(fp);
+}
+
+/*
* We use the convention that exiting with an exit code 10 means that
* the bisection process finished successfully.
* In this case the calling shell script should exit 0.
@@ -917,8 +950,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
const unsigned char *bisect_rev;
char bisect_rev_hex[GIT_SHA1_HEXSZ + 1];
- name_bad="bad";
- name_good="good";
+ read_bisect_terms(&name_bad, &name_good);
if (read_bisect_refs())
die("reading bisect refs failed");
diff --git a/git-bisect.sh b/git-bisect.sh
index ce6412f..55b9ebd 100644
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -77,6 +77,9 @@ bisect_start() {
orig_args=$(git rev-parse --sq-quote "$@")
bad_seen=0
eval=''
+ # revision_seen is true if a git bisect start
+ # has revision as arguments
+ revision_seen=0
if test "z$(git rev-parse --is-bare-repository)" != zfalse
then
mode=--no-checkout
@@ -101,6 +104,9 @@ bisect_start() {
die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
break
}
+
+ revision_seen=1
+
case $bad_seen in
0) state=$NAME_BAD ; bad_seen=1 ;;
*) state=$NAME_GOOD ;;
@@ -172,6 +178,11 @@ 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"
+ then
+ echo "$NAME_BAD" >"$GIT_DIR/BISECT_TERMS" &&
+ echo "$NAME_GOOD" >>"$GIT_DIR/BISECT_TERMS"
+ fi &&
echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
#
# Check if we can proceed to the next bisect state.
@@ -232,6 +243,7 @@ bisect_skip() {
bisect_state() {
bisect_autostart
state=$1
+ check_and_set_terms $state
case "$#,$state" in
0,*)
die "$(gettext "Please call 'bisect_state' with at least one argument.")" ;;
@@ -291,15 +303,17 @@ bisect_next_check() {
: bisect without $NAME_GOOD...
;;
*)
-
+ bad_syn=$(bisect_voc bad)
+ good_syn=$(bisect_voc good)
if test -s "$GIT_DIR/BISECT_START"
then
- gettextln "You need to give me at least one good and one bad revision.
-(You can use \"git bisect bad\" and \"git bisect good\" for that.)" >&2
+
+ eval_gettextln "You need to give me at least one \$bad_syn and one \$good_syn revision.
+(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
else
- gettextln "You need to start by \"git bisect start\".
-You then need to give me at least one good and one bad revision.
-(You can use \"git bisect bad\" and \"git bisect good\" for that.)" >&2
+ eval_gettextln "You need to start by \"git bisect start\".
+You then need to give me at least one \$good_syn and one \$bad_syn revision.
+(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
fi
exit 1 ;;
esac
@@ -402,6 +416,7 @@ bisect_clean_state() {
rm -f "$GIT_DIR/BISECT_LOG" &&
rm -f "$GIT_DIR/BISECT_NAMES" &&
rm -f "$GIT_DIR/BISECT_RUN" &&
+ rm -f "$GIT_DIR/BISECT_TERMS" &&
# 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 &&
@@ -422,11 +437,13 @@ bisect_replay () {
rev="$command"
command="$bisect"
fi
+ get_terms
+ check_and_set_terms "$command"
case "$command" in
start)
cmd="bisect_start $rev"
eval "$cmd" ;;
- $NAME_GOOD|$NAME_BAD|skip)
+ "$NAME_GOOD"|"$NAME_BAD"|skip)
bisect_write "$command" "$rev" ;;
*)
die "$(gettext "?? what are you talking about?")" ;;
@@ -499,11 +516,50 @@ bisect_log () {
cat "$GIT_DIR/BISECT_LOG"
}
+get_terms () {
+ if test -s "$GIT_DIR/BISECT_TERMS"
+ then
+ {
+ read NAME_BAD
+ read NAME_GOOD
+ }<"$GIT_DIR/BISECT_TERMS"
+ fi
+}
+
+check_and_set_terms () {
+ cmd="$1"
+ case "$cmd" in
+ bad|good)
+ 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.")"
+ fi
+ case "$cmd" in
+ bad|good)
+ if ! test -s "$GIT_DIR/BISECT_TERMS"
+ then
+ echo "bad" >"$GIT_DIR/BISECT_TERMS" &&
+ echo "good" >>"$GIT_DIR/BISECT_TERMS"
+ fi
+ NAME_BAD="bad"
+ NAME_GOOD="good" ;;
+ esac ;;
+ esac
+}
+
+bisect_voc () {
+ case "$1" in
+ bad) echo "bad" ;;
+ good) echo "good" ;;
+ esac
+}
+
case "$#" in
0)
usage ;;
*)
cmd="$1"
+ get_terms
shift
case "$cmd" in
help)
--
1.7.1
next prev parent reply other threads:[~2015-06-22 21:01 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 ` Antoine Delaite [this message]
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 ` [PATCH v7 5/5] bisect: allows any terms set by user Matthieu Moy
2015-06-23 18:48 ` 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=1435006836-18182-3-git-send-email-antoine.delaite@ensimag.grenoble-inp.fr \
--to=antoine.delaite@ensimag.grenoble-inp.fr \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--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.
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).