如何提取统一差异样式补丁子集?
每次我想要获取补丁的子集时,我都被迫编写一个脚本来仅提取我想要的索引。
例如我有一个适用于子目录的补丁 “耶”和“富”。
有没有办法创建新补丁或仅应用补丁的子集? 即从现有补丁创建一个新补丁,该补丁仅采用子目录“yay”下的所有索引。 或者不在子目录“foo”下的所有索引
如果我有一个类似的补丁(请原谅下面的伪补丁):
Index : foo/bar
yada
yada
- asdf
+ jkl
yada
yada
Index : foo/bah
blah
blah
- 28
+ 29
blah
blah
blah
Index : yay/team
go
huskies
- happy happy
+ joy joy
cougars
suck
我如何提取或仅应用“yay”子目录,例如:
Index : yay/team
go
huskies
- happy happy
+ joy joy
cougars
suck
我知道我是否编写了一个解决方案会重新发明轮子...
Every time I want to take a subset of a patch, I'm forced to write a script to only extract the indices that I want.
e.g. I have a patch that applies to sub directories
'yay' and 'foo'.
Is there a way to create a new patch or apply only a subset of a patch? i.e. create a new patch from the existing patch that only takes all indices that are under sub directory 'yay'. Or all indices that are not under sub directory 'foo'
If I have a patch like ( excuse the below pseudo-patch):
Index : foo/bar
yada
yada
- asdf
+ jkl
yada
yada
Index : foo/bah
blah
blah
- 28
+ 29
blah
blah
blah
Index : yay/team
go
huskies
- happy happy
+ joy joy
cougars
suck
How can I extract or apply only the 'yay' subdirectory like:
Index : yay/team
go
huskies
- happy happy
+ joy joy
cougars
suck
I know if I script up a solution I'll be re-inventing the wheel...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看一下
filterdiff
实用程序,它是 patchutils。例如,如果您有以下补丁:
那么您可以运行以下命令来仅为
a
目录中的内容提取补丁,如下所示:Take a look at the
filterdiff
utility, which is part of patchutils.For example, if you have the following patch:
Then you can run the following command to extract the patch for only things in the
a
directory like this:这是我的快速但肮脏的 Perl 解决方案。
Here's my quick and dirty Perl solution.
为了响应 sigjuice 在评论中的请求,我发布了我的脚本解决方案。 它不是 100% 防弹,我可能会使用
filterdiff
代替。In response to sigjuice's request in the comments, I'm posting my script solution. It isn't 100% bullet proof, and I'll probably use
filterdiff
instead.