简体   繁体   中英

Issue while patching the same line in source code

I am trying a patch a file but facing an issue ,Patch is trying to modifying the line which is also modifed by some other patch and for some reason I can't made both the changes through one single patch.

So can anybody let me know how should I go about it?

EDIT: Below is my first patch file

  @@ -1,4 +1,4 @@
 -myuser:*:0:0:root:/root:/bin/bash
 +myuser::0:0:root:/root:/bin/sh

Now I have to make some more changes to +myuser::0:0:root:/root:/bin/sh and it has to come through some other patch.

When I tried to patch this line again through second patch ,getting error(Hunk failed at line 1)

Yes, it is the sonamed "merge", what you want to do :-) Merging means if we want to unify two different change on a source code so. It is not always simple, and this is your case, too.

What you probably wanted (always problem-free merge), that is impossible. Patch does, what it can, and tries not to destroy anything (for example: a bad apply makes much more headache as a rejection).

For GNU Patch (this what you probably use) there is a flag to make a more aggressive merge.

Practically you should see the code, interpret what the patches do, apply one of the patches with the patch tool, and apply a second by hand.

Google for "merging tools" or some.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM