git-file-format: Add a flag to format all the files.
Usage: `git-file-format --all`.
Change-Id: I935d4e102bda002685861d6860a3182a914c42d2
diff --git a/git-file-format b/git-file-format
index 39b2af2..a970939 100755
--- a/git-file-format
+++ b/git-file-format
@@ -76,14 +76,22 @@
action="store_true",
default=False,
help="tell me what you're doing")
+ parser.add_argument(
+ "--all",
+ dest="all",
+ action="store_true",
+ default=False,
+ help="format all files in the repo, not just the modified ones")
args = parser.parse_args()
# Find the files to be formatted.
diff_base = _get_diff_base()
if args.verbose:
print "Diff base: " + diff_base
- files = filter(len, subprocess.check_output(
- ["git", "diff-index", "--name-only", diff_base]).split("\n"))
+
+ list_command = ["git", "ls-files"] if args.all else [
+ "git", "diff-index", "--name-only", diff_base]
+ files = filter(len, subprocess.check_output(list_command).split("\n"))
if args.verbose:
print