All predicatesShow sourcegitty_driver_files.pl -- Gitty plain files driver

This version of the driver uses plain files to store the gitty data. It consists of a nested directory structure with files named after the hash. Objects and hash computation is the same as for git. The heads (files) are computed on startup by scanning all objects. There is a file ref/head that is updated if a head is updated. Other clients can watch this file and update their notion of the head. This implies that the store can handle multiple clients that can access a shared file system, optionally shared using NFS from different machines.

The store is simple and robust. The main disadvantages are long startup times as the store holds more objects and relatively high disk usage due to rounding the small objects to disk allocation units.

bug
- Shared access does not work on Windows.
Source gitty_close(+Store) is det
Close resources associated with a store.
Source gitty_file(+Store, ?File, ?Ext, ?Head) is nondet
True when File entry in the gitty store and Head is the HEAD revision.
Source load_plain_commit(+Store, +Hash, -Meta:dict) is semidet
Load the commit data as a dict. Loaded commits are cached in commit/3. Note that only adding a fact to the cache is synchronized. This means that during a race situation we may load the same object multiple times from disk, but this is harmless while a lock around the whole predicate serializes loading different objects, which is not needed.
Source store_object(+Store, +Hash, +Header:string, +Data:string) is det
Store the actual object. The store must associate Hash with the concatenation of Hdr and Data.
Source load_object(+Store, +Hash, -Data, -Type, -Size) is det
Load the given object.
Source load_object_header(+Store, +Hash, -Type, -Size) is det[private]
Load the header of an object
Source gitty_rescan(?Store) is det
Update our view of the shared storage for all stores matching Store.
Source gitty_scan(+Store) is det[private]
Scan gitty store for files (entries), filling head/3. This is performed lazily at first access to the store.

@tdb Possibly we need to maintain a cached version of this index to avoid having to open all objects of the gitty store.

Source read_heads_from_objects(+Store) is det[private]
Establish the head(Store,File,Ext,Hash) relation by reading all objects and adding a fact for the most recent commit.
Source gitty_scan_latest(+Store)[private]
Scans the gitty store, extracting the latest version of each named entry.
Source gitty_hash(+Store, ?Hash) is nondet
True when Hash is an object in the store.
Source delete_object(+Store, +Hash)
Delete an existing object
Source gitty_object_file(+Store, +Hash, -Path) is det
True when Path is the file at which the object with Hash is stored.
Source gitty_update_head(+Store, +Name, +OldCommit, +NewCommit) is det
Update the head of a gitty store for Name. OldCommit is the current head and NewCommit is the new head. If Name is created, and thus there is no head, OldCommit must be -.

This operation can fail because another writer has updated the head. This can both be in-process or another process.

Source remote_updates(+Store)[private]
Watch for remote updates to the store. We only do this if we did not do so the last second.
Source remote_updates(+Store, -List) is det[private]
Find updates from other gitties on the same filesystem. Note that we have to push/pop the input context to avoid creating a notion of an input context which possibly relate messages incorrectly to the sync file.
Source restore_heads_from_remote(Store)[private]
Restore the known heads by reading the remote sync file.
Source delete_head(+Store, +Head) is det
Delete Head from Store. Used by gitty_fsck/1 to remove heads that have no commits. Should we forward this to remotes, or should they do their own thing?
Source set_head(+Store, +File, +Hash) is det
Set the head of the given File to Hash
Source repack_objects(+Store, +Options) is det[multifile]
Repack objects of Store for reduced disk usage and enhanced performance. By default this picks up all file objects of the store and all existing small pack files. Options:
small_pack(+Bytes)
Consider all packs with less than Bytes as small and repack them. Default 10Mb
min_files(+Count)
Do not repack if there are less than Count new files. Default 1,000.
Source pack_objects(+Store, +Objects, +Packs, +PackDir, -PackFile, +Options) is det
Pack the given objects and pack files into a new pack.
Source add_file(+Out, +Store, +Object) is det[private]
Add Object from Store to the pack stream Out.
Source gitty_fsck(+Store) is det
Validate all packs associated with Store
Source fsck_pack(+File) is det
Validate the integrity of the pack file File.
Source gitty_attach_packs(+Store) is det[private]
Attach all packs for Store
Source attach_pack(+Store, +PackFile)
Load the index of Pack into memory.
Source detach_pack(+Store, +Pack) is det[private]
Remove a pack file from the memory index.
Source load_object_from_pack(+Hash, -Data, -Type, -Size) is semidet
True when Hash is in a pack and can be loaded.
Source unpack_packs(+Store) is det[multifile]
Unpack all packs.
Source unpack_pack(+Store, +Pack) is det
Turn a pack back into a plain object files
Source remove_objects_after_pack(+Store, +Objects, +Options) is det[private]
Remove the indicated (file) objects from Store.
Source remove_repacked_packs(+Store, +Packs, +Options)[private]
Remove packs that have been repacked.
Source prune_empty_directories(+Dir) is det[private]
Prune directories that are empty below Dir. Dir itself is not removed, even if it is empty.