   "Reformat Clojure(script) source files"
   {:boot/export-tasks true}
   (:require [clojure.set]
+            [clojure.string]
+            [clojure.java.shell]
             [boot-fmt.impl :as impl]
             [boot.core :as bc]
             [boot.util :as bu]))
+
+(defn find-files-git []
+  (let [{:keys [exit out err]} (clojure.java.shell/sh "git" "ls-fileszzz" "-z" "*.clj" "*.cljs" "*.cljc" "*.boot")]
+    (when (not= exit 0)
+      (throw (ex-info "git ls-files failed"
+                      {:err err})))
+    (-> out
+        (clojure.string/split #"\000")
+        set)))
+
+(defn find-files-source []
+  (clojure.set/union (bc/get-env :source-paths) (bc/get-env :resource-paths)))
 
 ;!zprint {:format :skip}
 

  [m mode MODE kw "Mode of operation, i.e. print, list, diff or overwrite. Defaults to print"
   r really bool "In overwrite mode, files are overwritten only if the --really flag is set as well"
   f files VAL #{str} "The list of files or directories to format"
   s source bool "Automatically scan for source file in boot source directories"
   o options OPTS edn "zprint options"]
  (let [mode (or mode :print)
        files (cond-> files
                source (clojure.set/union (bc/get-env :source-paths) (bc/get-env :resource-paths)))]
    (assert (seq files) "At least one filename needs to be provided.")
    (assert (#{:print :list :diff :overwrite} mode) "Invalid mode")
    (assert (or (not= :overwrite mode) really)

                            (map clojure.java.io/file)
                            (mapcat (fn [f]
                                      (if (.isDirectory f) (file-seq f) [f])))
                            (filter impl/clj-file?)
                            set
                            sort)]
        (impl/process-many {:mode mode
                            :zprint-options options} files*)
        fileset))))
