 (defn branch [b]
   (let [filepath (str (git-root) "refs/heads/" b)]
     (clojure.string/replace (slurp filepath) #"\n" "")))
+
+(defn head []
+  (let [filepath (str (git-root) "HEAD")
+        full-branch (clojure.string/replace (slurp filepath) #"\n" "")
+        branch-name (-> full-branch (clojure.string/split #"\/") (last))]
+    (branch branch-name)))
 
 (defn validarte-index [] nil)
 

    (.close out)
    (.toByteArray out)))

(defn write-object [full-text]
  (let [hash-text (sha-1-hex full-text)
        [d-name f-name] (map #(apply str %) (split-at 2 hash-text))
        filepath (str (git-root) "objects/" d-name "/" f-name)
        data (byte-array (map byte full-text))
        bdata (compress-zlib data)]
    (make-parents filepath)
    (if (not (.exists (clojure.java.io/as-file filepath)))


(defn to-str [x] (apply str (map char x)))

(defn current-unix-time []
  (quot (System/currentTimeMillis) 1000))

(defn ok-sh [command & args]
  (let [res (apply sh (cons command args))]
    (assert (= 0 (:exit res)))
