2 cdw116999 cdw116999 于 2016.04.08 14:06 提问

linux下补丁diff与patch,打补丁不成功

1 两个目录:test/a.c test_new/{a.c, abc/abc.c} //test_new下有a.c以及abc目录(目录下有abc.c文件)

2 我原以为打补丁不成功是权限问题,所以更改权限
chmod -R 0775 test test_new

3 制作补丁文件
diff -Naur test test_new > test.patch
修改test.patch权限为0777也不行

4 打补丁
打印信息:
The next patch would create the file test_new/abc/abc.c,
which already exists! Assume -R? [n] n
Apply anyway? [n] n
Skipping patch.
1 out of 1 hunk ignored
patching file test_new/abc/abc.c
Hunk #1 FAILED at 1 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file test_new/abc/abc.c.rej

abc.c.rej:
1 --- test/abc/abc.c 1970-01-01 08:00:00.000000000 +0800
2 +++ test_new/abc/abc.c 2016-02-25 09:14:58.834541600 +0800
3 @@ -0,0 +1,13 @@
4 +#include ^M
5 +#include ^M
6 +^M
7 +int main(void)^M
8 +{ ^M
9 + int i = 0;^M
10 + int sum = 0^M
11 + while(i++ < 10){^M
12 + sum += i;^M
13 + }^M
14 +^M
15 + printf("sum = %d\n", sum);^M
16 +}

尝试在test_new目录下新建一个b.c,打补丁时同样报上面信息,无法成功打补丁

1个回答

CSDNXIAON
CSDNXIAON   2016.04.08 14:13

diff和patch 打补丁
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!