|
From: Ethan A M. <sf...@us...> - 2017-11-17 22:12:10
|
On Friday, November 17, 2017 1:39:17 PM PST you wrote: > Ethan A Merritt via gnuplot-beta <gnu...@li...> writes: > > > The entire patch file containing this piece is rejected by "git apply" > > or "git am", apparently because it does not like the syntax "@@ -0,0" > > which diff/patch use to indicate "top of file". > > -0,0 doesn't just indicate "top of file". It indicates that the file was > empty prior to this patch. Was that the case here? -0,0 +1,4 means replace 0 lines starting at line 0 with 4 lines starting at line 1. This is true whether or not the file was originally empty. -1,0 +1,4 means the same except that it fails or warns if applied against an empty file. > > I can apply the patch manually using "patch" and then run "git commit", > > but this loses the commit message and author information that was in > > the original formatted patch. > > > > Is there some config option for "git am" and/or "git apply" that tells > > it to accept this syntax in a patch file? > > Don't know off the top of my head. Generall 'git am' is used as the > complement to 'git format', but that's not what you're doing. If you > just did a 'git format' and then a 'git am' on the tree at the same > revision, it MUST work. The point of the operation is that it is not at the same revision. What I'm trying to do is convert my usual workflow into git-speak. New features are developed and tested against the development branch. If they pan out, I go back and apply them to the stable branch. I figured that in git this is equivalent to 1) git checkout origin 2) git format-patch --start-number 1 XXX..YYY where XXX was the commit in the development branch just before addition of the feature in question and YYY the commit just after 3) git checkout branch-5-2-stable 4) git am < 0*.patch Unfortunately (4) will never work as-is because the ChangeLog is very different between the two branches. On the other hand I know that the modification to the ChangeLog is always at the top, so I edit the formatted patch as I showed so that the ChangeLog diffs refer specifically to the top of the file. The equivalent has always worked for me in the past for patches generated by "diiff". And it still works with the output from "git format-patch" so long as I apply the patch with "patch" rather than with "git". The closest I have come is git am <0*.patch # fails with error about patch format patch --no-backup < 0*patch git stage --all # register the patched files in the staging area git am --continue # works if I'm lucky but not always Is there some totally different recommended way to replicate changes previously made to one branch and apply them to a different branch? Ethan |