Blob

type blob

A git blob.

generic (blob-size blob)

Return the size of the blob in bytes.

Specializers:
(blob)

generic (blob-content blob)

Returns the content of the blob BLOB as an array of UNSIGNED-BYTE's

Specializers:
(blob)

generic (binary-p blob)

Return T if the contents of the blob is binary.

Specializers:
(blob)

Accessing

Blobs can be accessed usually via TREE objects or directly by OID.

method (get-object (class blob) (id/name T) (repository T))

method (list-objects (class blob) (repository T) &key test test-not)

Specializers:
((eql :oid) repository)
(remote common-lisp:t)
(tag common-lisp:t)
((eql :oid) odb)
(reference common-lisp:t)

Content

Before we dive into this, we can get the content of the file by extracting the OID, "6AEF1FC9F802DB1D903200F39E1D776CE355565F" and lookup this object:

GIT> (get-object 'blob "6AEF1FC9F802DB1D903200F39E1D776CE355565F"
                 (open-repository (merge-pathnames #p"projects/ecl"
                                           (user-homedir-pathname))))
#<BLOB 6AEF1FC9F802DB1D903200F39E1D776CE355565F {10068F1493}>

A blob is just raw data, stored as raw bytes. Basically everything in the git database is stored as blobs. So to extract the content we can do

GIT> (blob-content
      (get-object 'blob "6AEF1FC9F802DB1D903200F39E1D776CE355565F"
                  (open-repository (merge-pathnames #p"projects/ecl"
                                                    (user-homedir-pathname)))))
#(35 33 47 98 105 110 47 115 104 10 35 10 35 32 84 104 105 115 32 105 115 32
  106 117 115 116 32 97 32 100 114 105 118 101 114 32 102 111 114 32 99 111 110
  102 105 103 117 114 101 44 32 116 104 101 32 114 101 97 108 32 99 111 110 102
  105 103 117 114 101 32 105 115 32 105 110 32 115 114 99 46 10 35 32 84 104
  105 115 32 115 99 114 105 112 116 32 105 100 101 110 116 105 102 105 101 115
  32 116 104 101 32 109 97 99 104 105 110 101 44 32 97 110 100 32 99 114 ....)

If the content is of a string type then we can print it's contents.

GIT> (binary-p
      (get-object 'blob "6AEF1FC9F802DB1D903200F39E1D776CE355565F"
                  (open-repository (merge-pathnames #p"projects/ecl"
                                                    (user-homedir-pathname)))))
NIL

Since this is a string then we can convert it, flexi-streams has a convenient mechanism to convent this to a string.

GIT> (flexi-streams:octets-to-string
      (blob-content
       (get-object 'blob "6AEF1FC9F802DB1D903200F39E1D776CE355565F"
                   (open-repository (merge-pathnames #p"projects/ecl"
                                                     (user-homedir-pathname))))))
"#!/bin/sh
#
# This is just a driver for configure, the real configure is in src.
# This script identifies the machine, and creates a directory for
# the installation, where it runs ${srcdir}/configure.
set -e

#if uname -a | grep -i 'mingw32' > /dev/null; then
#  srcdir=`pwd -W`/src;