* [PATCH v15 1/7] bisect: move argument parsing before state modification.
2011-08-03 15:03 [PATCH v15 0/7] bisect: Add support for --no-checkout option Jon Seymour
@ 2011-08-03 15:03 ` Jon Seymour
2011-08-03 15:03 ` [PATCH v15 2/7] bisect: use && to connect statements that are deferred with eval Jon Seymour
` (5 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Jon Seymour @ 2011-08-03 15:03 UTC (permalink / raw)
To: git; +Cc: chriscool, gitster, j6t, jnareb, Jon Seymour
Currently 'git bisect start' modifies some state prior to checking
that its arguments are valid.
This change moves argument validation before state modification
with the effect that state modification does not occur
unless argument validations succeeds.
An existing test is changed to check that new bisect state
is not created if arguments are invalid.
A new test is added to check that existing bisect state
is not modified if arguments are invalid.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
git-bisect.sh | 66 +++++++++++++++++++++---------------------
t/t6030-bisect-porcelain.sh | 14 +++++++--
2 files changed, 44 insertions(+), 36 deletions(-)
diff --git a/git-bisect.sh b/git-bisect.sh
index b2186a8..20f6dd5 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -60,6 +60,39 @@ bisect_autostart() {
bisect_start() {
#
+ # Check for one bad and then some good revisions.
+ #
+ has_double_dash=0
+ for arg; do
+ case "$arg" in --) has_double_dash=1; break ;; esac
+ done
+ orig_args=$(git rev-parse --sq-quote "$@")
+ bad_seen=0
+ eval=''
+ while [ $# -gt 0 ]; do
+ arg="$1"
+ case "$arg" in
+ --)
+ shift
+ break
+ ;;
+ *)
+ rev=$(git rev-parse -q --verify "$arg^{commit}") || {
+ test $has_double_dash -eq 1 &&
+ die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
+ break
+ }
+ case $bad_seen in
+ 0) state='bad' ; bad_seen=1 ;;
+ *) state='good' ;;
+ esac
+ eval="$eval bisect_write '$state' '$rev' 'nolog'; "
+ shift
+ ;;
+ esac
+ done
+
+ #
# Verify HEAD.
#
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
@@ -98,39 +131,6 @@ bisect_start() {
bisect_clean_state || exit
#
- # Check for one bad and then some good revisions.
- #
- has_double_dash=0
- for arg; do
- case "$arg" in --) has_double_dash=1; break ;; esac
- done
- orig_args=$(git rev-parse --sq-quote "$@")
- bad_seen=0
- eval=''
- while [ $# -gt 0 ]; do
- arg="$1"
- case "$arg" in
- --)
- shift
- break
- ;;
- *)
- rev=$(git rev-parse -q --verify "$arg^{commit}") || {
- test $has_double_dash -eq 1 &&
- die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
- break
- }
- case $bad_seen in
- 0) state='bad' ; bad_seen=1 ;;
- *) state='good' ;;
- esac
- eval="$eval bisect_write '$state' '$rev' 'nolog'; "
- shift
- ;;
- esac
- done
-
- #
# Change state.
# In case of mistaken revs or checkout error, or signals received,
# "bisect_auto_next" below may exit or misbehave.
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index b5063b6..b3d1b14 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -138,15 +138,23 @@ test_expect_success 'bisect start: back in good branch' '
grep "* other" branch.output > /dev/null
'
-test_expect_success 'bisect start: no ".git/BISECT_START" if junk rev' '
- git bisect start $HASH4 $HASH1 -- &&
- git bisect good &&
+test_expect_success 'bisect start: no ".git/BISECT_START" created if junk rev' '
+ git bisect reset &&
test_must_fail git bisect start $HASH4 foo -- &&
git branch > branch.output &&
grep "* other" branch.output > /dev/null &&
test_must_fail test -e .git/BISECT_START
'
+test_expect_success 'bisect start: existing ".git/BISECT_START" not modified if junk rev' '
+ git bisect start $HASH4 $HASH1 -- &&
+ git bisect good &&
+ cp .git/BISECT_START saved &&
+ test_must_fail git bisect start $HASH4 foo -- &&
+ git branch > branch.output &&
+ grep "* (no branch)" branch.output > /dev/null &&
+ test_cmp saved .git/BISECT_START
+'
test_expect_success 'bisect start: no ".git/BISECT_START" if mistaken rev' '
git bisect start $HASH4 $HASH1 -- &&
git bisect good &&
--
1.7.6.352.gd542a2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v15 2/7] bisect: use && to connect statements that are deferred with eval.
2011-08-03 15:03 [PATCH v15 0/7] bisect: Add support for --no-checkout option Jon Seymour
2011-08-03 15:03 ` [PATCH v15 1/7] bisect: move argument parsing before state modification Jon Seymour
@ 2011-08-03 15:03 ` Jon Seymour
2011-08-03 15:03 ` [PATCH v15 3/7] bisect: add tests to document expected behaviour in presence of broken trees Jon Seymour
` (4 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Jon Seymour @ 2011-08-03 15:03 UTC (permalink / raw)
To: git; +Cc: chriscool, gitster, j6t, jnareb, Jon Seymour
Christian Couder pointed out that the existing eval strategy
swallows an initial non-zero return. Using && to connect
the statements should fix this.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
git-bisect.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-bisect.sh b/git-bisect.sh
index 20f6dd5..a44ffe1 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -86,7 +86,7 @@ bisect_start() {
0) state='bad' ; bad_seen=1 ;;
*) state='good' ;;
esac
- eval="$eval bisect_write '$state' '$rev' 'nolog'; "
+ eval="$eval bisect_write '$state' '$rev' 'nolog' &&"
shift
;;
esac
@@ -145,7 +145,7 @@ bisect_start() {
#
echo "$start_head" >"$GIT_DIR/BISECT_START" &&
git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" &&
- eval "$eval" &&
+ eval "$eval true" &&
echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
#
# Check if we can proceed to the next bisect state.
--
1.7.6.352.gd542a2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v15 3/7] bisect: add tests to document expected behaviour in presence of broken trees.
2011-08-03 15:03 [PATCH v15 0/7] bisect: Add support for --no-checkout option Jon Seymour
2011-08-03 15:03 ` [PATCH v15 1/7] bisect: move argument parsing before state modification Jon Seymour
2011-08-03 15:03 ` [PATCH v15 2/7] bisect: use && to connect statements that are deferred with eval Jon Seymour
@ 2011-08-03 15:03 ` Jon Seymour
2011-08-03 15:03 ` [PATCH v15 4/7] bisect: introduce support for --no-checkout option Jon Seymour
` (3 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Jon Seymour @ 2011-08-03 15:03 UTC (permalink / raw)
To: git; +Cc: chriscool, gitster, j6t, jnareb, Jon Seymour
If the repo is broken, we expect bisect to fail.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
t/t6030-bisect-porcelain.sh | 48 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index b3d1b14..9ae2de8 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -581,5 +581,53 @@ test_expect_success 'erroring out when using bad path parameters' '
'
#
+# This creates a broken branch which cannot be checked out because
+# the tree created has been deleted.
#
+# H1-H2-H3-H4-H5-H6-H7 <--other
+# \
+# S5-S6'-S7'-S8'-S9 <--broken
+#
+# Commits marked with ' have a missing tree.
+#
+test_expect_success 'broken branch creation' '
+ git bisect reset &&
+ git checkout -b broken $HASH4 &&
+ git tag BROKEN_HASH4 $HASH4 &&
+ add_line_into_file "5(broken): first line on a broken branch" hello2 &&
+ git tag BROKEN_HASH5 &&
+ mkdir missing &&
+ :> missing/MISSING &&
+ git add missing/MISSING &&
+ git commit -m "6(broken): Added file that will be deleted"
+ git tag BROKEN_HASH6 &&
+ add_line_into_file "7(broken): second line on a broken branch" hello2 &&
+ git tag BROKEN_HASH7 &&
+ add_line_into_file "8(broken): third line on a broken branch" hello2 &&
+ git tag BROKEN_HASH8 &&
+ git rm missing/MISSING &&
+ git commit -m "9(broken): Remove missing file"
+ git tag BROKEN_HASH9 &&
+ rm .git/objects/39/f7e61a724187ab767d2e08442d9b6b9dab587d
+'
+
+echo "" > expected.ok
+cat > expected.missing-tree.default <<EOF
+fatal: unable to read tree 39f7e61a724187ab767d2e08442d9b6b9dab587d
+EOF
+
+test_expect_success 'bisect fails if tree is broken on start commit' '
+ git bisect reset &&
+ test_must_fail git bisect start BROKEN_HASH7 BROKEN_HASH4 2>error.txt &&
+ test_cmp expected.missing-tree.default error.txt
+'
+
+test_expect_success 'bisect fails if tree is broken on trial commit' '
+ git bisect reset &&
+ test_must_fail git bisect start BROKEN_HASH9 BROKEN_HASH4 2>error.txt &&
+ git reset --hard broken &&
+ git checkout broken &&
+ test_cmp expected.missing-tree.default error.txt
+'
+
test_done
--
1.7.6.352.gd542a2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v15 4/7] bisect: introduce support for --no-checkout option.
2011-08-03 15:03 [PATCH v15 0/7] bisect: Add support for --no-checkout option Jon Seymour
` (2 preceding siblings ...)
2011-08-03 15:03 ` [PATCH v15 3/7] bisect: add tests to document expected behaviour in presence of broken trees Jon Seymour
@ 2011-08-03 15:03 ` Jon Seymour
2011-08-03 15:03 ` [PATCH v15 5/7] bisect: introduce --no-checkout support into porcelain Jon Seymour
` (2 subsequent siblings)
6 siblings, 0 replies; 12+ messages in thread
From: Jon Seymour @ 2011-08-03 15:03 UTC (permalink / raw)
To: git; +Cc: chriscool, gitster, j6t, jnareb, Jon Seymour
If --no-checkout is specified, then the bisection process uses:
git update-ref --no-deref HEAD <trial>
at each trial instead of:
git checkout <trial>
Improved-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
bisect.c | 33 ++++++++++++++++++++++-----------
bisect.h | 2 +-
builtin/bisect--helper.c | 7 +++++--
3 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/bisect.c b/bisect.c
index dd7e8ed..c7b7d79 100644
--- a/bisect.c
+++ b/bisect.c
@@ -24,6 +24,7 @@ struct argv_array {
static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
+static const char *argv_update_ref[] = {"update-ref", "--no-deref", "BISECT_HEAD", NULL, NULL};
/* bits #0-15 in revision.h */
@@ -707,16 +708,23 @@ static void mark_expected_rev(char *bisect_rev_hex)
die("closing file %s: %s", filename, strerror(errno));
}
-static int bisect_checkout(char *bisect_rev_hex)
+static int bisect_checkout(char *bisect_rev_hex, int no_checkout)
{
int res;
mark_expected_rev(bisect_rev_hex);
argv_checkout[2] = bisect_rev_hex;
- res = run_command_v_opt(argv_checkout, RUN_GIT_CMD);
- if (res)
- exit(res);
+ if (no_checkout) {
+ argv_update_ref[3] = bisect_rev_hex;
+ if (run_command_v_opt(argv_update_ref, RUN_GIT_CMD))
+ die("update-ref --no-deref HEAD failed on %s",
+ bisect_rev_hex);
+ } else {
+ res = run_command_v_opt(argv_checkout, RUN_GIT_CMD);
+ if (res)
+ exit(res);
+ }
argv_show_branch[1] = bisect_rev_hex;
return run_command_v_opt(argv_show_branch, RUN_GIT_CMD);
@@ -788,7 +796,7 @@ static void handle_skipped_merge_base(const unsigned char *mb)
* - If one is "skipped", we can't know but we should warn.
* - If we don't know, we should check it out and ask the user to test.
*/
-static void check_merge_bases(void)
+static void check_merge_bases(int no_checkout)
{
struct commit_list *result;
int rev_nr;
@@ -806,7 +814,7 @@ static void check_merge_bases(void)
handle_skipped_merge_base(mb);
} else {
printf("Bisecting: a merge base must be tested\n");
- exit(bisect_checkout(sha1_to_hex(mb)));
+ exit(bisect_checkout(sha1_to_hex(mb), no_checkout));
}
}
@@ -849,7 +857,7 @@ static int check_ancestors(const char *prefix)
* If a merge base must be tested by the user, its source code will be
* checked out to be tested by the user and we will exit.
*/
-static void check_good_are_ancestors_of_bad(const char *prefix)
+static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
{
const char *filename = git_path("BISECT_ANCESTORS_OK");
struct stat st;
@@ -868,7 +876,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix)
/* Check if all good revs are ancestor of the bad rev. */
if (check_ancestors(prefix))
- check_merge_bases();
+ check_merge_bases(no_checkout);
/* Create file BISECT_ANCESTORS_OK. */
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
@@ -908,8 +916,11 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
* 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.
+ *
+ * If no_checkout is non-zero, the bisection process does not
+ * checkout the trial commit but instead simply updates BISECT_HEAD.
*/
-int bisect_next_all(const char *prefix)
+int bisect_next_all(const char *prefix, int no_checkout)
{
struct rev_info revs;
struct commit_list *tried;
@@ -920,7 +931,7 @@ int bisect_next_all(const char *prefix)
if (read_bisect_refs())
die("reading bisect refs failed");
- check_good_are_ancestors_of_bad(prefix);
+ check_good_are_ancestors_of_bad(prefix, no_checkout);
bisect_rev_setup(&revs, prefix, "%s", "^%s", 1);
revs.limited = 1;
@@ -966,6 +977,6 @@ int bisect_next_all(const char *prefix)
"(roughly %d step%s)\n", nr, (nr == 1 ? "" : "s"),
steps, (steps == 1 ? "" : "s"));
- return bisect_checkout(bisect_rev_hex);
+ return bisect_checkout(bisect_rev_hex, no_checkout);
}
diff --git a/bisect.h b/bisect.h
index 0862ce5..22f2e4d 100644
--- a/bisect.h
+++ b/bisect.h
@@ -27,7 +27,7 @@ struct rev_list_info {
const char *header_prefix;
};
-extern int bisect_next_all(const char *prefix);
+extern int bisect_next_all(const char *prefix, int no_checkout);
extern int estimate_bisect_steps(int all);
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 5b22639..8d325a5 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -4,16 +4,19 @@
#include "bisect.h"
static const char * const git_bisect_helper_usage[] = {
- "git bisect--helper --next-all",
+ "git bisect--helper --next-all [--no-checkout]",
NULL
};
int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
{
int next_all = 0;
+ int no_checkout = 0;
struct option options[] = {
OPT_BOOLEAN(0, "next-all", &next_all,
"perform 'git bisect next'"),
+ OPT_BOOLEAN(0, "no-checkout", &no_checkout,
+ "update BISECT_HEAD instead of checking out the current commit"),
OPT_END()
};
@@ -24,5 +27,5 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
usage_with_options(git_bisect_helper_usage, options);
/* next-all */
- return bisect_next_all(prefix);
+ return bisect_next_all(prefix, no_checkout);
}
--
1.7.6.352.gd542a2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v15 5/7] bisect: introduce --no-checkout support into porcelain.
2011-08-03 15:03 [PATCH v15 0/7] bisect: Add support for --no-checkout option Jon Seymour
` (3 preceding siblings ...)
2011-08-03 15:03 ` [PATCH v15 4/7] bisect: introduce support for --no-checkout option Jon Seymour
@ 2011-08-03 15:03 ` Jon Seymour
2011-08-03 15:32 ` Jon Seymour
2011-08-03 15:03 ` [PATCH v15 6/7] bisect: add tests for the --no-checkout option Jon Seymour
2011-08-03 15:03 ` [PATCH v15 7/7] bisect: add documentation for " Jon Seymour
6 siblings, 1 reply; 12+ messages in thread
From: Jon Seymour @ 2011-08-03 15:03 UTC (permalink / raw)
To: git; +Cc: chriscool, gitster, j6t, jnareb, Jon Seymour
git-bisect can now perform bisection of a history without performing
a checkout at each stage of the bisection process. Instead, HEAD is updated.
One use-case for this function is allow git bisect to be used with
damaged repositories where git checkout would fail because the tree
referenced by the commit is damaged.
It can also be used in other cases where actual checkout of the tree
is not required to progress the bisection.
Improved-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
git-bisect.sh | 42 +++++++++++++++++++++++++++++++-----------
1 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/git-bisect.sh b/git-bisect.sh
index a44ffe1..bebc6cd 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -3,7 +3,7 @@
USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'
LONG_USAGE='git bisect help
print this long help message.
-git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
+git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
reset bisect state and start bisection.
git bisect bad [<rev>]
mark <rev> a known-bad revision.
@@ -34,6 +34,15 @@ require_work_tree
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+bisect_head()
+{
+ if test -f "$GIT_DIR/BISECT_HEAD"; then
+ echo BISECT_HEAD;
+ else
+ echo HEAD
+ fi
+}
+
bisect_autostart() {
test -s "$GIT_DIR/BISECT_START" || {
(
@@ -69,6 +78,7 @@ bisect_start() {
orig_args=$(git rev-parse --sq-quote "$@")
bad_seen=0
eval=''
+ mode=''
while [ $# -gt 0 ]; do
arg="$1"
case "$arg" in
@@ -76,6 +86,11 @@ bisect_start() {
shift
break
;;
+ --no-checkout)
+ mode=--no-checkout;
+ shift ;;
+ --*)
+ die "$(eval_gettext "unrecognised option: '\$arg'")" ;;
*)
rev=$(git rev-parse -q --verify "$arg^{commit}") || {
test $has_double_dash -eq 1 &&
@@ -107,7 +122,9 @@ bisect_start() {
then
# Reset to the rev from where we started.
start_head=$(cat "$GIT_DIR/BISECT_START")
- git checkout "$start_head" -- || exit
+ if test "$mode" != "--no-checkout"; then
+ git checkout "$start_head" --
+ fi
else
# Get rev from where we start.
case "$head" in
@@ -143,6 +160,8 @@ bisect_start() {
#
# Write new start state.
#
+ test "$mode" != "--no-checkout" ||
+ git update-ref --no-deref BISECT_HEAD "$start_head" &&
echo "$start_head" >"$GIT_DIR/BISECT_START" &&
git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" &&
eval "$eval true" &&
@@ -206,8 +225,8 @@ bisect_state() {
0,*)
die "$(gettext "Please call 'bisect_state' with at least one argument.")" ;;
1,bad|1,good|1,skip)
- rev=$(git rev-parse --verify HEAD) ||
- die "$(gettext "Bad rev input: HEAD")"
+ rev=$(git rev-parse --verify $(bisect_head)) ||
+ die "$(gettext "Bad rev input: $(bisect_head)")"
bisect_write "$state" "$rev"
check_expected_revs "$rev" ;;
2,bad|*,good|*,skip)
@@ -291,7 +310,7 @@ bisect_next() {
bisect_next_check good
# Perform all bisection computation, display and checkout
- git bisect--helper --next-all
+ git bisect--helper --next-all $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout)
res=$?
# Check if we should exit because bisection is finished
@@ -340,12 +359,13 @@ bisect_reset() {
*)
usage ;;
esac
- if git checkout "$branch" -- ; then
- bisect_clean_state
- else
- die "$(eval_gettext "Could not check out original HEAD '\$branch'.
+ if ! test -f "$GIT_DIR/BISECT_HEAD"; then
+ if ! git checkout "$branch" --; then
+ die "$(eval_gettext "Could not check out original HEAD '\$branch'.
Try 'git bisect reset <commit>'.")"
+ fi
fi
+ bisect_clean_state
}
bisect_clean_state() {
@@ -362,8 +382,8 @@ bisect_clean_state() {
rm -f "$GIT_DIR/BISECT_RUN" &&
# Cleanup head-name if it got left by an old version of git-bisect
rm -f "$GIT_DIR/head-name" &&
-
- rm -f "$GIT_DIR/BISECT_START"
+ rm -f "$GIT_DIR/BISECT_START" &&
+ git update-ref -d BISECT_HEAD
}
bisect_replay () {
--
1.7.6.352.gd542a2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v15 5/7] bisect: introduce --no-checkout support into porcelain.
2011-08-03 15:03 ` [PATCH v15 5/7] bisect: introduce --no-checkout support into porcelain Jon Seymour
@ 2011-08-03 15:32 ` Jon Seymour
2011-08-03 19:33 ` Christian Couder
0 siblings, 1 reply; 12+ messages in thread
From: Jon Seymour @ 2011-08-03 15:32 UTC (permalink / raw)
To: git; +Cc: chriscool, gitster, j6t, jnareb, Jon Seymour
On Thu, Aug 4, 2011 at 1:03 AM, Jon Seymour <jon.seymour@gmail.com> wrote:
rm -f "$GIT_DIR/head-name" &&
> -
> - rm -f "$GIT_DIR/BISECT_START"
> + rm -f "$GIT_DIR/BISECT_START" &&
> + git update-ref -d BISECT_HEAD
> }
I'll reverse the order of the last two statements and restore the blank line...
jon.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v15 5/7] bisect: introduce --no-checkout support into porcelain.
2011-08-03 15:32 ` Jon Seymour
@ 2011-08-03 19:33 ` Christian Couder
0 siblings, 0 replies; 12+ messages in thread
From: Christian Couder @ 2011-08-03 19:33 UTC (permalink / raw)
To: Jon Seymour; +Cc: git, gitster, j6t, jnareb
On Wednesday 03 August 2011 17:32:09 Jon Seymour wrote:
> On Thu, Aug 4, 2011 at 1:03 AM, Jon Seymour <jon.seymour@gmail.com> wrote:
> rm -f "$GIT_DIR/head-name" &&
>
> > -
> > - rm -f "$GIT_DIR/BISECT_START"
> > + rm -f "$GIT_DIR/BISECT_START" &&
> > + git update-ref -d BISECT_HEAD
> > }
>
> I'll reverse the order of the last two statements and restore the blank
> line...
Great!
It would be nice too if the "git update-ref" call that creates the ref in the
first place was after the creation of the $GIT_DIR/BISECT_START file.
This way we start by creating the $GIT_DIR/BISECT_START file and we finish by
deleting it.
That is change this:
...
+ test "$mode" != "--no-checkout" ||
+ git update-ref --no-deref BISECT_HEAD "$start_head" &&
echo "$start_head" >"$GIT_DIR/BISECT_START" &&
into something like this:
echo "$start_head" >"$GIT_DIR/BISECT_START" &&
+ {
+ test "$mode" != "--no-checkout" ||
+ git update-ref --no-deref BISECT_HEAD "$start_head"
+ } &&
...
Thanks,
Christian.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v15 6/7] bisect: add tests for the --no-checkout option.
2011-08-03 15:03 [PATCH v15 0/7] bisect: Add support for --no-checkout option Jon Seymour
` (4 preceding siblings ...)
2011-08-03 15:03 ` [PATCH v15 5/7] bisect: introduce --no-checkout support into porcelain Jon Seymour
@ 2011-08-03 15:03 ` Jon Seymour
2011-08-03 15:03 ` [PATCH v15 7/7] bisect: add documentation for " Jon Seymour
6 siblings, 0 replies; 12+ messages in thread
From: Jon Seymour @ 2011-08-03 15:03 UTC (permalink / raw)
To: git; +Cc: chriscool, gitster, j6t, jnareb, Jon Seymour
These tests verify that git-bisect --no-checkout can successfully
bisect commit histories that reference damaged trees.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
t/t6030-bisect-porcelain.sh | 82 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 9ae2de8..1c05135 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -126,6 +126,18 @@ test_expect_success 'bisect reset removes packed refs' '
test -z "$(git for-each-ref "refs/heads/bisect")"
'
+test_expect_success 'bisect reset removes bisect state after --no-checkout' '
+ git bisect reset &&
+ git bisect start --no-checkout &&
+ git bisect good $HASH1 &&
+ git bisect bad $HASH3 &&
+ git bisect next &&
+ git bisect reset &&
+ test -z "$(git for-each-ref "refs/bisect/*")" &&
+ test -z "$(git for-each-ref "refs/heads/bisect")" &&
+ test -z "$(git for-each-ref "BISECT_HEAD")"
+'
+
test_expect_success 'bisect start: back in good branch' '
git branch > branch.output &&
grep "* other" branch.output > /dev/null &&
@@ -616,6 +628,14 @@ cat > expected.missing-tree.default <<EOF
fatal: unable to read tree 39f7e61a724187ab767d2e08442d9b6b9dab587d
EOF
+check_same()
+{
+ echo "Checking $1 is the same as $2" &&
+ git rev-parse "$1" > expected.same &&
+ git rev-parse "$2" > expected.actual &&
+ test_cmp expected.same expected.actual
+}
+
test_expect_success 'bisect fails if tree is broken on start commit' '
git bisect reset &&
test_must_fail git bisect start BROKEN_HASH7 BROKEN_HASH4 2>error.txt &&
@@ -630,4 +650,66 @@ test_expect_success 'bisect fails if tree is broken on trial commit' '
test_cmp expected.missing-tree.default error.txt
'
+test_expect_success 'bisect: --no-checkout - start commit bad' '
+ git bisect reset &&
+ git bisect start BROKEN_HASH7 BROKEN_HASH4 --no-checkout &&
+ check_same BROKEN_HASH6 BISECT_HEAD &&
+ git bisect reset
+'
+
+test_expect_success 'bisect: --no-checkout - trial commit bad' '
+ git bisect reset &&
+ git bisect start broken BROKEN_HASH4 --no-checkout &&
+ check_same BROKEN_HASH6 BISECT_HEAD &&
+ git bisect reset
+'
+
+test_expect_success 'bisect: --no-checkout - target before breakage' '
+ git bisect reset &&
+ git bisect start broken BROKEN_HASH4 --no-checkout &&
+ check_same BROKEN_HASH6 BISECT_HEAD &&
+ git bisect bad BISECT_HEAD &&
+ check_same BROKEN_HASH5 BISECT_HEAD &&
+ git bisect bad BISECT_HEAD &&
+ check_same BROKEN_HASH5 bisect/bad &&
+ git bisect reset
+'
+
+test_expect_success 'bisect: --no-checkout - target in breakage' '
+ git bisect reset &&
+ git bisect start broken BROKEN_HASH4 --no-checkout &&
+ check_same BROKEN_HASH6 BISECT_HEAD &&
+ git bisect bad BISECT_HEAD &&
+ check_same BROKEN_HASH5 BISECT_HEAD &&
+ git bisect good BISECT_HEAD &&
+ check_same BROKEN_HASH6 bisect/bad &&
+ git bisect reset
+'
+
+test_expect_success 'bisect: --no-checkout - target after breakage' '
+ git bisect reset &&
+ git bisect start broken BROKEN_HASH4 --no-checkout &&
+ check_same BROKEN_HASH6 BISECT_HEAD &&
+ git bisect good BISECT_HEAD &&
+ check_same BROKEN_HASH8 BISECT_HEAD &&
+ git bisect good BISECT_HEAD &&
+ check_same BROKEN_HASH9 bisect/bad &&
+ git bisect reset
+'
+
+test_expect_success 'bisect: demonstrate identification of damage boundary' "
+ git bisect reset &&
+ git checkout broken &&
+ git bisect start broken master --no-checkout &&
+ git bisect run eval '
+rc=1;
+if git rev-list --objects BISECT_HEAD >tmp.$$; then
+ git pack-objects --stdout >/dev/null < tmp.$$ && rc=0;
+fi;
+rm tmp.$$;
+test \$rc -eq 0;' &&
+ check_same BROKEN_HASH6 bisect/bad &&
+ git bisect reset
+"
+
test_done
--
1.7.6.352.gd542a2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v15 7/7] bisect: add documentation for --no-checkout option.
2011-08-03 15:03 [PATCH v15 0/7] bisect: Add support for --no-checkout option Jon Seymour
` (5 preceding siblings ...)
2011-08-03 15:03 ` [PATCH v15 6/7] bisect: add tests for the --no-checkout option Jon Seymour
@ 2011-08-03 15:03 ` Jon Seymour
2011-08-03 20:59 ` Junio C Hamano
6 siblings, 1 reply; 12+ messages in thread
From: Jon Seymour @ 2011-08-03 15:03 UTC (permalink / raw)
To: git; +Cc: chriscool, gitster, j6t, jnareb, Jon Seymour
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
Documentation/git-bisect.txt | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index ab60a18..2f23829 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -17,7 +17,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-checkout] [<bad> [<good>...]] [--] [<paths>...]
git bisect bad [<rev>]
git bisect good [<rev>...]
git bisect skip [(<rev>|<range>)...]
@@ -263,6 +263,17 @@ rewind the tree to the pristine state. Finally the script should exit
with the status of the real test to let the "git bisect run" command loop
determine the eventual outcome of the bisect session.
+OPTIONS
+-------
+--no-checkout::
++
+Do not checkout the new working tree at each iteration of the bisection
+process. Instead just update a special reference named 'BISECT_HEAD' to make
+it point to the commit that should be tested.
++
+This option is useful in circumstances in which checkout is either not
+possible (because the repository is damaged) or is otherwise not required.
+
EXAMPLES
--------
@@ -343,6 +354,25 @@ $ git bisect run sh -c "make || exit 125; ~/check_test_case.sh"
This shows that you can do without a run script if you write the test
on a single line.
+* Locate a good region of the object graph in a damaged repository
++
+------------
+$ git bisect start HEAD <known-good-commit> [ <boundary-commit> ... ] --no-checkout
+$ git bisect run eval '
+rc=1;
+if git rev-list --objects BISECT_HEAD >tmp.$$; then
+ git pack-objects --stdout >/dev/null < tmp.$$ && rc=0;
+fi;
+rm tmp.$$;
+test $rc -eq 0;'
+
+------------
++
+In this case, when 'git bisect run' finishes, bisect/bad will refer to a commit that
+has at least one parent whose reachable graph is fully traversable in the sense
+required by 'git pack objects'.
+
+
SEE ALSO
--------
link:git-bisect-lk2009.html[Fighting regressions with git bisect],
--
1.7.6.352.gd542a2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v15 7/7] bisect: add documentation for --no-checkout option.
2011-08-03 15:03 ` [PATCH v15 7/7] bisect: add documentation for " Jon Seymour
@ 2011-08-03 20:59 ` Junio C Hamano
2011-08-03 21:37 ` Jon Seymour
0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2011-08-03 20:59 UTC (permalink / raw)
To: Jon Seymour; +Cc: git, chriscool, gitster, j6t, jnareb
Jon Seymour <jon.seymour@gmail.com> writes:
> +This option is useful in circumstances in which checkout is either not
> +possible (because the repository is damaged) or is otherwise not required.
I do not think "because the repository is damaged" is a particularly good
example to single out here. For one thing, you may not be able to bisect
the history in a damaged repository due to unreadable commits. There are
other valid and more plausible reasons that the users do not want to
update the working tree while bisecting, e.g. they have local changes,
they do not want to rebuild everything after bisection is done, etc.
Also the above description muddies what is prerequisite and what is user's
wish.
- "is otherwise not required" is the prerequisite: "if and only if the
test you would perform during bisection does not need a checkout of the
version being tested, you can use this option";
- Even if the user wishes to use this option for various reasons (e.g. so
that the next "make" wouldn't have to rebuild everything unnecessarily;
or the repository has corrupt blobs and checkout of some versions may
fail), if the test _needs_ a checkout, it is not an option to use this
feature.
So I would suggest toning it down perhaps like this:
This option may be useful when the test you would perform in each step
does not require a checked out tree.
> +$ git bisect run eval '
> +rc=1;
> +if git rev-list --objects BISECT_HEAD >tmp.$$; then
> + git pack-objects --stdout >/dev/null < tmp.$$ && rc=0;
> +fi;
> +rm tmp.$$;
> +test $rc -eq 0;'
Hmm, "eval"?
More importantly, aren't these excessive and unnecessary semicolons
unsightly?
$ git bisect run sh -c '
git rev-list --objects BISECT_HEAD >tmp.$$ &&
git pack-objects --stdout >/dev/null <tmp.$$
rc=$?
rm -f tmp.$$
test $rc = 0'
> +In this case, when 'git bisect run' finishes, bisect/bad will refer to a commit that
> +has at least one parent whose reachable graph is fully traversable in the sense
> +required by 'git pack objects'.
Also "everything reachable from BISECT_HEAD" feels unnecessarily
wasteful. By the time you invoke "bisect run", you already know one good
commit, everything reachable from which are known to be good.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v15 7/7] bisect: add documentation for --no-checkout option.
2011-08-03 20:59 ` Junio C Hamano
@ 2011-08-03 21:37 ` Jon Seymour
0 siblings, 0 replies; 12+ messages in thread
From: Jon Seymour @ 2011-08-03 21:37 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, chriscool, j6t, jnareb
On Thu, Aug 4, 2011 at 6:59 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Jon Seymour <jon.seymour@gmail.com> writes:
>
>> +This option is useful in circumstances in which checkout is either not
>> +possible (because the repository is damaged) or is otherwise not required.
>
> I do not think "because the repository is damaged" is a particularly good
> example to single out here. For one thing, you may not be able to bisect
> the history in a damaged repository due to unreadable commits. There are
> other valid and more plausible reasons that the users do not want to
> update the working tree while bisecting, e.g. they have local changes,
> they do not want to rebuild everything after bisection is done, etc.
>
> Also the above description muddies what is prerequisite and what is user's
> wish.
>
> - "is otherwise not required" is the prerequisite: "if and only if the
> test you would perform during bisection does not need a checkout of the
> version being tested, you can use this option";
>
> - Even if the user wishes to use this option for various reasons (e.g. so
> that the next "make" wouldn't have to rebuild everything unnecessarily;
> or the repository has corrupt blobs and checkout of some versions may
> fail), if the test _needs_ a checkout, it is not an option to use this
> feature.
>
> So I would suggest toning it down perhaps like this:
>
> This option may be useful when the test you would perform in each step
> does not require a checked out tree.
>
Sounds good.
>> +$ git bisect run eval '
>> +rc=1;
>> +if git rev-list --objects BISECT_HEAD >tmp.$$; then
>> + git pack-objects --stdout >/dev/null < tmp.$$ && rc=0;
>> +fi;
>> +rm tmp.$$;
>> +test $rc -eq 0;'
>
> Hmm, "eval"?
>
> More importantly, aren't these excessive and unnecessary semicolons
> unsightly?
>
> $ git bisect run sh -c '
> git rev-list --objects BISECT_HEAD >tmp.$$ &&
> git pack-objects --stdout >/dev/null <tmp.$$
> rc=$?
> rm -f tmp.$$
> test $rc = 0'
>
>> +In this case, when 'git bisect run' finishes, bisect/bad will refer to a commit that
>> +has at least one parent whose reachable graph is fully traversable in the sense
>> +required by 'git pack objects'.
>
> Also "everything reachable from BISECT_HEAD" feels unnecessarily
> wasteful. By the time you invoke "bisect run", you already know one good
> commit, everything reachable from which are known to be good.
>
How about?
git bisect run sh -c '
GOOD=$(git for-each-ref "--format=%(objectname)" refs/bisect/good-*) &&
git rev-list --objects BISECT_HEAD --not $GOOD >tmp.$$ &&
git pack-objects --stdout >/dev/null <tmp.$$
rc=$?
rm -f tmp.$$
test $rc = 0'
^ permalink raw reply [flat|nested] 12+ messages in thread