Commits

evhan committed d80fdb8 Merge

Merge branch 'types' into development

Comments (0)

Files changed (6)

 (export
+ blob
  blob*
  blob*-binary?
  blob*-content
  blob*-id
  blob*-size
  blob*?
- blob
  blob-binary?
  blob-content
  blob-id
  config-set!
  config-unset!
  config?
- create-blob*
  create-blob
+ create-blob*
  create-branch
  create-commit
  create-note
  diff-fold
  diff-hunk-header
  diff-hunk-header-len
+ diff-hunk-header-length
  diff-hunk-lines
  diff-hunk-new-lines
  diff-hunk-new-start
  diff-hunk?
  diff-line-content
  diff-line-content-len
+ diff-line-content-length
  diff-line-content-offset
  diff-line-new-lineno
  diff-line-num-lines
  diff-num-deltas
  diff-patch
  diff-patches
+ diff-repository
  diff?
  diffs
  file-ignored?
  note-id
  note-message
  note-repository
+ note?
  notes
  notes-fold
  object-id
  remote-name
  remote-pushurl
  remote-pushurl-set!
- remote-refspecs
  remote-refspec-add!
+ remote-refspecs
  remote-repository
  remote-stats
  remote-update-fetchhead-set!
  tree-builder-ref
  tree-builder-remove
  tree-builder-write
+ tree-builder?
  tree-entries
  tree-entry->object
+ tree-entry-attributes
  tree-entry-id
  tree-entry-name
  tree-entry-owner

git-lolevel-exports.scm

  diff-num-deltas
  diff-num-deltas-of-type
  diff-hunk-header
- diff-hunk-header-len
+ diff-hunk-header-length
  diff-hunk-new-lines
  diff-hunk-new-start
  diff-hunk-old-lines
  diff-hunk-old-start
  diff-index-to-workdir
  diff-line-content
- diff-line-content-len
+ diff-line-content-length
  diff-line-content-offset
  diff-line-new-lineno
  diff-line-num-lines
  diff-tree-to-tree
  diff-tree-to-workdir
  error
+ filemode->int ; Used by `tree-entry-attributes`.
  index-add
  index-add-bypath
  index-clear
  tree-entry-byoid
  tree-entry-bypath
  tree-entry-dup
+ tree-entry-filemode
  tree-entry-free
  tree-entry-id
  tree-entry-name
   (int              old_lines    diff-hunk-old-lines)
   (int              new_start    diff-hunk-new-start)
   (int              new_lines    diff-hunk-new-lines)
-  (size_t           header_len   diff-hunk-header-len)
+  (size_t           header_len   diff-hunk-header-length)
   (nonnull-c-string header       diff-hunk-header))
 
 (define-foreign-record-type (diff-line git_diff_line)
   (int              old_lineno     diff-line-old-lineno)
   (int              new_lineno     diff-line-new-lineno)
   (int              num_lines      diff-line-num-lines)
-  (size_t           content_len    diff-line-content-len)
+  (size_t           content_len    diff-line-content-length)
   (off-t            content_offset diff-line-content-offset)
   ;; XXX Not null-terminated, and doesn't outlive the call to
   ;; git_diff_line_cb that produces it -- must be copied out first.
 
 ;; TODO git_refspec_transform
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; repository.h
 
 (define repository-open          (foreign-lambda/allocate repository git_repository_open nonnull-c-string))
 (define tree-entry-name       (foreign-lambda c-string git_tree_entry_name tree-entry))
 (define tree-entry-id         (foreign-lambda oid git_tree_entry_id tree-entry))
 (define tree-entry-type       (foreign-lambda object-type git_tree_entry_type tree-entry))
+(define tree-entry-filemode   (foreign-lambda filemode git_tree_entry_filemode tree-entry))
 (define tree-entry-dup        (foreign-lambda tree-entry git_tree_entry_dup tree-entry))
 (define tree-entry-free       (foreign-lambda void git_tree_entry_free tree-entry))
 (define tree-builder-free     (foreign-lambda void git_treebuilder_free tree-builder))
              (free      (cddddr e))
              (slots     (cdar spec))
              (attrs     (cdr spec))
-             (make      (s+ 'make- name))
-             (%make     (s+ '%make- name))
+             (make      (s+ '%make- name))
+             (pred?     (s+ name '?))
              (->pointer (s+ name '->pointer))
              (pointer-> (s+ 'pointer-> name)))
         `(begin
-           (define-record ,name >pointer ,@slots)
-           (define ,%make ,make)
+           (define-record-type ,name
+             (,make pointer ,@slots)
+             ,pred?
+             (pointer ,->pointer)
+             ,@(map (lambda (s)
+                      `(,s ,(symbol-append name '- s)
+                           ,(symbol-append name '- s '-set!)))
+                    slots))
            (define-record-printer (,name ,name out)
              (display ,printer out))
            (define (,pointer-> ,@slots ptr)
-             (and-let* ((ptr)
-                        (obj (,%make ptr ,@slots)))
+             (and-let* ((ptr) ; TODO This check should go away.
+                        (obj (,make ptr ,@slots)))
                ,(if (null? free)
                     'obj
                     `(set-finalizer! obj
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;
+;;; Types
+;;;
+
+(define-type blob*             (struct blob))
+(define-type commit            (struct commit))
+(define-type config            (struct config))
+(define-type config-entry      (struct config-entry))
+(define-type diff              (struct diff))
+(define-type diff-delta        (struct diff-delta))
+(define-type diff-file         (struct diff-file))
+(define-type diff-hunk         (struct diff-hunk))
+(define-type diff-line         (struct diff-line))
+(define-type index             (struct index))
+(define-type index-entry       (struct index-entry))
+(define-type note              (struct note))
+(define-type odb               (struct odb))
+(define-type odb-object        (struct odb-object))
+(define-type oid               (struct oid))
+(define-type patch             (struct patch))
+(define-type reference         (struct reference))
+(define-type refspec           (struct refspec))
+(define-type repository        (struct repository))
+(define-type remote            (struct remote))
+(define-type signature         (struct signature))
+(define-type tag               (struct tag))
+(define-type transfer-progress (struct transfer-progress))
+(define-type tree              (struct tree))
+(define-type tree-builder      (struct tree-builder))
+(define-type tree-entry        (struct tree-entry))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
 ;;; Generics & OIDs
 ;;;
 
+(define-type object  (or blob* commit tag tree))
+(define-type oid-ish (or oid string reference object))
+
+(: merge-base (repository oid oid -> commit))
+(: object->oid (object -> oid))
+(: object-id (object -> oid))
+(: object-sha (object -> string))
+(: object-type (object -> (or symbol false)))
+(: object=? (object object -> boolean))
+(: oid->path (oid -> string))
+(: oid->string (oid #!optional fixnum -> string))
+(: oid=? (oid oid -> boolean))
+(: string->oid (string -> oid))
+
 ;; OIDs are allocated/freed by git-lolevel.scm.
 (define-git-record-type oid
   ((oid))
 ;;; Signatures
 ;;;
 
+(: make-signature (string string #!optional fixnum fixnum -> signature))
+(: signature-email (signature -> string))
+(: signature-name (signature -> string))
+(: signature-time (signature -> fixnum))
+(: signature-time-offset (signature -> fixnum))
+(: signature? (* --> boolean : signature))
+
 (define-git-record-type signature
   ((signature) name email)
   (format "#<signature \"~A <~A>\">" (signature-name signature) (signature-email signature))
 ;;; Repositories
 ;;;
 
+(: create-repository (#!optional string * -> repository))
+(: repository-bare? (repository -> boolean))
+(: repository-empty? (repository -> boolean))
+(: repository-head (repository -> reference))
+(: repository-head-detached? (repository -> boolean))
+(: repository-head-unborn? (repository -> boolean))
+(: repository-open (#!optional string -> repository))
+(: repository-path (repository -> string))
+(: repository-ref (repository oid-ish #!optional symbol -> (or object false)))
+(: repository-working-directory (repository -> string))
+(: repository? (* --> boolean : repository))
+
 (define-git-record-type repository
   ((repository) is-empty is-bare path workdir head-unborn head-detached)
   (format "#<repository ~S>" (repository-path repository))
   (pointer->repository (git-repository-init path bare)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;
 ;;; Revspec
+;;;
+
+(: parse-revision-specification
+   (repository string -> (or object false) (or object false)))
 
 (define (parse-revision-specification repo str)
   (condition-case
         (values #f #f))))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; References
+;;;
+;;; References
+;;;
+
+(: create-reference (repository #!rest -> reference))
+(: reference (repository string -> reference))
+(: reference-branch? (reference -> boolean))
+(: reference-delete (reference -> void))
+(: reference-name (reference -> string))
+(: reference-remote? (reference -> boolean))
+(: reference-rename (reference string #!optional * -> reference))
+(: reference-repository (reference -> repository))
+(: reference-resolve (reference -> reference))
+(: reference-tag? (reference -> boolean))
+(: reference-target (reference -> oid))
+(: reference-target-set! (reference oid-ish -> void))
+(: reference-type (reference -> symbol))
+(: reference? (* --> boolean : reference))
+(: references (repository #!optional string -> (list-of reference)))
+(: references-fold
+   (forall (a b)
+           ((reference a -> b) a repository #!optional string -> (or a b))))
 
 (define-git-record-type reference
   ((reference repository) type name delete)
    (git-reference-rename (reference->pointer ref) name force)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Trees
+;;;
+;;; Trees
+;;;
+
+(: create-tree (repository #!optional index -> tree))
+(: tree (repository oid-ish -> tree))
+(: tree-entries (tree -> (list-of (pair string tree-entry))))
+(: tree-entrycount (tree -> fixnum))
+(: tree-fold (forall (a b) ((string tree-entry a -> b) a tree #!optional symbol -> (or a b))))
+(: tree-id (tree -> oid))
+(: tree-ref (tree (or fixnum oid string) -> (or tree-entry false)))
+(: tree-repository (tree -> repository))
+(: tree? (* --> boolean : tree))
 
 (define-git-record-type tree
   ((tree repository) id entrycount)
   (format "#<tree ~S>" (oid->string (tree-id tree) 7))
   (git-tree-free))
 
+(: tree-entry->object ((or repository tree-entry) #!optional tree-entry -> object))
+(: tree-entry-attributes (tree-entry -> fixnum))
+(: tree-entry-id (tree-entry -> oid))
+(: tree-entry-name (tree-entry -> string))
+(: tree-entry-owner (tree-entry -> (or tree tree-builder)))
+(: tree-entry-type (tree-entry -> symbol))
+(: tree-entry? (* --> boolean : tree-entry))
+
 (define-git-record-type tree-entry
-  ((tree-entry owner) id name type)
+  ((tree-entry owner) id name type filemode)
   (format "#<tree-entry ~S>" (tree-entry-name tree-entry))
   (git-tree-entry-free))
 
+(define (tree-entry-attributes e)
+  (git-filemode->int (tree-entry-filemode e)))
+
 (define (tree repo ref)
   (pointer->tree
    repo
   (tree-fold (lambda (path entry acc) (cons (cons path entry) acc)) '() tree))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Tree Builders
+;;;
+;;; Tree Builders
+;;;
+
+(: make-tree-builder (#!optional tree -> tree-builder))
+(: tree-builder-clear (tree-builder -> void))
+(: tree-builder-insert (tree-builder oid-ish string fixnum -> tree-entry))
+(: tree-builder-ref (tree-builder string -> (or tree-entry false)))
+(: tree-builder-remove (tree-builder string -> void))
+(: tree-builder-write (repository tree-builder -> tree))
+(: tree-builder? (* --> boolean : tree-builder))
 
 (define-git-record-type tree-builder
   ((tree-builder) clear)
   (git-tree-builder-remove (tree-builder->pointer tb) path))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Branches
+;;;
+;;; Branches
+;;;
+
+(define-type branch reference)
+
+(: branch (repository string #!optional symbol -> branch))
+(: branch-delete (branch -> void))
+(: branch-head? (branch -> boolean))
+(: branch-name (branch -> string))
+(: branch-rename (branch string #!optional boolean -> branch))
+(: branches (repository #!optional symbol -> (list-of branch)))
+(: branches-fold (forall (a b) ((branch a -> b) a repository #!optional symbol -> (or a b))))
+(: create-branch (repository #!rest -> branch))
 
 (define (branch repo name #!optional (type 'all))
   (pointer->reference repo (git-branch-lookup (repository->pointer repo) name type)))
   (branches-fold cons '() repo type))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Checkout
+;;;
+;;; Checkout
+;;;
+
+(: checkout (repository #!optional (or index object) -> void))
 
 (define (checkout repo #!optional object)
   (cond
      (git-checkout-tree (repository->pointer repo) (object->oid->pointer object) git-checkout-options-default))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Commits
+;;;
+;;; Commits
+;;;
+
+(: commit (repository oid-ish -> commit))
+(: commit-ancestor (commit #!optional fixnum -> (or commit false)))
+(: commit-author (commit -> signature))
+(: commit-committer (commit -> signature))
+(: commit-header (commit -> string))
+(: commit-id (commit -> oid))
+(: commit-message (commit -> string))
+(: commit-message-encoding (commit -> string))
+(: commit-message-raw (commit -> string))
+(: commit-parent (commit #!optional fixnum -> (or commit false)))
+(: commit-parent-id (commit -> oid))
+(: commit-parentcount (commit -> fixnum))
+(: commit-parents (commit -> (list-of commit)))
+(: commit-repository (commit -> repository))
+(: commit-time (commit -> fixnum))
+(: commit-time-offset (commit -> fixnum))
+(: commit-tree (commit -> tree))
+(: commit-tree-id (commit -> oid))
+(: commit? (* --> boolean : commit))
+(: commits (repository #!rest -> (list-of commit)))
+(: commits-fold (forall (a b) ((commit a -> b) a repository #!rest -> (or a b))))
+(: create-commit (repository #!rest -> commit))
 
 (define-git-record-type commit
   ((commit repository) id parentcount message message-raw message-encoding time time-offset raw-header)
      (map commit->pointer parents)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Blobs
+;;;
+;;; Blobs
+;;;
+
+(: blob (repository oid-ish -> blob*))
+(: blob-binary? (blob* -> boolean))
+(: blob-content (blob* -> blob))
+(: blob-id (blob* -> oid))
+(: blob-length (blob* -> fixnum))
+(: blob-repository (blob* -> repository))
+(: blob? (* --> boolean : blob*))
+(: create-blob (repository (or blob string) -> blob*))
 
 (define-git-record-type blob
   ((blob repository) id rawsize rawcontent is-binary)
      repo
      (git-blob-lookup
       repo*
-      (cond ((blob? source)
+      (cond ((chicken-blob? source)
              (git-blob-create-frombuffer repo* source))
             ((string? source)
              (if (regular-file? source)
 (define create-blob* create-blob)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Index
+;;;
+;;; Index
+;;;
+
+(: index-add (index (or index-entry string) -> void))
+(: index-clear (index -> void))
+(: index-entrycount (index -> fixnum))
+(: index-find (index string -> (or fixnum false)))
+(: index-open ((or string repository) -> index))
+(: index-read (index #!optional boolean -> void))
+(: index-ref (index (or fixnum string) -> (or index-entry false)))
+(: index-remove (index fixnum -> void))
+(: index-write (index -> fixnum))
+(: index? (* --> boolean : index))
 
 (define-git-record-type index
   ((index) entrycount write clear)
   "#<index>"
   (git-index-free))
 
+(: index-entry-ctime (index-entry -> fixnum))
+(: index-entry-dev (index-entry -> fixnum))
+(: index-entry-extended (index-entry -> fixnum))
+(: index-entry-flags (index-entry -> fixnum))
+(: index-entry-gid (index-entry -> fixnum))
+(: index-entry-id (index-entry -> oid))
+(: index-entry-ino (index-entry -> fixnum))
+(: index-entry-mode (index-entry -> fixnum))
+(: index-entry-mtime (index-entry -> fixnum))
+(: index-entry-owner (index-entry -> index))
+(: index-entry-path (index-entry -> string))
+(: index-entry-size (index-entry -> fixnum))
+(: index-entry-stage (index-entry -> fixnum))
+(: index-entry-uid (index-entry -> fixnum))
+(: index-entry? (* --> boolean : index-entry))
+
 (define-git-record-type index-entry
   ((index-entry owner) dev oid ino mode uid gid size stage flags extended path)
   (format "#<index-entry ~S>" (index-entry-path index-entry)))
             (git-error 'index-ref "Invalid key" key))))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Status
+;;;
+;;; File status
+;;;
+
+(define-type status (or symbol (list-of symbol)))
+
+(: file-ignored? (repository string -> boolean))
+(: file-status (repository string -> status))
+(: file-statuses (repository -> (list-of (pair string status))))
+(: file-statuses-fold
+   (forall (a b) ((string status a -> b) a repository -> (or a b))))
 
 (define (file-status repo path)
   (git-status-file (repository->pointer repo) path))
    repo))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Notes
+;;;
+;;; Notes
+;;;
+
+(: create-note (repository #!rest -> note))
+(: delete-note (repository #!rest -> void))
+(: note (repository oid-ish #!optional string -> note))
+(: note-id (note -> oid))
+(: note-message (note -> string))
+(: note-repository (note -> repository))
+(: note? (* --> boolean : note))
+(: notes (repository #!optional reference -> (list-of note)))
+(: notes-fold
+   (forall (a b) ((note a -> b) a repository #!optional reference -> (or a b))))
 
 (define-git-record-type note
   ((note repository) message oid)
   (notes-fold cons '() repo reference))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; ODB
+;;;
+;;; ODB
+;;;
+
+(: odb-has-object? (odb oid-ish -> boolean))
+(: odb-hash (* #!optional symbol -> oid))
+(: odb-object-data (odb-object -> blob))
+(: odb-object-id (odb-object -> oid))
+(: odb-object-owner (odb-object -> odb))
+(: odb-object-size (odb-object -> fixnum))
+(: odb-object-type (odb-object -> symbol))
+(: odb-object? (* --> boolean : odb-object))
+(: odb-open ((or string repository) -> odb))
+(: odb-read (odb oid-ish -> odb-object))
+(: odb-write (odb * #!optional symbol -> oid))
+(: odb? (* --> boolean : odb))
 
 (define-git-record-type odb
   ((odb))
     dest))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Tags
+;;;
+;;; Tags
+;;;
+
+(: create-tag (repository #!rest -> tag))
+(: tag (repository oid-ish -> tag))
+(: tag-delete (tag -> void))
+(: tag-id (tag -> oid))
+(: tag-message (tag -> string))
+(: tag-name (tag -> string))
+(: tag-peel (tag -> object))
+(: tag-repository (tag -> repository))
+(: tag-tagger (tag -> signature))
+(: tag-target (tag -> object))
+(: tag? (* --> boolean : tag))
+(: tags (repository -> (list-of tag)))
+(: tags-fold (forall (a b) ((tag a -> b) a repository -> (or a b))))
 
 (define-git-record-type tag
   ((tag repository) id name message)
      force))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Diffs
+;;;
+;;; Diffs
+;;;
+
+(: diff (repository #!optional (or index tree) (or index tree) -> diff))
+(: diff->string (diff -> string))
+(: diff-delta-hunks (diff-delta -> (list-of diff-hunk)))
+(: diff-delta-new-file (diff-delta -> (or diff-file false)))
+(: diff-delta-old-file (diff-delta -> (or diff-file false)))
+(: diff-delta-path (diff-delta -> string))
+(: diff-delta-status (diff-delta -> symbol))
+(: diff-delta? (* --> boolean : diff-delta))
+(: diff-deltas (diff -> (list-of diff-delta)))
+(: diff-file-flags (diff-file -> fixnum))
+(: diff-file-id (diff-file -> oid))
+(: diff-file-mode (diff-file -> fixnum))
+(: diff-file-path (diff-file -> string))
+(: diff-file-size (diff-file -> fixnum))
+(: diff-file? (* --> boolean : diff-file))
+(: diff-fold (forall (a b) ((diff-delta a -> b) a diff -> (or a b))))
+(: diff-hunk-header (diff-hunk -> string))
+(: diff-hunk-header-len (deprecated diff-hunk-header-length))
+(: diff-hunk-header-length (diff-hunk -> fixnum))
+(: diff-hunk-lines (diff-hunk -> (list-of diff-line)))
+(: diff-hunk-new-lines (diff-hunk -> fixnum))
+(: diff-hunk-new-start (diff-hunk -> fixnum))
+(: diff-hunk-old-lines (diff-hunk -> fixnum))
+(: diff-hunk-old-start (diff-hunk -> fixnum))
+(: diff-hunk? (* --> boolean : diff-hunk))
+(: diff-line-content (diff-line -> string))
+(: diff-line-content-len (deprecated diff-line-content-length))
+(: diff-line-content-length (diff-line -> fixnum))
+(: diff-line-content-offset (diff-line -> fixnum))
+(: diff-line-new-lineno (diff-line -> fixnum))
+(: diff-line-num-lines (diff-line -> fixnum))
+(: diff-line-old-lineno (diff-line -> fixnum))
+(: diff-line-origin (diff-line -> char))
+(: diff-line? (* --> boolean : diff-line))
+(: diff-num-deltas (diff -> fixnum))
+(: diff-patch (diff fixnum -> patch))
+(: diff-patches (diff -> (list-of patch)))
+(: diff-repository (diff -> repository))
+(: diff? (* --> boolean : diff))
+(: diffs (deprecated diff-deltas))
 
 (define-git-record-type diff
   ((diff repository) num-deltas)
   (format "#<diff-delta (~a) ~s>" (diff-delta-status diff-delta) (diff-delta-path diff-delta)))
 
 (define-git-record-type diff-hunk
-  ((diff-hunk diff lines) old-start old-lines new-start new-lines header-len header)
+  ((diff-hunk diff lines) old-start old-lines new-start new-lines header-length header)
   (format "#<diff-hunk ~s>" (diff-hunk-header diff-hunk)))
 
 (define-git-record-type diff-line
-  ((diff-line diff content) origin old-lineno new-lineno num-lines content-len content-offset)
+  ((diff-line diff content) origin old-lineno new-lineno num-lines content-length content-offset)
   (format "#<diff-line (~a)>" (diff-line-origin diff-line)))
 
 (define diff-delta-old-file (preserve-owner pointer->diff-file diff-delta-old-file))
 (define diff-delta-new-file (preserve-owner pointer->diff-file diff-delta-new-file))
 
+(define diff-hunk-header-len diff-hunk-header-length)
+(define diff-line-content-len diff-line-content-length)
+
 (define (diff-delta-path delta)
   (diff-file-path
    (or (diff-delta-new-file delta)
          (set! hunk (pointer->diff-hunk delta '() *hunk))
          (diff-delta-hunks-set! delta (cons hunk (diff-delta-hunks delta))))
        (lambda (*delta *hunk *line)
-         (let* ((len  (git-diff-line-content-len *line))
+         (let* ((len  (git-diff-line-content-length *line))
                 (str  (make-string len))
                 (line (pointer->diff-line hunk str *line)))
            (move-memory! (git-diff-line-content *line) str len)
               (else
                (git-error 'diff "Undiffable object" object))))))))
 
-(define (diff-deltas . args)
-  (diff-fold cons '() (apply diff args)))
+(define diff-deltas
+  (case-lambda
+    ((diff)
+     (diff-fold cons '() diff))
+    (args ; Deprecated.
+     (diff-fold cons '() (apply diff args)))))
 
-(: diffs (deprecated diff-deltas))
+;; Deprecated (above).
 (define diffs diff-deltas)
 
 (define (diff-patch diff i)
 ;;; Patch
 ;;;
 
+(: patch (blob* (or string blob) -> patch))
+(: patch->string (patch -> string))
+(: patch-size (patch -> fixnum))
+(: patch-stats (patch -> (vector fixnum fixnum fixnum)))
+(: patch? (* --> boolean : patch))
+
 (define-git-record-type patch
   ((patch repository) num-hunks line-stats)
   (format "#<patch (~a)>" (patch-num-hunks patch))
 ;;; Cloning
 ;;;
 
+(: clone (string string -> repository))
+
 (define (clone url path) (pointer->repository (git-clone url path #f)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Configs
+;;;
+;;; Configs
+;;;
+
+(define-type config-value (or string boolean number))
+
+(: config-get (config string #!optional symbol -> config-value))
+(: config-open (#!optional (or string symbol repository) -> config))
+(: config-path (#!optional symbol -> string))
+(: config-set! (config string config-value -> void))
+(: config-unset! (config string -> void))
+(: config? (* --> boolean : config))
 
 (define-git-record-type config
   ((config))
    name
    value))
 
-(define (config-unset! cfg name)
-  (git-config-delete-entry (config->pointer cfg) name)))
+(define (config-unset! config name)
+  (git-config-delete-entry (config->pointer config) name)))
 
 Folds over the given {{diff}}'s {{diff-delta}}s in unspecified order.
 
-<procedure>(diff-deltas repository [object1 [object2]]) => (list-of diff-delta)</procedure>
+<procedure>(diff-deltas {{diff}}) => (list-of diff-delta)</procedure>
 
-Returns a list of {{diff-deltas}} for the {{diff}} between two objects
-in the given {{repository}}. This is equivalent to calling {{(diff
-repository object1 object2)}}, then immediately building a list from the
-resulting {{diff}} record with {{diff-fold}}.
+Returns the list of {{diff-delta}}s for all changed files in the given
+{{diff}}.
 
 <record>diff-delta</record>
 <procedure>(diff-delta-path diff) => string</procedure>
 
 (test-group "status"
   (parameterize ((current-directory repo-path))
-    (test-error "file-status on nonexistent file" (file-status "not-a-file"))
+    (test-error "file-status on nonexistent file" (file-status repo "not-a-file"))
     (test-assert "file-ignored?" (not (find (lambda (f) (file-ignored? repo f)) files)))
     (test "file-statuses" 4 (length (file-statuses repo)))
     (let ((s (car (file-statuses repo))))
     (let ((file (car files))
           (line (car content)))
       (test-assert "diff (clean workdir)" (diff? (diff repo)))
-      (test-assert "diff-deltas (clean workdir)" (null? (diff-deltas repo)))
-      (test-assert "diff-deltas (index to clean workdir)" (null? (diff-deltas repo (index-open repo))))
+      (test "diff (clean workdir)" 0 (diff-num-deltas (diff repo)))
+      (test "diff (index to clean workdir)" 0 (diff-num-deltas (diff repo (index-open repo))))
       ;; Modify workdir state slightly.
       (with-output-to-file file newline #:append)
       (test-assert "diff (dirty workdir)" (diff? (diff repo)))
-      (test "diff-deltas (dirty workdir)" 1 (length (diff-deltas repo)))
-      (test "diff-deltas (index to dirty workdir)" 1 (length (diff-deltas repo (index-open repo))))
+      (test "diff (dirty workdir)" 1 (diff-num-deltas (diff repo)))
+      (test "diff (index to dirty workdir)" 1 (diff-num-deltas (diff repo (index-open repo))))
       (let* ((ts (map commit-tree (commits repo sort: 'rev)))
              (t1 (car ts))
              (t2 (cadr ts)))
-        (test "diff-deltas (tree to workdir)" 1 (length (diff-deltas repo t2)))
-        (test "diff-deltas (tree to index)" 1 (length (diff-deltas repo t1 (index-open repo))))
-        (test "diff-deltas (tree to tree)" 1 (length (diff-deltas repo t1 t2)))
-        (let ((d (car (diff-deltas repo))))
+        (test "diff (tree to workdir)" 1 (diff-num-deltas (diff repo t2)))
+        (test "diff (tree to index)" 1 (diff-num-deltas (diff repo t1 (index-open repo))))
+        (test "diff (tree to tree)" 1 (diff-num-deltas (diff repo t1 t2)))
+        (let ((d (car (diff-deltas (diff repo)))))
           (test-assert "diff-delta?" (diff-delta? d))
           (test "diff-delta-path" file (diff-delta-path d))
           (test "diff-delta-status" 'modified (diff-delta-status d))
     (test-assert "remote-pushurl-set!" (remote-pushurl-set! r (repository-path repo)))
     (test "remote-url after set" (repository-working-directory repo) (remote-url r))
     (test "remote-pushurl after set" (repository-path repo) (remote-pushurl r))
-    (test-assert "remote-connect" (remote-connect r))
+    (test-assert "remote-connect!" (remote-connect! r))
     (test-assert "remote-connected? (connected)" (remote-connected? r))
-    (test-assert "remote-disconnect" (remote-disconnect r))
+    (test-assert "remote-disconnect!" (remote-disconnect! r))
     (test-assert "remote-connected? (disconnected)" (not (remote-connected? r)))
     (test-assert "remote-download!" (remote-download! r))))