| Thejesh GN | A Blog, A Website and A container for all my views with excerpts from technology, life, travel, films, india, photography, kannada, friends and other interests. I am Thejesh GN and my friends call me Thej..more. |
![]() |
|
We all use some kind of source control to maintain the code. But we developers still use mail/IM to share some changes/snippets with each other. Where you usually send the changed file, original file to your friend. There could also be a case where you have read only access to source control. It usually happens when you are working FOSS project and you are supposed prove yourself before you get check in access. This is an important notice! It should therefore be located at the beginning of this document! Thejesh GN can't do anything and everything. He doesnt know. can't you do it?? This is third line from can you do it My end of file Bye I had to update it. So here is new.txt This is an important notice! It should therefore be located at the beginning of this document! Thejesh GN can do anything and everything. can you do it?? This is third line from can you do it My end of file Bye So now I take a diff and send it to my manager to update the actual and check in. So at my shell I run diff org.txt new.txt > diff.txt --- org.txt 2009-07-31 21:44:46.233518700 +0530 +++ new.txt 2009-07-31 21:43:44.889768700 +0530 @@ -4,10 +4,10 @@ the beginning of this document! -Thejesh GN can't do anything -and everything. He doesnt know. +Thejesh GN can do anything +and everything. -can't you do it?? +can you do it?? This is third line from can you do it Patch or diff file will have
Now you can update the org.txt file just by using diff.txt. At your shell $ patch < diff.txt You patch knows what to do. All it needs is original file and diff file. It has all the details need to patch. Since the diff file has context lines surrounding the actual change. It doesn’t need you to mention the version of old file (or send it to your friend). If it cant find the context it will fail. And hence if your friend has worked on the same lines before you sent a diff, the patch will fail. Otherwise it will update your org.txt. Isn’t that easy and elegant?
3 Comments posted on "To differ and to patch up"
Prasoon on July 31st, 2009 at 10:11 PM #
Nicely explained!
ManojVasanth on August 2nd, 2009 at 1:45 PM #
Thanks for the tip Thej! That sounds neat :) Well compressed and explained in detail ;) Post a comment
|
|
||||||