0

I need to apply some code changes to a source code file I don't have access to. I write code but rely on someone else to test it for me because my old computer has trouble with VMs. Most of the changes are fixing small syntax errors, but I think there were some code instertions, some newlines, etc. I've never used diff in this way before. And I've never used patch ever. Is this possible?

3
Contributors
4
Replies
8
Views
3 Years
Discussion Span
Last Post by rubberman
0

diff is used to find the differences between two files. So you will need a copy of the file before the changes were made and a copy of the file after the changes were made.

0

in other words no. Thats OK. I noticed diff worked by identifying line numbers where files differed I hoped that if perhaps the files had the same number of lines, changes could still be made. But I also noticed there are different versions of a diff file.

0

There has to be two versions of the file so that diff can tell you the differences. How would you expect diff to work with only 1 file??? The two files don't have to have the same number of lines, at least not with the diff pogram I've used in MS-Windows.

0

Depending upon how you use it, diff can generate files that the patch command can use to update a source file by merging the deltas between the two versions. You need to read the man pages for diff and patch in detail in order to understand how that works, and whether it is applicable for your needs. This technique is commonly used when distribution source code patches for Linux system software, so there is abundant information on the web that can help. Remember, Google (or DuckDuckGo) is your friend! :-)

In any case, if you get the original version of a source file and edit it, you can use diff to generate the deltas that the patch command can be used to create a new (and hopefully fixed) source file.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.