C# Class 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.
Afficher le fichier Open project: jagregory/GitSharp Class Usage Examples

Méthodes publiques

Méthode Description
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.

Private Methods

Méthode Description
Compare ( byte aPath, int aLen, DirCacheEntry b ) : int
IsDIRC ( byte header ) : bool
ReadFrom ( Stream inStream ) : void
RequireLocked ( LockFile tmp ) : void
WriteTo ( Stream os ) : void

Method Details

Compare() public static méthode

public static Compare ( DirCacheEntry a, DirCacheEntry b ) : int
a DirCacheEntry
b DirCacheEntry
Résultat int

Compare() public static méthode

public static Compare ( byte aPath, int aLen, byte bPath, int bLen ) : int
aPath byte
aLen int
bPath byte
bLen int
Résultat int

DirCache() public méthode

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.
Résultat System

Lock() public static méthode

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. ///
Résultat DirCache

Lock() public static méthode

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. ///
Résultat DirCache

Lock() public méthode

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
Résultat bool

builder() public méthode

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
Résultat DirCacheBuilder

clear() public méthode

Empty this index, removing all entries.
public clear ( ) : void
Résultat void

commit() public méthode

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
Résultat bool

editor() public méthode

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
Résultat DirCacheEditor

findEntry() public méthode

public findEntry ( byte p, int pLen ) : int
p byte
pLen int
Résultat int

findEntry() public méthode

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.
Résultat int

getCacheTree() public méthode

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. ///
Résultat DirCacheTree

getEntriesWithin() public méthode

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. ///
Résultat GitSharp.Core.DirectoryCache.DirCacheEntry[]

getEntry() public méthode

Get a specific entry.
public getEntry ( int i ) : DirCacheEntry
i int /// position of the entry to get. ///
Résultat DirCacheEntry

getEntry() public méthode

Get a specific entry.
public getEntry ( string path ) : DirCacheEntry
path string The path to search for.
Résultat DirCacheEntry

getEntryCount() public méthode

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
Résultat int

newInCore() public static méthode

Create a new empty index which is never stored on disk.
public static newInCore ( ) : DirCache
Résultat DirCache

nextEntry() public méthode

public nextEntry ( byte p, int pLen, int nextIdx ) : int
p byte
pLen int
nextIdx int
Résultat int

nextEntry() public méthode

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. ///
Résultat int

read() public static méthode

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.
Résultat DirCache

read() public static méthode

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. ///
Résultat DirCache

read() public méthode

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
Résultat void

replace() public méthode

public replace ( DirCacheEntry e, int cnt ) : void
e DirCacheEntry
cnt int
Résultat void

toArray() public méthode

public toArray ( int i, DirCacheEntry dst, int off, int cnt ) : void
i int
dst DirCacheEntry
off int
cnt int
Résultat void

unlock() public méthode

Unlock this file and abort this change. The temporary file (if created) is deleted before returning.
public unlock ( ) : void
Résultat void

write() public méthode

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
Résultat void

writeTree() public méthode

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. ///
Résultat ObjectId