How can I cut down a git bisect run using file paths?
Asked Answered
Y

1

27

I'm using git bisect to find a failure inducing commit. However, a lot of the commits in the range are definately irrelevant (because they are commits to the documentation or to unit tests). I'd like to make git bisect automatically skip commits which affect files in certain directories. Is this possible somehow?

Yawl answered 5/7, 2010 at 12:40 Comment(0)
A
40

You have several options here:

  1. Ignoring specific commits

    git bisect contains functionality of skipping commits. You can specify commits, tags, ranges you don't want to test with

     git bisect skip 0dae5f ff049ab ...
    

    Just do this before you git bisect run, and it should skip what you specified.

  2. Specifying folders with broken sources

    You can also cut down commits bisect tests by specifying what folders it should look for problems in. This is done at the beginning of bisect process by supplying additional arguments to git bisect start (quote from standard manual):

     git bisect start -- arch/i386 include/asm-i386
    

    Bisect will only consider commits that touch the folders specified.


If you want to automatically gather commits that touch certain files or folders, you may use git log for that. For example, the following command will give you commit names that modify files in certain folders:

git log --pretty=format:%H  tests/ docs/

And you can supply the result to git bisect skip with use of shell capabilities:

git bisect skip `git log --pretty=format:%H  tests/ docs/`
Absolve answered 5/7, 2010 at 12:53 Comment(5)
I knew about the first two options already, but manually skipping commits was too much work (there are hundres of them) and I also don't know which folders contains the broken sources. The suggestion to use git log is great! Unfortunately I'm on Windows, so fancy shell capabilities won't work for me. However, I can easily construct an appropriate git bisect skip command line by hand. Thanks!Yawl
@FrerichRaabe: What, your git didn't come with a copy of bash?Lumberjack
hmmm adding 2 folders to git bisect start only looks at commits which touch BOTH folders. Is there a way to look at commits which touch EITHER folder?Insalivate
what is "arch"? in git bisect start -- arch/i386 include/asm-i386Walkout
@Walkout those are the examples used in man git-bisect; they used to be directories in the Linux kernel source tree.Lingwood

© 2022 - 2024 — McMap. All rights reserved.