# Workflow for bisecting with test in a branch

2 messages from 2025-04-27 to 2025-04-28. Participants: Victor Engmark, Christian Couder.
Thread: https://gitlist.dev/t/63356

## Victor Engmark, 2025-04-27 08:18

Subject: Workflow for bisecting with test in a branch
Message-ID: <02671927-2e65-4bd3-904b-b564849d1fa5@engmark.name>
URL: https://gitlist.dev/e/02671927-2e65-4bd3-904b-b564849d1fa5%40engmark.name

```
I'd like to bisect using a test I've written in a different branch from 
the one I'm bisecting. But to do `git bisect run ./test.bash` I have to 
keep the new test file and an old test suite file the same during the 
whole `bisect` process. This turned out pretty cumbersome:

test.bash:

ˋˋˋ
#!/usr/bin/env bash

set -o errexit

git show my-test-branch:test-suite-path > test-suite-path
mkdir -p test-dir
git show my-test-branch:test-dir/test-file > test-dir/test-file

run_test || exit_code=$?
git checkout .
exit "${exit_code-0}"
ˋˋˋ

Console session:

ˋˋˋ
git bisect start my-test-branch known-good-ancestor
git bisect run ./test.bash
ˋˋˋ

Is there a more streamlined way to achieve the same thing, that is, 
forcing some checked-in files to not change while bisecting?

Kind regards
Victor Engmark

```

## Christian Couder, 2025-04-28 07:41

Subject: Re: Workflow for bisecting with test in a branch
Message-ID: <CAP8UFD1fzLjNdrhv8yuGJmjKsJRU0kaa4rtV=ur+3CMYZD2wzA@mail.gmail.com>
URL: https://gitlist.dev/e/CAP8UFD1fzLjNdrhv8yuGJmjKsJRU0kaa4rtV%3Dur%2B3CMYZD2wzA%40mail.gmail.com
In-Reply-To: <02671927-2e65-4bd3-904b-b564849d1fa5@engmark.name>

```
On Sun, Apr 27, 2025 at 10:18 AM Victor Engmark <victor@engmark.name> wrote:
>
> I'd like to bisect using a test I've written in a different branch from
> the one I'm bisecting. But to do `git bisect run ./test.bash` I have to
> keep the new test file and an old test suite file the same during the
> whole `bisect` process. This turned out pretty cumbersome:

[...]

> Is there a more streamlined way to achieve the same thing, that is,
> forcing some checked-in files to not change while bisecting?

You could perhaps use worktrees (see
https://git-scm.com/docs/git-worktree) to have a separate worktree
with the checked-in files that shouldn't change, while performing the
bisection and building in the main worktree. If all the needed files
and directories are properly set up on the separate worktree, you
could copy them over using a single `cp -a ...` command.

Also I think that conceptually it's more the responsibility of your
build and test system, rather than the SCM, to provide you with clean,
out of source builds and tests.

Best,
Christian.

```
