寻找什么git的承诺约code从催生git、code

2023-09-06 05:07:33 作者:背着棺材跳舞

我有一些原始的开源$ C ​​$ C Linux内核的修改版本。理想情况下我想有一个补丁,这样我可以把它应用到内核的新版本,而是我只是有源$ C ​​$ C,所以我想创建自己的补丁。

I have some raw open-source code for a modified version of the linux kernel. Ideally I would have a patch so that I could apply it to a newer version of the kernel, but instead I just have the source code, so I'm trying to create that patch myself.

什么我的发现是,当我创建了一个补丁,并把它应用到新内核,我最终恢复了很大的变化。有没有在Git中的一项功能,可以告诉我们,如果本地更改还原previous提交?或者是有一些其他的工具,可以发现提交的最低金额的变化(即使它耗费时间,并且要在自己的机器上运行)?

What I'm finding is that when I create a patch and apply it to the newer kernel, I end up reverting a lot of changes. Is there a feature in git that can tell if local changes are reverting previous commits? Or is there some other tool that can find the commit with the least amount of changes (even if it's time consuming and has to be run on my own machine)?

我一直在手动缩小犯了什么从支源,但它是非常耗时。我发现相当密切配合,现在我试图找出最新的提交是以前更改了它做了一个分支。

I've been manually narrowing down what commit the source branched from, but it's very time consuming. I found a branch that fairly closely matched and now am trying to figure out what the latest commit was before changes were made to it.

我会检查出犯,复制已更改的文件,做一个日志上,有很多的东西,找出取出来,如果​​这些具体的变化是从提交b的加成任何文件,然后签在提交前提交B,等等,等等...

I'll check out a commit A, copy the changed files, do a log on any file that has a lot of stuff taken out to find out if those exact changes were added from commit B, then checkout the commit before commit B, etc, etc...

编辑:由于这是所有关于开源$ C ​​$ C,我看不出有任何理由为什么我不能把它共享链接在这里

Since this is all pertaining to open source code, I don't see any reason why I can't share links to it here.

由LG电子发布的源$ C ​​$ C可以发现 >。移动在搜索LS970。

The source code released by LGE can be found here. Search for LS970 under Mobile.

在MSM内核的不同分支,可以发现的此处。到目前为止, ics_strawberry 头似乎是最接近的。这是为数不多的,有一个的ChromeOS 文件夹中,这似乎是这将是一个奇怪的事情,以专门添加的,不会运行Chrome OS的手机之一。

The different branches of the MSM kernel can be found here. So far the ics_strawberry head seems to be the closest. It's one of the few that has a chromeos folder, which seems like it would be an odd thing to add specifically for a cell phone that wouldn't be running Chrome OS.

推荐答案

不幸的是,你不能使用 git的平分这里,因为你不能告诉任何承诺是否是坏的或不错。

Unfortunately, you cannot use git bisect here because you cannot tell at any commit whether it was bad or good.

你的目标是要找到犯了你的目标源相匹配最好的。我认为,什么是最佳匹配的最佳指标是统一的diff /补丁的大小(行)。

Your goal is to find commit that matches best to your target source. I think that best metric of what is "matching best" is the size (in lines) of unified diff/patch.

考虑到这一点,你可以按照下面的伪code写一个脚本(对不起,怪异的组合外壳,Perl和C):

With this in mind, you can write a script according to following pseudo-code (sorry, weird mix of shell, Perl and C):

min_diff_size = 10000000000
best_commit = none
git branch tmp original_branch  # branch to scan
git checkout tmp
for (;;) {
    diff_size = `diff -burN -x.git my_git_subtree my_src_subtree | wc -l`;
    if (diff_size < min_diff_size) {
         min_diff_size = diff_size;
         best_commit = `git log --oneline -1`;
    }
    git reset --hard HEAD~; # rewind back by 1 commit
    if (git reset did not work) break;
}
git checkout original_branch
git branch -d tmp

print "best commit $best_commit, diff size $min_diff_size"

您可能还需要循环的内核分支以及找到最匹配的分支。

You may also want to cycle through kernel branches as well to find best matching branch.

这可能会工作缓慢,需要大量的时间(可能是小时),但它会找到最匹配的承诺。

This probably will work slow and take a lot of time (could be hours), but it will find best matching commit.