An alternative to git bisect with Gentoo and the live ebuild

Git bisect is absolutely powerful, but sometimes is more comfortable use emerge instead of compile the software outside the package manager.

That was my case with media-libs/jasper which I’m picking as example for this ‘howto’

So basically, you are running Gentoo, you can install a live ebuild (9999) and you want to find which commit id fixes an issue. Let’s see step-by-step what to do.

1) Clone the repository to obtain the commit ids and put them in a file

ago@blackgate ~ $ cd /tmp
ago@blackgate /tmp $ git clone
ago@blackgate /tmp $ cd jasper/
ago@blackgate /tmp/jasper $ git --no-pager log --format=%H > /tmp/commitlist.txt

The file should contain the git commit ids, for example:


2) Use a simple script which runs emerge and the command you need to test.

for COMMIT_ID in $( cat /tmp/commitlist.txt )
      echo "Testing with the commit id: "${COMMIT_ID}""
      EGIT_COMMIT="${COMMIT_ID}" emerge -q media-libs/jasper
      imginfo -f /tmp/myjpg.jpg
      echo -ne "\n\n\n"

With the EGIT_COMMIT variable from the git-* eclass, we can emerge the live ebuild at a specific commit id.
imginfo is in my case the command I need and then I print some blank lines to better separate the output of the commands and understand what is happening.

Now you need to wait and just check what is the output of the specified command.

– This howto looks to be valid when the project you are building is small; running this script with e.g. libreoffice will take months.
– This howto looks to be valid when you know that the problem is near to the commit master and will take few emerge cycles to found the issue.
– If you know that the problem is fixed e.g. a year ago, you can manually edit the commitlist.txt file and delete some recent ids, to have a specified and minor range of commits.

That’s all.

This entry was posted in gentoo. Bookmark the permalink.

4 Responses to An alternative to git bisect with Gentoo and the live ebuild

  1. Felix says:

    It would also be possible to combine git bisect and emerge via git
    bisect run. A run script could be of the form:


    EGIT_COMMIT=”$(git revparse HEAD)” emerge -q media-libs/jasper

    if has_bug; then
    return 1
    return 0

    It might also be nice to use “ebuild … install” so that the running
    system is not affected by the tests.

  2. eliasp says:

    Shouldn’t “${PN}_LIVE_COMMIT=$(git rev-parse HEAD)” be used instead of EGIT_COMMIT?

  3. reck says:

    Why the grep and sed? git log has plenty of format options, git log –format=%H will log just the sha1s of each commit.


Leave a Reply

Your email address will not be published. Required fields are marked *