2016-11-25 14:20 GMT+01:00 高阳 <crazyya...@gmail.com>: > Hello, developer! > > I use the latest version of patch-2.7.3,and find a problem ,it's maybe a bug > . > The following is the problem: > > =================case 1======================= > Then person A have file named a.txt > > a.txt: > > 11111111111 > 2222222222 > 3333333333 > 4444444444 > 5555555555 > 6666666666 > 7777777777 > > > and person B modified it : > > a.txt: > > 11111111111 > 2222222222 > aaaaaaaaaabbb > bbbbbbbbbbbbb > 3333333333 > 4444444444 > 5555555555 > 6666666666 > 7777777777 > > and person C modified it : > > 11111111111 > 2222222222 > aaaaaaaaaabbb > bbbbbbbbbbbbb > 3333333333 > 4444444444 > 5555555555 > 6666666666 > ccccccccccccc > ddddddddddddd > 7777777777 > > > Then, B and C make patch : > > diff -Naur A/a.txt B/a.txt > ab.patch > diff -Naur A/a.txt C/a.txt > ac.patch > > The person A got ab.patch and ac.patch from B and C . > > patch -d A/ -Nsp1 -i /pathto/ab.patch //ok > patch -d A/ -Nsp1 -i /pathto/ac.patch //2 out of 2 hunks ignored
I actually get this here (there's also only one hunk in ac.patch): Hunk #1 succeeded at 3 with fuzz 2 (offset 2 lines). > Finally ,the a.txt is : > > 11111111111 > 2222222222 > aaaaaaaaaabbb > bbbbbbbbbbbbb > 3333333333 > 4444444444 > 5555555555 > 6666666666 > 7777777777 > > > I Think the second patch shoud give the answer :1 out of 2 hunks ignored > ,and the finally result is : > > 11111111111 > 2222222222 > aaaaaaaaaabbb > bbbbbbbbbbbbb > 3333333333 > 4444444444 > 5555555555 > 6666666666 > ccccccccccccc > ddddddddddddd > 7777777777 Traditional patch cannot reliably detect hunks which have been applied already. Recent versions have a --merge mode which will often produce better results, like in this case. Note that there's at least one open --merge bug that hasn't been fixed yet (http://savannah.gnu.org/bugs/?42922). > ================and the other case is success ================ > > > if person C modified the file as : > > 11111111111 > ddddddddddddd > 2222222222 > aaaaaaaaaabbb > bbbbbbbbbbbbb > 3333333333 > 4444444444 > 5555555555 > 6666666666 > ccccccccccccc > ddddddddddddd > 7777777777 > > > and other step are the same. > I got the result : > patch -d A/ -Nsp1 -i /pathto/ab.patch //ok > patch -d A/ -Nsp1 -i /pathto/ac.patch //1 out of 2 hunks ignored > > the finally result: > > > 11111111111 > ddddddddddddd > 2222222222 > aaaaaaaaaabbb > bbbbbbbbbbbbb > 3333333333 > 4444444444 > 5555555555 > 6666666666 > ccccccccccccc > ddddddddddddd > 7777777777 > > > It's my expected result ! I don't know what you did there. Again, ac.patch only has one hunk with standard diff. Applying that fails with: Hunk #1 FAILED at 1. Patch --merge again produces a correct merge result here. > > ============================================ > > the case 1 is failed without the two lines: > ccccccccccccc > ddddddddddddd > > and case 2 is ok! > > So , I think it is a problem! Not sure what you mean with that. Andreas