Computing > Programming

[solved] how do you compare two folders? to extract source diff

(1/4) > >>

Usually when I work with Linux kernels, I download the source, and immediately create a git branch labelled "original code", so I can commit my changes on it, and this way it's easy to extract patches.

Now I am working on a two and large kernels, my colleagues didn't use Git, and differences between kernel-A and kernel-B are unclear.

Kernel-A and kernel-B are derived from the same source, but they are two different branches, both bugged, and with different working and not working stuff.

Within each main folder, the sources are distributed in several sub-folders, with a deep hierarchy. I see that some sub-folders have been renamed, deleted or added, as well as some of the contained files.

This is bad without Git, because it's not immediately clear how to know how a file was renamed or where it was moved.

How would you compare two folders, to extract diff, in this case?  :D

If they are not completely different "ls -lR > /tmp/old" the same for the other version, in another file, then diff. Crude, but may work.
Another possibility with for:
for file in d1/*.cpp; do
    diff "$file" "d2/${file##*/}"

You can also do it with find, connot do it out of my head now... but something like:
find /path/to/src -exec diff {} d2/${file##*/} \;
I'm sure it's wrong... but something along the lines should do.

Well under linux of course there are several 'diff' related tools.
And a UI tool called 'meld'.

But since you know these kernels came from git maybe you can take the 'A' project, find out what git branch it was based on 'AO',
check out that branch, and populate the 'A' files on top of 'AO' then you have some git-able differences fro 'A' to 'AO'.

Do the same for distribution 'B' and 'BO'.

Then you can use a git related history mechanism to relate the changes that led from 'AO' and 'BO' (assuming you have the public git history relating the parental branches from the and also deltas from 'A' -> 'AO' and 'B' -> 'BO' so you can relate the 'local feature branches' as well.

Then the problem can become the same as trying to relate 2.6.33 to 2.6.28 or whatever history relationship exists for the ancestry of the kernels in question with
your usual IDEs and git aware tools.

Any decent diff tool will work on directories and recursively.

But, well, I don't know how different your two kernels are. But good luck analyzing every single difference in all source files. That could be a very time-consuming work.

Kids these days ::)

--- Quote ---If you must generate your patches by hand, use ``diff -up`` or ``diff -uprN``
to create patches.  Git generates patches in this form by default; if
you're using ``git``, you can skip this section entirely.
--- End quote ---


--- Quote from: DiTBho on July 11, 2021, 03:33:43 pm ---I see that some sub-folders have been renamed, deleted or added, as well as some of the contained files.

--- End quote ---
Nevermind, that's gonna suck big time. Not sure what could find renamed files and directiories, particularly if they have been modified too.


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version