1

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?

azbarcea
  • 3,323
  • 1
  • 20
  • 25
Peter Kapteyn
  • 354
  • 1
  • 13

2 Answers2

1

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.

azbarcea
  • 3,323
  • 1
  • 20
  • 25
1

Also for Bash:

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

$() is command substitution.

phd
  • 82,685
  • 13
  • 120
  • 165
  • `git diff --name-only` will return a multi-line output. In order for the above to work, one needs to translate from `f1\nf2` to `f1 f2`. Considering this runs on windows, with very inconsistent behavior between shells ... it may be a little challenging. – azbarcea Sep 22 '21 at 19:08
  • @azbarcea I mentioned `bash` and it does that automatically. Try `echo $(git diff --name-only)` – phd Sep 22 '21 at 19:51