            [fname {:keys [sha ftype]}] (git-tree gitdir tree-sha)]
        [:tree/node tree-bsha ftype fname (str->sha sha)]))))
 
+(pldb/db-rel r-branch name sha)
 (pldb/db-rel r-commit ^:index sha ctime tree-sha)
 (pldb/db-rel r-commit-parent ^:index sha ^:index parent-sha)
 (pldb/db-rel r-tree ^:index sha name type ^:index obj-sha)

     (mapcat seq
             (for [{:keys [sha ctime tree parents]} commits
                   :let [bsha (str->sha sha)]]
               (into [[:r-commit bsha ctime (str->sha tree)]]
                     (for [p parents]
                       [:r-commit-parent bsha (str->sha p)]))))
     (for [tree-sha (all-git-trees gitdir)
           :let [tree-bsha (str->sha tree-sha)]
           [fname {:keys [sha ftype]}] (git-tree gitdir tree-sha)]
       [:r-tree tree-bsha fname (keyword ftype) (str->sha sha)]))))

(def rel-for-kw {:r-commit r-commit
                 :r-commit-parent r-commit-parent
                 :r-tree r-tree})
(defn data->relation
  [[rel-name & data]]
  (cons (rel-for-kw rel-name) data))

(comment
  (time (fress-spit-seq "tmp.frs" (git-logic-tuples "<git repo>")))
  (take 10 (filter #(= :r-tree (first %)) (fress/read "tmp.frs" :handlers my-read-handlers)))
  (time (last (fress/read "tmp.frs" :handlers my-read-handlers)))
  (time (def db (apply pldb/db
                       (map data->relation
                            (fress/read "tmp.frs" :handlers my-read-handlers)))))
  (pldb/with-db db
    (l/run 10 [sha]
     (l/fresh [obj-sha]

            [datomic.db :as db]
            [clojure.core.logic.pldb :as pldb]
            [clojure.core.logic :as l]
            [clojure.core.reducers :as red]
            [leiningen.core.project :as project]
            [leiningen.core.main :as lmain]
            [org.satta.glob :refer [glob]]
