2

I have a single repository that contains several sub-projects and no sub-trees or sub-modules. I now have a bug on a new feature that needs fixing in Project C. C depends on projects A and B.

For the feature to work, I need the latest version of Project A.

Somewhere in project B, the bug was introduced. So my question is:

Can I run git bisect and tell it to only operate on Project B's source tree while keeping A and C at their latest versions?

Carl
  • 43,122
  • 10
  • 80
  • 104

2 Answers2

4

No, git bisect does not support that. You should never but different projects into the same repo. Git does not like or support that. Here’s what you can do despite that:

git bisect basically has two modes here: the normal mode and the --no-checkout mode. You can use either of both to achieve your goal in different ways:

  1. Normal: run git bisect and at every step, before you test, you put the correct version of your subprojects in the working tree with git checkout master -- sub/project/folder. You might have to undo that after testing befor you can conitnue the bisect.
  2. --no-checkout: run git bisect start --no-checkout. Now the steps won’t have any effect on your repo, apart from setting a BISECT_HEAD reference. Use this reference to check out projectB only: git checkout BISECT_HEAD path/to/projectB. Now do your test.

I would recommend the --no-checkout method. And note that while 3lectrologos’ tip did not work, it is still helpful. Giving the path of ProjectB to git bisect will allow to make use of the fact that errors could only have been introduced at revisions that contain changes to ProjectB.

Chronial
  • 66,706
  • 14
  • 93
  • 99
  • Thanks. I used this with the following script I hacked together: http://pastebin.com/Kqt7rr3N. The entire command is now: git bisect start --no-checkout -- /path/to/projectB && git bisect && git bisect && git bisect run ./bisect_tree.sh (the script needs to be in the same folder as your repository to work. – Carl Apr 24 '13 at 05:29
1

I think git bisect start -- path/to/projectB should do the trick.

Note: As pointed out in the comments below, this will not keep the rest of the repo to its most recent state, but will bisect considering only commits that made changes to the specified path.

3lectrologos
  • 9,469
  • 4
  • 39
  • 46
  • Yeah, sorry, I missed that you want to actually keep the rest to the newest version. (I'm not deleting the answer, since it might still be useful to other viewers.) – 3lectrologos Apr 24 '13 at 10:59
  • Hi, I'm just wondering, what do the "--" mean? I see them in the man entry, but there's no explanation.. Thanks! – NHDaly Nov 14 '13 at 02:53
  • @NHDaly `git bisect start` takes two categories of variable-length command line arguments ("bad/good" arguments and path arguments). The `--` signifies where the "bad/good" arguments end. In the above example, there is no "bad/good" argument, but there is one path argument. – 3lectrologos Nov 14 '13 at 09:04
  • @3lectrologos: Got it, thanks so much! (Additionally, I did manage to find another question asking the same question as my comment: [this question](http://stackoverflow.com/a/13321491/751061)) Thanks again though! – NHDaly Nov 17 '13 at 05:39