从上游分支合并到供应商分支,其中供应商分支包含上游提交的子集

发布于 2024-11-05 05:18:59 字数 1140 浏览 1 评论 0原文

我正在与一家供应商合作,该供应商为 Linux 内核提供补丁集,以便在其平台上支持 Android。这意味着他们的补丁串基于特定的 Linux 版本,并且在他们的补丁串中包含了一些 Android 补丁(我假设是精心挑选的),这些补丁适用于相同的 Linux 版本。

因此,当导入到 git 以及我们在顶部应用的更改时,历史记录看起来像这样:

     v2.6.x.y                          v_rel_x.y      o_rel_z
l--l--l---------v--v--a--v--a--a--v--v--v--------o--o--o

其中 l 是 linux 提交,v 是供应商提交,a 是 android 提交,o 是我们的提交。

让事情变得复杂的是,基于相同 Linux 内核版本的 android git 内核源代码是完全独立的,如下所示:

     v2.6.x.y      v2.6.x.y+1
l--l--l---------l---l
       \             \           android-2.6.x
        \             a--a--a--a--a
         \
          \                       v_rel_x.y      o_rel_z
           v--v--a--v--a--a--v--v--v--------o--o--o

现在,我想在 android-2.6.x 版本中包含所有 android 补丁,但是我也想要所有供应商都提供补丁来支持他们的平台。不幸的是,v2.6.x.y+1..android-2.6.x 变更集中的相当多的更改已经应用于 v_rel_x.y 分支。因此,从 android-2.6.x 到 o_rel_z 的简单合并会产生大量冲突,而这些冲突根本无法手动解决。

你知道如何可靠地执行从 android-2.6.x 到 o_rel_z 的合并吗?

是的,每个分支上确实有大量的提交,并且 v_rel_x 上的 android 补丁.y 与供应商补丁完全纠缠在一起。

I am working with a vendor who provides a patchset to the linux kernel in order to support android on top of their platform. This means that they base their string of patches on a specific linux version, and in their string of patches some of the android patches are included (cherry-picked I assume), which are applied to the same linux version.

So the history looks something like this when imported into git along with our changes which are applied on top:

     v2.6.x.y                          v_rel_x.y      o_rel_z
l--l--l---------v--v--a--v--a--a--v--v--v--------o--o--o

Where l are linux commits, v are vendor commits, a are android commits, and o are our commits.

What makes this complicated is that the android git kernel source based on the same linux kernel version is completely separate, looking like this:

     v2.6.x.y      v2.6.x.y+1
l--l--l---------l---l
       \             \           android-2.6.x
        \             a--a--a--a--a
         \
          \                       v_rel_x.y      o_rel_z
           v--v--a--v--a--a--v--v--v--------o--o--o

Now, I want to include all of the android patches in the android-2.6.x release, however I also want all the vendors patches to support their platform. Unfortunately quite a few of the changes in the v2.6.x.y+1..android-2.6.x changeset are already applied to the v_rel_x.y branch. Thus a simple merge from android-2.6.x to o_rel_z creates a huge number of conflicts, which are simply impossible to solve by hand.

Do you have any idea on how to perform the merge from android-2.6.x to o_rel_z reliably?

And yes, there are really a huge number of commits on each branch, and the android patches on the v_rel_x.y are completely entangled with the vendor patches.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢华的一滴泪 2024-11-12 05:18:59

我的两点意见:

  1. 冲突的原因不是你挑选了一些提交,而是因为一些提交正在相同的位置更改相同的文件,而 git 无法干净地应用差异。
  2. 如果发生冲突的更改,您没有太多选择:
    a) 合并并解决冲突以使代码达到理想的状态
    b) 您尝试通过使用诸如 --ours 或 --theirs 之类的合并策略进行合并来自动解决冲突,具体取决于您认为更适合您的目的。

请参阅此处 Git 合并文档

您可以使用的另一种方法尝试是在更新的上游 android-2.6.x 之上重新调整 0_rel_z 分支的基础。

最后,您的问题不是冲突本身,而是您必须立即处理的冲突数量。因此,我会考虑改进管理更新的流程,可能会更频繁地进行更新(例如,每天与每周),并在更新上游的基础上不断重新调整您的开发分支,直到您准备好完成一项功能的开发。

希望有帮助!

My two cents:

  1. The reason of conflict is not that you have some of the commits cherry picked, but because some of the commits are changing the same files in the same places and git cannot apply the diff cleanly.
  2. In case of conflicting changes you don't have many choices:
    a) you merge and resolve conflicts to bring the code to the desirable state
    b) you're trying to resolve conflicts automatically by merging using merging strategies like --ours or --theirs depending on what you consider more correct for your purposes.

See here Git merge documentation

Another approach you may try is to rebase your 0_rel_z branch on top of the updated upstream android-2.6.x

Finally, your problem is not the conflicts them-selves, but the amount of them that you have to deal with at once. So I would take a look at improving the process how you are managing the updates, may be to make this more often (daily vs weekly, for example) and constantly rebasing your development branches on top of the updating upstream until you're ready to finalize the development of a feature.

Hope that helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文