如何在git am中使用bash filedescriptors?

时间:2016-02-11 15:44:15

标签: git bash github

这可能有点深奥,但它让我很困惑。

git am是一个应用mbox的漂亮工具。与git apply应用补丁文件git am非常相似,将应用一系列补丁文件。它们使用的一个关键区别是git am需要一个文件才能使用,而git apply很乐意接受一个流。例如:

git apply /path/to/foo   # Works
git apply < /path/to/foo # Works
git am /path/to/foo      # Works
git am < /path/to/foo    # Does not work

由于GitHub会在.patch附加到提交时输出补丁文件,因此只有curl与这些文件一起使用才有意义。

我可以应用修补程序但是松开了提交元数据:

curl -L https://github.com/user/repo/commit/bada55.patch | git apply
# Or better
git apply <(curl -L https://github.com/user/repo/commit/bada55.patch)

但相比之下,我想要元数据,所以我更喜欢使用git am。问题是git am奇怪地不起作用。管道确实有效:

curl -L https://github.com/user/repo/commit/bada55.patch | git am -

我更喜欢使用文件描述符:

git am <(curl -L https://github.com/user/repo/commit/bada55.patch)

然而,这会导致以下错误:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   612    0   612    0     0   1624      0 --:--:-- --:--:-- --:--:--  1627
error: cannot read mbox /dev/fd/63
error: cannot split patches from /dev/fd/63
fatal: Failed to split patches.

为什么不进行上述工作。我认为<(…)语法接受了命令的输出并将其放在fifo中,就好像它被保存到文件中一样。  引擎盖下发生了什么?

0 个答案:

没有答案