diff --git a/src/git_kv.ml b/src/git_kv.ml index 61d6197..2fea998 100644 --- a/src/git_kv.ml +++ b/src/git_kv.ml @@ -109,7 +109,13 @@ let connect ctx endpoint = let branch t = t.branch -let commit t = t.head +let commit t = + match t.head, t.committed with + | None, _ -> None + | Some commit, None -> Some (`Clean commit) + | Some commit, Some _ -> + (* XXX: this is not precise as we can have made zero changes *) + Some (`Dirty commit) type key = Mirage_kv.Key.t diff --git a/src/git_kv.mli b/src/git_kv.mli index 3de53d7..735e12e 100644 --- a/src/git_kv.mli +++ b/src/git_kv.mli @@ -43,8 +43,10 @@ val connect : Mimic.ctx -> string -> t Lwt.t val branch : t -> Git.Reference.t (** [branch t] returns the branch used by the given [t]. *) -val commit : t -> Digestif.SHA1.t option -(** [commit t] returns the commit used by the given [t]. *) +val commit : t -> [ `Clean of Digestif.SHA1.t | `Dirty of Digestif.SHA1.t ] option +(** [commit t] returns the commit used by the given [t]. The commit is either + marked [`Dirty _] if we're inside a [change_and_push] or [`Clean _] + otherwise. *) val to_octets : ?level:int -> t -> string Lwt_stream.t (** [to_octets ?level store] returns a serialized version of the given [store].