Modifier and Type | Field and Description |
---|---|
static int |
STAGE_0
The standard (fully merged) stage for an entry.
|
static int |
STAGE_1
The base tree revision for an entry.
|
static int |
STAGE_2
The first tree revision (usually called "ours").
|
static int |
STAGE_3
The second tree revision (usually called "theirs").
|
Constructor and Description |
---|
DirCacheEntry(byte[] newPath)
Create an empty entry at stage 0.
|
DirCacheEntry(byte[] path,
int stage)
Create an empty entry at the specified stage.
|
DirCacheEntry(DirCacheEntry src)
Duplicate DirCacheEntry with same path and copied info.
|
DirCacheEntry(String newPath)
Create an empty entry at stage 0.
|
DirCacheEntry(String newPath,
int stage)
Create an empty entry at the specified stage.
|
Modifier and Type | Method and Description |
---|---|
void |
copyMetaData(DirCacheEntry src)
Copy the ObjectId and other meta fields from an existing entry.
|
long |
getCreationTime()
Get the cached creation time of this file, in milliseconds.
|
FileMode |
getFileMode()
Obtain the
FileMode for this entry. |
long |
getLastModified()
Get the cached last modification date of this file, in milliseconds.
|
int |
getLength()
Get the cached size (mod 4 GB) (in bytes) of this file.
|
ObjectId |
getObjectId()
Obtain the ObjectId for the entry.
|
String |
getPathString()
Get the entry's complete path.
|
int |
getRawMode()
Obtain the raw
FileMode bits for this entry. |
byte[] |
getRawPath()
Get a copy of the entry's raw path bytes.
|
int |
getStage()
Get the stage of this entry.
|
boolean |
isAssumeValid()
Is this entry always thought to be unmodified?
|
boolean |
isIntentToAdd()
Returns whether this entry is intent to be added to the Index.
|
boolean |
isMerged()
Returns whether this entry is in the fully-merged stage (0).
|
boolean |
isSkipWorkTree()
Returns whether this entry should be skipped from the working tree.
|
boolean |
isSmudged()
Check whether this entry has been smudged or not
|
boolean |
isUpdateNeeded() |
boolean |
mightBeRacilyClean(int smudge_s,
int smudge_ns)
Is it possible for this entry to be accidentally assumed clean?
|
void |
setAssumeValid(boolean assume)
Set the assume valid flag for this entry,
|
void |
setCreationTime(long when)
Set the cached creation time of this file, using milliseconds.
|
void |
setFileMode(FileMode mode)
Set the file mode for this entry.
|
void |
setLastModified(long when)
Set the cached last modification date of this file, using milliseconds.
|
void |
setLength(int sz)
Set the cached size (in bytes) of this file.
|
void |
setLength(long sz)
Set the cached size (in bytes) of this file.
|
void |
setObjectId(AnyObjectId id)
Set the ObjectId for the entry.
|
void |
setObjectIdFromRaw(byte[] bs,
int p)
Set the ObjectId for the entry from the raw binary representation.
|
void |
setUpdateNeeded(boolean updateNeeded)
Set whether this entry must be checked for changes
|
void |
smudgeRacilyClean()
Force this entry to no longer match its working tree file.
|
String |
toString()
Use for debugging only !
|
public static final int STAGE_0
public static final int STAGE_1
public static final int STAGE_2
public static final int STAGE_3
public DirCacheEntry(String newPath)
newPath
- name of the cache entry.IllegalArgumentException
- If the path starts or ends with "/", or contains "//" either
"\0". These sequences are not permitted in a git tree object
or DirCache file.public DirCacheEntry(String newPath, int stage)
newPath
- name of the cache entry.stage
- the stage index of the new entry.IllegalArgumentException
- If the path starts or ends with "/", or contains "//" either
"\0". These sequences are not permitted in a git tree object
or DirCache file. Or if stage
is outside of the
range 0..3, inclusive.public DirCacheEntry(byte[] newPath)
newPath
- name of the cache entry, in the standard encoding.IllegalArgumentException
- If the path starts or ends with "/", or contains "//" either
"\0". These sequences are not permitted in a git tree object
or DirCache file.public DirCacheEntry(byte[] path, int stage)
path
- name of the cache entry, in the standard encoding.stage
- the stage index of the new entry.IllegalArgumentException
- If the path starts or ends with "/", or contains "//" either
"\0". These sequences are not permitted in a git tree object
or DirCache file. Or if stage
is outside of the
range 0..3, inclusive.public DirCacheEntry(DirCacheEntry src)
The same path buffer is reused (avoiding copying), however a new info buffer is created and its contents are copied.
src
- entry to clone.public final boolean mightBeRacilyClean(int smudge_s, int smudge_ns)
The "racy git" problem happens when a work file can be updated faster than the filesystem records file modification timestamps. It is possible for an application to edit a work file, update the index, then edit it again before the filesystem will give the work file a new modification timestamp. This method tests to see if file was written out at the same time as the index.
smudge_s
- seconds component of the index's last modified time.smudge_ns
- nanoseconds component of the index's last modified time.public final void smudgeRacilyClean()
This avoids the "racy git" problem by making this index entry no longer match the file in the working directory. Later git will be forced to compare the file content to ensure the file matches the working tree.
public final boolean isSmudged()
If a blob has length 0 we know his id see Constants.EMPTY_BLOB_ID
. If an entry
has length 0 and an ID different from the one for empty blob we know this
entry was smudged.
true
if the entry is smudged, false
otherwisepublic boolean isAssumeValid()
Most entries in the index do not have this flag set. Users may however set them on if the file system stat() costs are too high on this working directory, such as on NFS or SMB volumes.
public void setAssumeValid(boolean assume)
assume
- true to ignore apparent modifications; false to look at last
modified to detect file modifications.public boolean isUpdateNeeded()
public void setUpdateNeeded(boolean updateNeeded)
updateNeeded
- public int getStage()
Entries have one of 4 possible stages: 0-3.
public boolean isSkipWorkTree()
public boolean isIntentToAdd()
public boolean isMerged()
public int getRawMode()
FileMode
bits for this entry.FileMode.fromBits(int)
public FileMode getFileMode()
FileMode
for this entry.public void setFileMode(FileMode mode)
mode
- the new mode constant.IllegalArgumentException
- If mode
is FileMode.MISSING
,
FileMode.TREE
, or any other type code not permitted
in a tree object.public long getCreationTime()
public void setCreationTime(long when)
when
- new cached creation time of the file, in milliseconds.public long getLastModified()
One of the indicators that the file has been modified by an application changing the working tree is if the last modification time for the file differs from the time stored in this entry.
public void setLastModified(long when)
when
- new cached modification date of the file, in milliseconds.public int getLength()
One of the indicators that the file has been modified by an application changing the working tree is if the size of the file (in bytes) differs from the size stored in this entry.
Note that this is the length of the file in the working directory, which may differ from the size of the decompressed blob if work tree filters are being used, such as LF<->CRLF conversion.
Note also that for very large files, this is the size of the on-disk file truncated to 32 bits, i.e. modulo 4294967296. If that value is larger than 2GB, it will appear negative.
public void setLength(int sz)
sz
- new cached size of the file, as bytes. If the file is larger
than 2G, cast it to (int) before calling this method.public void setLength(long sz)
sz
- new cached size of the file, as bytes.public ObjectId getObjectId()
Using this method to compare ObjectId values between entries is inefficient as it causes memory allocation.
public void setObjectId(AnyObjectId id)
id
- new object identifier for the entry. May be
ObjectId.zeroId()
to remove the current identifier.public void setObjectIdFromRaw(byte[] bs, int p)
bs
- the raw byte buffer to read from. At least 20 bytes after p
must be available within this byte array.p
- position to read the first byte of data from.public String getPathString()
This method is not very efficient and is primarily meant for debugging and final output generation. Applications should try to avoid calling it, and if invoked do so only once per interesting entry, where the name is absolutely required for correct function.
public byte[] getRawPath()
public void copyMetaData(DirCacheEntry src)
This method copies everything except the path from one entry to another, supporting renaming.
src
- the entry to copy ObjectId and meta fields from.Copyright © 2017 Eclipse JGit Project. All rights reserved.