你如何让git bisect忽略合并的分支? [英] How do you get git bisect to ignore merged branches?

查看:163
本文介绍了你如何让git bisect忽略合并的分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道git bisect是通过设计感知的,所以如果在良好的提交,G和错误的提交B之间合并了一个分支,它也需要考虑这些更改,就像该错误可能包含在分支中。



在我的情况下,我有一个依赖项作为一个分支,我不时合并主项目的变化。依赖关系可以被认为是一个库,它具有不同的运行方式,不同的构建系统等等,但我仍然希望通过合并到主分支来进行最近的更改。



现在的问题是,在这种情况下平分的时候,你最终会在依赖项提交中进行不可编译的提交。



我真的只是想把每个分支合并视为一个单独的提交而已。



到目前为止我发现的解决方法是创建一个有效的提交列表G..B使用git log --first-parent,然后在平分的时候,如果当前提交不在该列表中,则执行git bisect skip。这需要很多时间,但是(每个跳过都需要大量文件来检查/更改)。



所以问题是:有没有办法做--first-父母与git bisect或提供我觉得有效的提交清单能够避免检查我知道已经不可编译的分支?我们如何检查图中标记为 o 的提交?

 
G --- o --- o --- o --- o --- o --- o --- B主项目分支
/ / /
x --- x --- x --- x-- -x依赖项
\ /
x'依赖项目任务分支

编辑:为了清晰起见,我添加了一个图表

解决方案

我一直在寻找类似的东西。据我所知, git rev-list --bisect --first-parent 似乎可以做你想做的事,而rev-list的文档意味着 - bisect 选项是bisect内部使用的选项 - 但获取 git bisect 可将该标志添加到其调用中s $)rev-list似乎不那么简单:bisect命令是由一个shell脚本git-bisect实现的,该脚本又使用一个内置命令 bisect - helper 实际上做了有趣的部分(计算,显示和结帐说评论...),显然是基于一堆魔术状态文件在.git /中。而且它似乎是rev-list命令,它可以重复使用来自bisect-helper的代码,而不是像你所期望的那样。

我认为必须扩展bisect - helper代码的提交过滤。



作为一个解决方法,类似这样的工作可能会奏效:在bisect检查了一些东西之后,使用 git rev-list --bisect --first-parent 重置为另一个,测试并标记为好/不好/跳过并继续。


I'm aware that git bisect is branch-aware by design, so that if between good commit, G, and bad commit, B, you merged in a branch, it needs to take those changes into consideration as well, as the bug may be contained in the branch.

In my case I have a dependency as a side branch and I merge in changes to my main project from time to time. The dependency can be considered a library that has a different way of running, different build-system etc. from my main project, but I still want recent changes from it via merges to the main branch.

The problem is then that while bisecting in this scenario, you end up on non-compilable commits in the commits from the dependency.

I would really just want to consider each branch merge as a single commit while doing the bisection.

A workaround I've found so far is making a list of valid commits G..B with git log --first-parent, and then while bisecting, do git bisect skip if the current commit isn't in that list. That takes a lot of time though (lots of files to checkout/change for each skip).

So the question is: Is there any way of doing --first-parent with git bisect or providing a list of commits i feel are valid to be able to avoid checking out branches I know already are not compilable? How do we only check the commits marked o in the diagram?

G---o---o---o---o---o---o---B  main project branch
   /       /       / 
  x---x---x---x---x            dependency
           \ /
            x'                 dependency project taskbranch

Edit: added diagram for clarity

解决方案

I've been looking for something like this too. As far as I've got is that git rev-list --bisect --first-parent seems to do what you want to, and the docs for rev-list implies that the --bisect option is what bisect uses internally - but getting git bisect to add that flag to its call(s) to rev-list seems less trivial:

The bisect command is implemented by a shell script git-bisect, which in turn uses a builtin command bisect--helper to actually do the interesting part ("computation, display and checkout" says the comment...), apparently based on a bunch of magic state files in .git/. And it seems to be the rev-list command that is reusing code from bisect--helper rather than the other way around as you might expect.

So, you'd have to extend the bisect--helper code's commit filtering to do it, I think.

As a workaround, something like this might work: after bisect checks something out for you, reset to a different one using git rev-list --bisect --first-parent, test that and mark it good/bad/skip and continue from there.

这篇关于你如何让git bisect忽略合并的分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆