Hi i have one doubt when creating patch files. if consider a file a.txt it contains This is a simple file. i added to git and commit it. Next i changed the file as This is a slightly more complex file. Again i added to git and commit it. Now if i create a patch by using the below commands git format-patch -n HEAD git show HEAD > somepatch.patch the contents in somepatch.patch are shown below commit 0e1d77b66e708580a07530e8c1bf20546a701c6f Author: <UserName> <xxxxxxxxx@gmail.com> Date: Tue Jun 3 22:02:57 2014 +0530 Next Commit diff --git a/a.txt b/a.txt index 76e499a..c341c1c 100644 --- a/a.txt +++ b/a.txt @@ -1,5 +1,5 @@ this is a -simple +slightly more complex file file. My doubt is how to create patch file which contains the modifications only i.e lines with "+" only why because for example initially if a file contains 1000 rows after i changed 2 lines but in the patch file it is taking entire 1000+2 lines.So is there any way to generate patch with only modified lines? Thank you
On Tue, 03 Jun 2014 22:15:21 +0530, me storage said:
diff --git a/a.txt b/a.txt index 76e499a..c341c1c 100644 --- a/a.txt +++ b/a.txt @@ -1,5 +1,5 @@ this is a -simple +slightly more complex file file.
My doubt is how to create patch file which contains the modifications only i.e lines with "+" only why because for example initially if a file contains 1000 rows.
It's showing the first 3 lines and the last line because of "context" - when the patch is finally applied, the change may not apply at line 4, due to *other* patches having added/deleted lines. Usually git will display 3 lines either side of the changed line. Go ahead, create a 25 line patch, and change line 15, and see what the diff shows then.
On Die, 2014-06-03 at 22:15 +0530, me storage wrote: [...]
My doubt is how to create patch file which contains the modifications only i.e lines with "+" only why because for example initially if a file contains 1000 rows after i changed 2 lines but in the patch file it is taking entire 1000+2 lines.So is there any way to generate patch with only modified lines?
Well, you are extrapolating from your simple (and thus quite small) lab test to the (big;-) reality without actually trying it. That is more often than not not working anyways (and IMHO it doesn't work at all in almost all cases). So it would have been better to actually to simply try a `diff` (with and without `git`) on a file with 1000 lines. Kind regards, Bernd -- "What happens when you read some doc and either it doesn't answer your question or is demonstrably wrong? In Linux, you say "Linux sucks" and go read the code. In Windows/Oracle/etc you say "Windows sucks" and start banging your head against the wall." - Denis Vlasenko on lkml
participants (3)
-
Bernd Petrovitsch -
me storage -
Valdis.Kletnieks@vt.edu