Top Description Fields Constructors Methods
org.eclipse.jgit.internal.storage.file

public Class ReflogWriter

extends Object
Class Inheritance
Static Imports
org.eclipse.jgit.lib.Constants.HEAD, .Constants.LOCK_SUFFIX, .Constants.R_HEADS, .Constants.R_NOTES, .Constants.R_REFS, .Constants.R_REMOTES

Utility for writing reflog entries using the traditional one-file-per-log format.

Field Summary

Modifier and TypeField and Description
private final boolean
private final RefDirectory

Constructor Summary

AccessConstructor and Description
public
ReflogWriter(RefDirectory refdb)

Create writer for ref directory.

public
ReflogWriter(RefDirectory refdb, boolean
true to write to disk all entries logged, false to respect the repository's config and current log file status.
forceWrite
)

Create writer for ref directory.

Method Summary

Modifier and TypeMethod and Description
public ReflogWriter

Returns:

this writer.
create
()

Create the log directories.

private byte[]
encode(ObjectId oldId, ObjectId newId, PersonIdent ident, String message)

private FileOutputStream
public ReflogWriter

Returns:

this writer
log
(String refName, ReflogEntry entry)

Write the given entry to the ref's log.

public ReflogWriter

Returns:

this writer
log
(String
ref name
refName
,
ObjectId
old object id
oldId
,
ObjectId
new object id
newId
,
PersonIdent ident, String
reflog message
message
)

Write the given entry information to the ref's log

public ReflogWriter

Returns:

this writer
log
(RefUpdate update, String
reflog message
msg
,
boolean
whether to dereference symbolic refs
deref
)

Write the given ref update to the ref's log.

private ReflogWriter
log(String refName, byte[] rec)

public static String

Returns:

the name of the ref's lock ref.
refLockFor
(String
name of the ref, relative to the Git repository top level directory (so typically starts with refs/).
name
)

Get the ref name to be used for when locking a ref's log for rewriting.

private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

forceWriteback to summary
private final boolean forceWrite
refdbback to summary
private final RefDirectory refdb

Constructor Detail

ReflogWriterback to summary
public ReflogWriter(RefDirectory refdb)

Create writer for ref directory.

Parameters
refdb:RefDirectory

a org.eclipse.jgit.internal.storage.file.RefDirectory object.

ReflogWriterback to summary
public ReflogWriter(RefDirectory refdb, boolean forceWrite)

Create writer for ref directory.

Parameters
refdb:RefDirectory

a org.eclipse.jgit.internal.storage.file.RefDirectory object.

forceWrite:boolean

true to write to disk all entries logged, false to respect the repository's config and current log file status.

Method Detail

createback to summary
public ReflogWriter create() throws IOException

Create the log directories.

Returns:ReflogWriter

this writer.

Exceptions
IOException:
if an IO error occurred
encodeback to summary
private byte[] encode(ObjectId oldId, ObjectId newId, PersonIdent ident, String message)
getFileOutputStreamback to summary
private FileOutputStream getFileOutputStream(File log) throws IOException
logback to summary
public ReflogWriter log(String refName, ReflogEntry entry) throws IOException

Write the given entry to the ref's log.

Parameters
refName:String

a java.lang.String object.

entry:ReflogEntry

a org.eclipse.jgit.lib.ReflogEntry object.

Returns:ReflogWriter

this writer

Exceptions
IOException:
if an IO error occurred
logback to summary
public ReflogWriter log(String refName, ObjectId oldId, ObjectId newId, PersonIdent ident, String message) throws IOException

Write the given entry information to the ref's log

Parameters
refName:String

ref name

oldId:ObjectId

old object id

newId:ObjectId

new object id

ident:PersonIdent

a org.eclipse.jgit.lib.PersonIdent

message:String

reflog message

Returns:ReflogWriter

this writer

Exceptions
IOException:
if an IO error occurred
logback to summary
public ReflogWriter log(RefUpdate update, String msg, boolean deref) throws IOException

Write the given ref update to the ref's log.

Parameters
update:RefUpdate

a org.eclipse.jgit.lib.RefUpdate

msg:String

reflog message

deref:boolean

whether to dereference symbolic refs

Returns:ReflogWriter

this writer

Exceptions
IOException:
if an IO error occurred
logback to summary
private ReflogWriter log(String refName, byte[] rec) throws IOException
refLockForback to summary
public static String refLockFor(String name)

Get the ref name to be used for when locking a ref's log for rewriting.

Parameters
name:String

name of the ref, relative to the Git repository top level directory (so typically starts with refs/).

Returns:String

the name of the ref's lock ref.

shouldAutoCreateLogback to summary
private boolean shouldAutoCreateLog(String refName)