1

I have a snapshot of a linux kernel provided by a company for one of their devices pursuant to the prescriptions by GPL.

I also have a history of the linux kernel as a git repository (with many commits older than the snapshot and many newer ones).

I would now like identify the "least common denominator" commit at which the company diverged from the official kernel tree. Using this I would like to separate the changes made by the company from the changes made to the official kernel after the company diverged from the official kernel sources.

Is this possible? (At least a good estimate.)

ARF
  • 7,420
  • 8
  • 45
  • 72

2 Answers2

2

A modification of the other answer, you could take the diff itself

  1. Add your tree as orphaned commit, as described here

Do it with command:

git checkout --orphan patched_kernel
git rm -rf .
<copy or extract the tree to current directory>
git add .
git commit -m 'Patched kernel'
  1. for commits in suspicious range, run git diff --shortstat COMMIT, it will print something like "N lines changed, M insertions, K deletions". You need to find a commit with minimal counts.
max630
  • 8,762
  • 3
  • 30
  • 55
  • That looks very simple. Do you know, if there is a way of running a command, e.g. `git diff --shortstat COMMIT`, automatically for every commit in a provided range of commits? – ARF Jan 02 '18 at 12:56
1

You can get close, but probably can't get an exact match.

Here is what I would do:

  1. Check the Makefile of the tree you have to find the version (e.g. 4.15). Use this to narrow down the range of possible commits (only those where the Maekfile had this version)

  2. Take a SHA1 signature of all the files in the tree you have - e.g.

    find . -not -path ./.git -type f -exec sha256sum {} \; > kernel.log

  3. Do the same for each commit in the range and keep the resulting files

  4. Diff the log from the tree you have and from each commit. The one with the smallest diff is your best bet. They may be more than one option

gby
  • 14,900
  • 40
  • 57