xargs: git : Bad file number

拈花ヽ惹草 提交于 2019-12-22 08:06:07

问题


Anyone know what could cause this error?

I am trying to create a package on git using this command:

git diff -z --name-only --diff-filter=MAR 5e2a4b4 5261fe1 | xargs -s1000000 -0 git archive develop -o 'package.zip'

回答1:


Apart from getting the error on ssh, which you've already ruled out, it could also be that git archive can handle a limited number of argument on the command line.

You are already (suspiciously) limiting the total running length of the arguments with -s, and you indicated your command is working for some commits but not the others. You could investigate the difference further by setting GIT_TRACE=1.

Generally it is common to limit the number of arguments with xargs -n in addition to -s but beware as this will execute the command passed to xargs multiple times, when the number of arguments exceeds the -n threshold, and git archive doesn’t support appending to an archive. You will have to call a script instead, that can increment a running number for the zip archive suffix, rotate the zip filenames in some acceptable fashion, or explicitly merge the output zip files into a master zip file.

And if you are running on cygwin, EBADF can also imply that the permission to one of the files to be archived was denied by the underlying OS.



来源:https://stackoverflow.com/questions/19805233/xargs-git-bad-file-number

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!