Class: GitDS::StageMemIndex

Inherits:
StageIndex show all
Defined in:
lib/git-ds/index.rb

Overview

In-memory staging index.

This replaces the StageIndex#build method with a nop, so that the index is not written to disk.

This is primarily useful in transactions or in methods such as Database#batch. Keepin the tree in-memory as long as necessary reduces disk writes and speeds up bulk insert/delete operations.

Instance Attribute Summary

Attributes inherited from StageIndex

#parent_commit, #sha

Instance Method Summary collapse

Methods inherited from StageIndex

#commit, #initialize, read, #read_tree, #write

Methods inherited from Index

#add, #add_db, #add_fs, #delete, #include?, #local_write_tree, #path_to_object, #write

Constructor Details

This class inherits a constructor from GitDS::StageIndex

Instance Method Details

#buildObject

Return the sha of the stage index on disk. This DOES NOT synchronize the in-memory index with the on-disk index.



248
249
250
# File 'lib/git-ds/index.rb', line 248

def build
  return @sha
end

#force_syncObject

Force a sync-to-disk. This is used by batch mode to ensure a sync.



261
262
263
264
# File 'lib/git-ds/index.rb', line 261

def force_sync
  self.read_tree(self.write)
  @repo.exec_in_git_dir { `git read-tree #{@sha}` }
end

#syncObject

Replace standard sync with a no-op.



255
256
# File 'lib/git-ds/index.rb', line 255

def sync
end