Class ReflogWriter
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.file.ReflogWriter
-
public class ReflogWriter extends java.lang.Object
Utility for writing reflog entries using the traditional one-file-per-log format.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
forceWrite
private RefDirectory
refdb
-
Constructor Summary
Constructors Constructor Description ReflogWriter(RefDirectory refdb)
Create writer for ref directory.ReflogWriter(RefDirectory refdb, boolean forceWrite)
Create writer for ref directory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ReflogWriter
create()
Create the log directories.private byte[]
encode(ObjectId oldId, ObjectId newId, PersonIdent ident, java.lang.String message)
private java.io.FileOutputStream
getFileOutputStream(java.io.File log)
private ReflogWriter
log(java.lang.String refName, byte[] rec)
ReflogWriter
log(java.lang.String refName, ObjectId oldId, ObjectId newId, PersonIdent ident, java.lang.String message)
Write the given entry information to the ref's logReflogWriter
log(java.lang.String refName, ReflogEntry entry)
Write the given entry to the ref's log.ReflogWriter
log(RefUpdate update, java.lang.String msg, boolean deref)
Write the given ref update to the ref's log.static java.lang.String
refLockFor(java.lang.String name)
Get the ref name to be used for when locking a ref's log for rewriting.private boolean
shouldAutoCreateLog(java.lang.String refName)
-
-
-
Field Detail
-
refdb
private final RefDirectory refdb
-
forceWrite
private final boolean forceWrite
-
-
Constructor Detail
-
ReflogWriter
public ReflogWriter(RefDirectory refdb)
Create writer for ref directory.- Parameters:
refdb
- aRefDirectory
object.
-
ReflogWriter
public ReflogWriter(RefDirectory refdb, boolean forceWrite)
Create writer for ref directory.- Parameters:
refdb
- aRefDirectory
object.forceWrite
- true to write to disk all entries logged, false to respect the repository's config and current log file status.
-
-
Method Detail
-
refLockFor
public static java.lang.String refLockFor(java.lang.String name)
Get the ref name to be used for when locking a ref's log for rewriting.- Parameters:
name
- name of the ref, relative to the Git repository top level directory (so typically starts with refs/).- Returns:
- the name of the ref's lock ref.
-
create
public ReflogWriter create() throws java.io.IOException
Create the log directories.- Returns:
- this writer.
- Throws:
java.io.IOException
-
log
public ReflogWriter log(java.lang.String refName, ReflogEntry entry) throws java.io.IOException
Write the given entry to the ref's log.- Parameters:
refName
- aString
object.entry
- aReflogEntry
object.- Returns:
- this writer
- Throws:
java.io.IOException
-
log
public ReflogWriter log(java.lang.String refName, ObjectId oldId, ObjectId newId, PersonIdent ident, java.lang.String message) throws java.io.IOException
Write the given entry information to the ref's log- Parameters:
refName
- ref nameoldId
- old object idnewId
- new object idident
- aPersonIdent
message
- reflog message- Returns:
- this writer
- Throws:
java.io.IOException
-
log
public ReflogWriter log(RefUpdate update, java.lang.String msg, boolean deref) throws java.io.IOException
Write the given ref update to the ref's log.- Parameters:
update
- aRefUpdate
msg
- reflog messagederef
- whether to dereference symbolic refs- Returns:
- this writer
- Throws:
java.io.IOException
-
encode
private byte[] encode(ObjectId oldId, ObjectId newId, PersonIdent ident, java.lang.String message)
-
getFileOutputStream
private java.io.FileOutputStream getFileOutputStream(java.io.File log) throws java.io.IOException
- Throws:
java.io.IOException
-
log
private ReflogWriter log(java.lang.String refName, byte[] rec) throws java.io.IOException
- Throws:
java.io.IOException
-
shouldAutoCreateLog
private boolean shouldAutoCreateLog(java.lang.String refName)
-
-