bisect: add support for bisecting bare repositories
v2 cover bisect: add support for bisecting bare repositories
This extension to js/bisect-no-checkout (currently in pu) adds support for bisecting bare repositories.
It does this by relaxing the requirement that git bisect is invoked in a repository with a working tree and by defaulting to --no-checkout in the case of a bare repository.
Two tests are included to demonstrate this behaviour.
Revisions
=========
v2:
Squashed documentation patch into code change patch. Simplified test, per Jonathan Nieder.
v1:
Initial release.
Jon Seymour (2):
bisect: relax requirement for a working tree.
bisect: add tests for bisection on bare repositories
Documentation/git-bisect.txt | 2 ++ git-bisect.sh | 8 ++++++-- git.c | 2 +- t/t6030-bisect-porcelain.sh | 31 +++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.6.522.g810f.dirty
PATCH v2 1/2 bisect: relax requirement for a working tree.
Now that bisection does not require checkout, it can work on bare repositories too.
In this case, we default the checkout mode to --no-checkout, thereby forcing the creation of BISECT_HEAD on either a manual or automatic start.
The require_work_tree check in git-bisect.sh and the NEED_WORK_TREE check in git.c are relaxed.
--- Documentation/git-bisect.txt | 2 ++ git-bisect.sh | 8 ++++++-- git.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-)
Documentation/git-bisect.txt +2 -0
@@ -273,6 +273,8 @@ it point to the commit that should be tested. + This option may be useful when the test you would perform in each step does not require a checked out tree. ++ +If the repository is bare, `--no-checkout` is assumed. EXAMPLES --------
git-bisect.sh +6 -2
@@ -29,7 +29,6 @@ Please use "git help bisect" to get the full man page.' OPTIONS_SPEC= . git-sh-setup . git-sh-i18n -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"
@@ -79,7 +78,12 @@ bisect_start() { orig_args=$(git rev-parse --sq-quote "$@") bad_seen=0 eval='' - mode='' + if test "z$(git rev-parse --is-bare-repository)" != zfalse + then + mode=--no-checkout + else + mode= + fi while [ $# -gt 0 ]; do arg="$1" case "$arg" in
git.c +1 -1
@@ -320,7 +320,7 @@ static void handle_internal_command(int argc, const char **argv) { "annotate", cmd_annotate, RUN_SETUP }, { "apply", cmd_apply, RUN_SETUP_GENTLY }, { "archive", cmd_archive }, - { "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE }, + { "bisect--helper", cmd_bisect__helper, RUN_SETUP }, { "blame", cmd_blame, RUN_SETUP }, { "branch", cmd_branch, RUN_SETUP }, { "bundle", cmd_bundle, RUN_SETUP_GENTLY },
Signature · 1 line
1.7.6.522.g810f.dirty
PATCH v2 2/2 bisect: add tests for bisection on bare repositories
In reply to Jon SeymourWe add a test to check that bisection works on bare repositories both when --no-checkout is specified explicitly and when it is defaulted.
--- t/t6030-bisect-porcelain.sh | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-)
t/t6030-bisect-porcelain.sh +31 -0
@@ -592,6 +592,37 @@ test_expect_success 'erroring out when using bad path parameters' ' grep "bad path parameters" error.txt ' +test_expect_success 'test bisection on bare repo - --no-checkout specified' ' + git clone --bare . bare.nocheckout && + ( + cd bare.nocheckout && + git bisect start --no-checkout && + git bisect good $HASH1 && + git bisect bad $HASH4 && + git bisect run eval \ + "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \ + >../nocheckout.log && + git bisect reset + ) && + grep "$HASH3 is the first bad commit" nocheckout.log +' + + +test_expect_success 'test bisection on bare repo - --no-checkout defaulted' ' + git clone --bare . bare.defaulted && + ( + cd bare.defaulted && + git bisect start && + git bisect good $HASH1 && + git bisect bad $HASH4 && + git bisect run eval \ + "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \ + >../defaulted.log && + git bisect reset + ) && + grep "$HASH3 is the first bad commit" defaulted.log +' + # # This creates a broken branch which cannot be checked out because # the tree created has been deleted.
Signature · 1 line
1.7.6.522.g810f.dirty
Quoted 8 lines · Jon Seymour
This extension to js/bisect-no-checkout (currently in pu) adds support for bisecting bare repositories.
It does this by relaxing the requirement that git bisect is invoked in a repository with a working tree and by defaulting to --no-checkout in the case of a bare repository.
Two tests are included to demonstrate this behaviour.
Thanks! I think the two patches should be squashed, with the above as commit message.
With or without that change, for what it's worth,