通过管道传递 subversion 修订版号以进行 diff
好的,所以我可以运行这样的命令来获取在特定日期或日期范围内制作的修订号列表:
svn log -q -r{2012-01-25}:HEAD | grep '^r[0-9]' | cut -d\| -f1 | cut -b2-
这工作正常并给我一个像这样的列表
12345
12346
12347
现在,我想将这些修订号传递给 diff 命令,因此在修订号上手动运行简单的 svn diff 可以按预期工作,即
svn diff -c12345
但是,如果我尝试像这样将修订列表通过管道传输到 diff 命令,
svn log -q -r{2012-01-25}:HEAD | grep '^r[0-9]' | cut -d\| -f1 | cut -b2- | xargs svn diff -c
它会返回一个错误,指出未找到节点 - 在我看来,我正在传递论点错误。
OK, so I can run a command like this to get a list of revision numbers made on a certain date or date range:
svn log -q -r{2012-01-25}:HEAD | grep '^r[0-9]' | cut -d\| -f1 | cut -b2-
This works fine and gives me a list like this
12345
12346
12347
Now, I would like to pass these revision numbers to the diff command, so running a simple svn diff on a revision number manually works as expected i.e.
svn diff -c12345
But, if I attempt to pipe the revision list to the diff command like this
svn log -q -r{2012-01-25}:HEAD | grep '^r[0-9]' | cut -d\| -f1 | cut -b2- | xargs svn diff -c
it returns an error that the node was not found - looks to me like I am passing the arguments wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来,在管道的最后一部分,
xargs
正在尝试执行:当它应该尝试时:
因为
-c
选项只接受一个参数。要解决此问题,请尝试将
xargs
替换为xargs -n1
。It looks like, in the last part of the pipe,
xargs
is trying to execute:when it should try:
because the
-c
option only accepts one argument.To fix that, try to replace
xargs
withxargs -n1
.问题是
12345
、12346
、12347
中的每一个都作为单独的参数传递;您需要将其与-c
连接成单个参数。假设您使用的是
xargs
的 GNU findutils 版本,则可以使用-I
选项。不使用 svn 的示例:请注意,这将为每个版本号调用一次
svn diff
。您的命令使用多个版本号调用svn
一次。如果您想为多个版本号调用一次 svn:那么就需要不同的解决方案。
编辑:
阅读其他答案和 svn 文档,看起来您可以在
-c
之后有一个空格,因此svn diff -c12345
或 svn diff -c 12345 有效。在这种情况下,只需使用-n 1
就可以解决问题。The problem is that each of
12345
,12346
,12347
is passed as a separate argument; you need it to be joined with the-c
into a single argument.Assuming you're using the GNU findutils version of
xargs
, you can use the-I
option. An example not using svn:Note that this invokes
svn diff
once for each version number. Your command invokessvn
once with multiple version numbers. If you want to invoke svn once for multiple version numbers:then a different solution will be necessary.
EDIT :
Reading the other answer and the svn documentation, it looks like you can have a space after
-c
, so eithersvn diff -c12345
orsvn diff -c 12345
is valid. In that case, just using-n 1
should do the trick.