views:

42

answers:

1

Hello everybody, 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.

+1  A: 

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.

cypheon