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

227 Views Asked by At

Running git diff --name-only gives me a list of files like this

file1
file2

Astyle usage goes something like this

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

Instead of specifying each file manually I'd like a way to pipe the output of git diff --name-only as the list of files specified in the astyle program call.

Anyone know how to do this?

2

There are 2 best solutions below

2
phd On BEST ANSWER

Also for Bash:

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

$() is command substitution.

0
azbarcea On

What about using Git Bash or cygwin or any linux emulator on windows:

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

You can also do it using Powershell.