如何 运行 对 git diff --name-only 指定的文件列表进行 astyle

How to run astyle over the list of files specified by git diff --name-only

运行 git diff --name-only 给我一个这样的文件列表

file1
file2

Astyle 的用法是这样的

astyle.exe --options=myoptionsfile <file1> <file2>

我不想手动指定每个文件,而是希望通过管道将 git diff --name-only 的输出作为在 astyle 程序调用中指定的文件列表。

有人知道怎么做吗?

如何在 windows 上使用 Git Bashcygwin 或任何 linux 模拟器:

git diff --name-only | xargs astyle.exe --options=myoptionsfile

你也可以using Powershell.

也适用于Bash:

astyle.exe --options=myoptionsfile $(git diff --name-only)

$()command substitution