Patch applied with system's patch but rejected by git-apply -


i'm trying understand how git apply unified diffs.

i wrote following "identity" patch:

--- a/js/controllers.js +++ b/js/controllers.js @@ -15,3 +15,3 @@ -  '$location', -  function ($scope, $routeparams, $location) { -    dosomething(); +  '$location', +  function ($scope, $routeparams, $location) { +    dosomething(); 

the system's patch command applies patch success while git-apply gives following output:

error: patch failed: [...]js/controllers.js:15 error: [...]js/controllers.js: patch not apply 

i don't understand why.

your patch has no context. diff have included few unmodified lines before , after changes well. git apply documentation:

--unidiff-zero

by default, git apply expects patch being applied unified diff @ least 1 line of context. provides safety measures, breaks down when applying diff generated --unified=0. bypass these checks use --unidiff-zero.

note, reasons stated above usage of context-free patches discouraged.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -