如何在git树顶部应用补丁来防止重复? [英] How to apply patches on the top of a git tree preventing duplication?

查看:157
本文介绍了如何在git树顶部应用补丁来防止重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻求一个我认为简单的问题的建议,通过创建一个小脚本可能很简单,但是我认为应该已经有了一个方法,可以用git / quilt / stgit来实现。 / p>

我不太了解git,这对我造成了一些问题。



我的问题:
我有一个git树(linux内核)和一些补丁。会发生什么,这样的修补程序是针对和旧版本的内核,其中许多已经应用到我的树。补丁以标题行开始,如

 从b1af4315d823a2b6659c5b14bc17f7bc61878ef4(timestamp)

,并通过执行类似

  git show b1af4315d823a2b6659c5b14bc17f7bc61878ef4 $ b我的内核树中的$ b  

我可以看到它们已经在我当前的树中可用了,我不我试图使用 git应用 git am 之类的东西,但是他们似乎是尝试应用补丁:

  alan @ ubuntu:〜/ Desktop / openwrt / linux-git / linux-2.6.33 .y $ git apply -p1 --check --index / home / alan / Desktop / openwrt / svn / backfire-branch / build_dir / linux-kirkwood / linux- 2.6.30.10/patches/generic/000-bzip_lzma_remove_nasty_hack.patch 
错误:修补程序失败:lib / decompress_bunzip2.c:45
错误:lib / decompress_bunzip2.c:修补程序不应用
错误:修补程序失败:lib / decompress_unlz ma.c:29
错误:lib / decompress_unlzma.c:补丁不适用

所以:有没有任何命令/ util来执行一个补丁是否已经应用在当前的树上,并且它有一个git apply,如果没有,只是跳过补丁,如果它有?



谢谢。

解决方案

您可以创建一个新版本的分支,这些补丁是制作的,而不是应用它们并将temp-branch合并到master中:

  git checkout -b temp-branch v2 .6.30 
git apply / am ... patches ...
git checkout master
git merge temp-branch

这应该解决大多数重复的修补程序(虽然不会使用提交ID,而是补丁内容)。此外,您可以在最后一步尝试 git rebase



这不是最优雅的方式,但应该做窍门。


I'm seeking advice for a problem that I thought to be simple, and it might be simple indeed by creating a small script, but I think there should already be a way to do that with git/quilt/stgit.

I'm not exactly good at git and this is causing some issues to me.

My problem: I've got a git tree (linux kernel) and a number of patches. What happens, such patches were intended for and older version of the kernel, and many of them have already been applied to my tree. The patches start with an header line like

From b1af4315d823a2b6659c5b14bc17f7bc61878ef4 (timestamp)

and by doing something like

git show b1af4315d823a2b6659c5b14bc17f7bc61878ef4

in my kernel tree, I can see they're already available in my current tree, and I don't ever want to try applying them.

I tried using things like git apply or git am , but they seem to try applying the patch whatsoever:

alan@ubuntu:~/Desktop/openwrt/linux-git/linux-2.6.33.y$ git apply -p1 --check --index        /home/alan/Desktop/openwrt/svn/backfire-branch/build_dir/linux-kirkwood/linux-    2.6.30.10/patches/generic/000-bzip_lzma_remove_nasty_hack.patch
error: patch failed: lib/decompress_bunzip2.c:45
error: lib/decompress_bunzip2.c: patch does not apply
error: patch failed: lib/decompress_unlzma.c:29
error: lib/decompress_unlzma.c: patch does not apply

So: is there any command/util that performs a check whether a patch has already been applied on the current tree, and it does a "git apply" if it hasn't, and just skips the patch if it has?

Thanks.

解决方案

You can create a new branch of the version, for which the patches were made, than apply them and merge the temp-branch into master:

git checkout -b temp-branch v2.6.30
git apply/am ...patches...
git checkout master
git merge temp-branch

This should resolve most duplicated patches (although, it won't use the commit id, but rather patch contents). Also, you could try git rebase in the last step.

It's not the most elegant way, but should do the trick.

这篇关于如何在git树顶部应用补丁来防止重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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