C# Класс GitSharp.Core.DirectoryCache.DirCache

Support for the Git dircache (aka index file). The index file keeps track of which objects are currently checked out in the working directory, and the last modified time of those working files. Changes in the working directory can be detected by comparing the modification times to the cached modification time within the index file. Index files are also used during merges, where the merge happens within the index file first, and the working directory is updated as a post-merge step. Conflicts are stored in the index file to allow tool (and human) based resolutions to be easily performed.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Compare ( DirCacheEntry a, DirCacheEntry b ) : int
Compare ( byte aPath, int aLen, byte bPath, int bLen ) : int
DirCache ( FileInfo indexLocation ) : System

Create a new in-core index representation. The new index will be empty. Callers may wish to read from the on disk file first with read().

Lock ( FileInfo indexLocation ) : DirCache

Create a new in-core index representation, lock it, and read from disk. The new index will be locked and then read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index. On read failure, the lock is released.

Lock ( Repository db ) : DirCache

Create a new in-core index representation, lock it, and read from disk. The new index will be locked and then read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.

Lock ( ) : bool

Try to establish an update lock on the cache file.

builder ( ) : DirCacheBuilder

Create a new builder to update this cache. Callers should add all entries to the builder, then use DirCacheBuilder.finish() to update this instance.

clear ( ) : void

Empty this index, removing all entries.

commit ( ) : bool

Commit this change and release the lock. If this method fails (returns false) the lock is still released.

editor ( ) : DirCacheEditor

Create a new editor to recreate this cache. Callers should add commands to the editor, then use DirCacheEditor.finish() to update this instance.

findEntry ( byte p, int pLen ) : int
findEntry ( string path ) : int

Locate the position a path's entry is at in the index. If there is at least one entry in the index for this path the position of the lowest stage is returned. Subsequent stages can be identified by testing consecutive entries until the path differs. If no path matches the entry -(position+1) is returned, where position is the location it would have gone within the index.

getCacheTree ( bool build ) : DirCacheTree

Obtain (or build) the current cache tree structure. This method can optionally recreate the cache tree, without flushing the tree objects themselves to disk.

getEntriesWithin ( string path ) : GitSharp.Core.DirectoryCache.DirCacheEntry[]

Recursively get all entries within a subtree.

getEntry ( int i ) : DirCacheEntry

Get a specific entry.

getEntry ( string path ) : DirCacheEntry

Get a specific entry.

getEntryCount ( ) : int

Total number of file entries stored in the index. This count includes unmerged stages for a file entry if the file is currently conflicted in a merge. This means the total number of entries in the index may be up to 3 times larger than the number of files in the working directory. Note that this value counts only files.

newInCore ( ) : DirCache

Create a new empty index which is never stored on disk.

nextEntry ( byte p, int pLen, int nextIdx ) : int
nextEntry ( int position ) : int

Determine the next index position past all entries with the same name. As index entries are sorted by path name, then stage number, this method advances the supplied position to the first position in the index whose path name does not match the path name of the supplied position's entry.

read ( FileInfo indexLocation ) : DirCache

Create a new in-core index representation and read an index from disk. The new index will be read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.

read ( Repository db ) : DirCache

Create a new in-core index representation and read an index from disk. The new index will be read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.

read ( ) : void

Read the index from disk, if it has changed on disk. This method tries to avoid loading the index if it has not changed since the last time we consulted it. A missing index file will be treated as though it were present but had no file entries in it.

replace ( DirCacheEntry e, int cnt ) : void
toArray ( int i, DirCacheEntry dst, int off, int cnt ) : void
unlock ( ) : void

Unlock this file and abort this change. The temporary file (if created) is deleted before returning.

write ( ) : void

Write the entry records from memory to disk. The cache must be locked first by calling Lock() and receiving true as the return value. Applications are encouraged to lock the index, then invoke read() to ensure the in-memory data is current, prior to updating the in-memory entries. Once written the lock is closed and must be either committed with commit() or rolled back with unlock().

writeTree ( ObjectWriter ow ) : ObjectId

Write all index trees to the object store, returning the root tree.

Приватные методы

Метод Описание
Compare ( byte aPath, int aLen, DirCacheEntry b ) : int
IsDIRC ( byte header ) : bool
ReadFrom ( Stream inStream ) : void
RequireLocked ( LockFile tmp ) : void
WriteTo ( Stream os ) : void

Описание методов

Compare() публичный статический Метод

public static Compare ( DirCacheEntry a, DirCacheEntry b ) : int
a DirCacheEntry
b DirCacheEntry
Результат int

Compare() публичный статический Метод

public static Compare ( byte aPath, int aLen, byte bPath, int bLen ) : int
aPath byte
aLen int
bPath byte
bLen int
Результат int

DirCache() публичный Метод

Create a new in-core index representation. The new index will be empty. Callers may wish to read from the on disk file first with read().
public DirCache ( FileInfo indexLocation ) : System
indexLocation System.IO.FileInfo location of the index file on disk.
Результат System

Lock() публичный статический Метод

Create a new in-core index representation, lock it, and read from disk. The new index will be locked and then read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index. On read failure, the lock is released.
/// The index file is present but could not be read, or the lock /// could not be obtained. /// /// the index file is using a format or extension that this /// library does not support. ///
public static Lock ( FileInfo indexLocation ) : DirCache
indexLocation System.IO.FileInfo /// location of the index file on disk. ///
Результат DirCache

Lock() публичный статический Метод

Create a new in-core index representation, lock it, and read from disk. The new index will be locked and then read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.
/// The index file is present but could not be read, or the lock /// could not be obtained. /// /// The index file is using a format or extension that this /// library does not support. ///
public static Lock ( Repository db ) : DirCache
db Repository /// Repository the caller wants to read the default index of. ///
Результат DirCache

Lock() публичный Метод

Try to establish an update lock on the cache file.
/// The output file could not be created. The caller does not /// hold the lock. ///
public Lock ( ) : bool
Результат bool

builder() публичный Метод

Create a new builder to update this cache. Callers should add all entries to the builder, then use DirCacheBuilder.finish() to update this instance.
public builder ( ) : DirCacheBuilder
Результат DirCacheBuilder

clear() публичный Метод

Empty this index, removing all entries.
public clear ( ) : void
Результат void

commit() публичный Метод

Commit this change and release the lock. If this method fails (returns false) the lock is still released.
/// the lock is not held. ///
public commit ( ) : bool
Результат bool

editor() публичный Метод

Create a new editor to recreate this cache. Callers should add commands to the editor, then use DirCacheEditor.finish() to update this instance.
public editor ( ) : DirCacheEditor
Результат DirCacheEditor

findEntry() публичный Метод

public findEntry ( byte p, int pLen ) : int
p byte
pLen int
Результат int

findEntry() публичный Метод

Locate the position a path's entry is at in the index. If there is at least one entry in the index for this path the position of the lowest stage is returned. Subsequent stages can be identified by testing consecutive entries until the path differs. If no path matches the entry -(position+1) is returned, where position is the location it would have gone within the index.
public findEntry ( string path ) : int
path string The path to search for.
Результат int

getCacheTree() публичный Метод

Obtain (or build) the current cache tree structure. This method can optionally recreate the cache tree, without flushing the tree objects themselves to disk.
public getCacheTree ( bool build ) : DirCacheTree
build bool /// If true and the cache tree is not present in the index it will /// be generated and returned to the caller. ///
Результат DirCacheTree

getEntriesWithin() публичный Метод

Recursively get all entries within a subtree.
public getEntriesWithin ( string path ) : GitSharp.Core.DirectoryCache.DirCacheEntry[]
path string /// The subtree path to get all entries within. ///
Результат GitSharp.Core.DirectoryCache.DirCacheEntry[]

getEntry() публичный Метод

Get a specific entry.
public getEntry ( int i ) : DirCacheEntry
i int /// position of the entry to get. ///
Результат DirCacheEntry

getEntry() публичный Метод

Get a specific entry.
public getEntry ( string path ) : DirCacheEntry
path string The path to search for.
Результат DirCacheEntry

getEntryCount() публичный Метод

Total number of file entries stored in the index. This count includes unmerged stages for a file entry if the file is currently conflicted in a merge. This means the total number of entries in the index may be up to 3 times larger than the number of files in the working directory. Note that this value counts only files.
public getEntryCount ( ) : int
Результат int

newInCore() публичный статический Метод

Create a new empty index which is never stored on disk.
public static newInCore ( ) : DirCache
Результат DirCache

nextEntry() публичный Метод

public nextEntry ( byte p, int pLen, int nextIdx ) : int
p byte
pLen int
nextIdx int
Результат int

nextEntry() публичный Метод

Determine the next index position past all entries with the same name. As index entries are sorted by path name, then stage number, this method advances the supplied position to the first position in the index whose path name does not match the path name of the supplied position's entry.
public nextEntry ( int position ) : int
position int /// entry position of the path that should be skipped. ///
Результат int

read() публичный статический Метод

Create a new in-core index representation and read an index from disk. The new index will be read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.
/// The index file is present but could not be read. /// /// The index file is using a format or extension that this /// library does not support. ///
public static read ( FileInfo indexLocation ) : DirCache
indexLocation System.IO.FileInfo Location of the index file on disk.
Результат DirCache

read() публичный статический Метод

Create a new in-core index representation and read an index from disk. The new index will be read before it is returned to the caller. Read failures are reported as exceptions and therefore prevent the method from returning a partially populated index.
/// The index file is present but could not be read. /// /// The index file is using a format or extension that this /// library does not support. ///
public static read ( Repository db ) : DirCache
db Repository /// repository the caller wants to read the default index of. ///
Результат DirCache

read() публичный Метод

Read the index from disk, if it has changed on disk. This method tries to avoid loading the index if it has not changed since the last time we consulted it. A missing index file will be treated as though it were present but had no file entries in it.
/// The index file is present but could not be read. This /// instance may not be populated correctly. /// /// The index file is using a format or extension that this /// library does not support. ///
public read ( ) : void
Результат void

replace() публичный Метод

public replace ( DirCacheEntry e, int cnt ) : void
e DirCacheEntry
cnt int
Результат void

toArray() публичный Метод

public toArray ( int i, DirCacheEntry dst, int off, int cnt ) : void
i int
dst DirCacheEntry
off int
cnt int
Результат void

unlock() публичный Метод

Unlock this file and abort this change. The temporary file (if created) is deleted before returning.
public unlock ( ) : void
Результат void

write() публичный Метод

Write the entry records from memory to disk. The cache must be locked first by calling Lock() and receiving true as the return value. Applications are encouraged to lock the index, then invoke read() to ensure the in-memory data is current, prior to updating the in-memory entries. Once written the lock is closed and must be either committed with commit() or rolled back with unlock().
/// The output file could not be created. The caller no longer /// holds the lock. ///
public write ( ) : void
Результат void

writeTree() публичный Метод

Write all index trees to the object store, returning the root tree.
/// One or more paths contain higher-order stages (stage > 0), /// which cannot be stored in a tree object. /// /// One or more paths contain an invalid mode which should never /// appear in a tree object. /// /// An unexpected error occurred writing to the object store. ///
public writeTree ( ObjectWriter ow ) : ObjectId
ow ObjectWriter /// The writer to use when serializing to the store. ///
Результат ObjectId