File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
src/main/clojure/clojure/tools/gitlibs Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 11Changelog
22===========
33
4+ * next
5+ * Don't use future to background the process reading (leaves non-daemon thread)
46* 2.5.186 on Feb 11, 2023
57 * Don't block on big git output
68* 2.4.181 on Jun 19, 2022
Original file line number Diff line number Diff line change 2424 (binding [*out* *err*]
2525 (apply println msgs)))
2626
27- (defn capture
28- " Reads from input-stream until EOF and returns a String (or nil if 0 length).
29- Takes same opts as clojure.java.io/copy - :buffer and :encoding"
27+ (defn- capture
28+ " Reads from input-stream until EOF and returns a String (or nil if 0 length)."
3029 [^InputStream input-stream]
3130 (let [writer (StringWriter. )]
3231 (jio/copy input-stream writer)
3332 (let [s (str/trim (.toString writer))]
3433 (when-not (zero? (.length s))
3534 s))))
3635
36+ (defmacro background
37+ [& body]
38+ `(let [result# (promise )]
39+ (doto (Thread. (fn [] (deliver result# (do ~@body))))
40+ (.setDaemon true )
41+ (.start ))
42+ result#))
43+
3744(defn- run-git
3845 [& args]
3946 (let [{:gitlibs/keys [command debug terminal]} @config/CONFIG
4451 _ (when debug (.redirectError proc-builder ProcessBuilder$Redirect/INHERIT))
4552 _ (when-not terminal (.put (.environment proc-builder) " GIT_TERMINAL_PROMPT" " 0" ))
4653 proc (.start proc-builder)
47- out (future (capture (.getInputStream proc)))
48- err (future (capture (.getErrorStream proc))) ; ; if debug is true, stderr will be redirected instead
54+ out (background (capture (.getInputStream proc)))
55+ err (background (capture (.getErrorStream proc))) ; ; if debug is true, stderr will be redirected instead
4956 exit (.waitFor proc)]
5057 {:args command-args, :exit exit, :out @out, :err @err})))
5158
You can’t perform that action at this time.
0 commit comments