Top Description Inners Fields Constructors Methods
org.eclipse.jgit.transport

pack-priv abstract Class WalkRemoteObjectDatabase

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.transport.TransportAmazonS3.DatabaseS3, org.eclipse.jgit.transport.TransportHttp.HttpObjectDB, org.eclipse.jgit.transport.TransportSftp.SftpObjectDB
Static Imports
java.nio.charset.StandardCharsets.UTF_8

Transfers object data through a dumb transport.

Implementations are responsible for resolving path names relative to the objects/ subdirectory of a single remote Git repository or naked object database and make the content available as a Java input stream for reading during fetch. The actual object traversal logic to determine the names of files to retrieve is handled through the generic, protocol independent WalkFetchConnection.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv static final String
pack-priv static final String
pack-priv static final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract void
close()

Close any resources used by this connection.

pack-priv void
deleteFile(String
name of the item to be removed, relative to the current object database.
path
)

Delete a file from the object database.

pack-priv void
deleteRef(String
name of the ref within the ref space, for example refs/heads/pu.
name
)

Delete a loose ref from the remote repository.

pack-priv void
deleteRefLog(String
name of the ref within the ref space, for example refs/heads/pu.
name
)

Delete a reflog from the remote repository.

pack-priv abstract Collection<WalkRemoteObjectDatabase>

Returns:

list of additional object databases the caller could fetch from; null or empty list if none are configured.
getAlternates
()

Obtain alternate connections to alternate object databases (if any).

pack-priv abstract Collection<String>

Returns:

list of pack names; null or empty list if none are available.
getPackNames
()

Obtain the list of available packs (if any).

pack-priv abstract URIish
pack-priv abstract WalkRemoteObjectDatabase.FileStream

Returns:

a stream to read from the file. Never null.
open
(String
location of the file to read, relative to this objects directory (e.g. cb/95df6ab7ae9e57571511ef451cf33767c26dd2 or pack/pack-035760ab452d6eebd123add421f253ce7682355a.pack).
path
)

Open a single file for reading.

pack-priv abstract WalkRemoteObjectDatabase

Returns:

a new database connection that can read from the specified alternate.
openAlternate
(String
the location of the new alternate, relative to the current object database.
location
)

Create a new connection for a discovered alternate object database

This method is typically called by readAlternates(String) when subclasses us the generic alternate parsing logic for their implementation of getAlternates().

pack-priv BufferedReader

Returns:

a stream to read from the file. Never null.
openReader
(String
location of the file to read, relative to this objects directory (e.g. info/packs).
path
)

Open a buffered reader around a file.

pack-priv Collection<WalkRemoteObjectDatabase>

Returns:

the list of discovered alternates. Empty list if the file exists, but no entries were discovered.
readAlternates
(final String
location of the alternate file to read, relative to this object database (e.g. info/alternates).
listPath
)

Read a standard Git alternates file to discover other object databases.

protected void
readPackedRefs(Map<String, Ref>
return collection of references. Any existing entries will be replaced if they are found in the packed-refs file.
avail
)

Read a standard Git packed-refs file to discover known references.

private void
readPackedRefsImpl(final Map<String, Ref> avail, final BufferedReader br)

pack-priv OutputStream

Returns:

stream to write into this file. Caller must close the stream to complete the write request. The stream is not buffered and each write may cause a network request/response so callers should buffer to smooth out small writes.
writeFile
(final String
name of the file to write, relative to the current object database.
path
,
final ProgressMonitor
(optional) progress monitor to post write completion to during the stream's close method.
monitor
,
final String
(optional) task name to display during the close method.
monitorTask
)

Open a remote file for writing.

pack-priv void
writeFile(String
name of the file to write, relative to the current object database.
path
,
byte[]
complete new content of the file.
data
)

Atomically write a remote file.

pack-priv void
writeInfoPacks(Collection<String>
names of available pack files, in the order they should appear in the file. Valid pack name strings are of the form pack-035760ab452d6eebd123add421f253ce7682355a.pack.
packNames
)

Rebuild the INFO_PACKS for dumb transport clients.

pack-priv void
writeRef(String
name of the ref within the ref space, for example refs/heads/pu.
name
,
ObjectId
new value to store in this ref. Must not be null.
value
)

Overwrite (or create) a loose ref in the remote repository.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INFO_PACKSback to summary
pack-priv static final String INFO_PACKS
INFO_REFSback to summary
pack-priv static final String INFO_REFS
ROOT_DIRback to summary
pack-priv static final String ROOT_DIR

Constructor Detail

WalkRemoteObjectDatabaseback to summary
pack-priv WalkRemoteObjectDatabase()

Method Detail

closeback to summary
pack-priv abstract void close()

Close any resources used by this connection.

If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.

deleteFileback to summary
pack-priv void deleteFile(String path) throws IOException

Delete a file from the object database.

Path may start with ../ to request deletion of a file that resides in the repository itself.

When possible empty directories must be removed, up to but not including the current object database directory itself.

This method does not support deletion of directories.

Parameters
path:String

name of the item to be removed, relative to the current object database.

Exceptions
IOException:
deletion is not supported, or deletion failed.
deleteRefback to summary
pack-priv void deleteRef(String name) throws IOException

Delete a loose ref from the remote repository.

Parameters
name:String

name of the ref within the ref space, for example refs/heads/pu.

Exceptions
IOException:
deletion is not supported, or deletion failed.
deleteRefLogback to summary
pack-priv void deleteRefLog(String name) throws IOException

Delete a reflog from the remote repository.

Parameters
name:String

name of the ref within the ref space, for example refs/heads/pu.

Exceptions
IOException:
deletion is not supported, or deletion failed.
getAlternatesback to summary
pack-priv abstract Collection<WalkRemoteObjectDatabase> getAlternates() throws IOException

Obtain alternate connections to alternate object databases (if any).

Alternates are typically read from the file org.eclipse.jgit.lib.Constants#INFO_ALTERNATES or org.eclipse.jgit.lib.Constants#INFO_HTTP_ALTERNATES. The content of each line must be resolved by the implementation and a new database reference should be returned to represent the additional location.

Alternates may reuse the same network connection handle, however the fetch connection will close() each created alternate.

Returns:Collection<WalkRemoteObjectDatabase>

list of additional object databases the caller could fetch from; null or empty list if none are configured.

Exceptions
IOException:
The connection is unable to read the remote repository's list of configured alternates.
getPackNamesback to summary
pack-priv abstract Collection<String> getPackNames() throws IOException

Obtain the list of available packs (if any).

Pack names should be the file name in the packs directory, that is pack-035760ab452d6eebd123add421f253ce7682355a.pack. Index names should not be included in the returned collection.

Returns:Collection<String>

list of pack names; null or empty list if none are available.

Exceptions
IOException:
The connection is unable to read the remote repository's list of available pack files.
getURIback to summary
pack-priv abstract URIish getURI()
openback to summary
pack-priv abstract WalkRemoteObjectDatabase.FileStream open(String path) throws FileNotFoundException, IOException

Open a single file for reading.

Implementors should make every attempt possible to ensure FileNotFoundException is used when the remote object does not exist. However when fetching over HTTP some misconfigured servers may generate a 200 OK status message (rather than a 404 Not Found) with an HTML formatted message explaining the requested resource does not exist. Callers such as WalkFetchConnection are prepared to handle this by validating the content received, and assuming content that fails to match its hash is an incorrectly phrased FileNotFoundException.

This method is recommended for already compressed files like loose objects and pack files. For text files, see openReader(String).

Parameters
path:String

location of the file to read, relative to this objects directory (e.g. cb/95df6ab7ae9e57571511ef451cf33767c26dd2 or pack/pack-035760ab452d6eebd123add421f253ce7682355a.pack).

Returns:WalkRemoteObjectDatabase.FileStream

a stream to read from the file. Never null.

Exceptions
FileNotFoundException:
the requested file does not exist at the given location.
IOException:
The connection is unable to read the remote's file, and the failure occurred prior to being able to determine if the file exists, or after it was determined to exist but before the stream could be created.
openAlternateback to summary
pack-priv abstract WalkRemoteObjectDatabase openAlternate(String location) throws IOException

Create a new connection for a discovered alternate object database

This method is typically called by readAlternates(String) when subclasses us the generic alternate parsing logic for their implementation of getAlternates().

Parameters
location:String

the location of the new alternate, relative to the current object database.

Returns:WalkRemoteObjectDatabase

a new database connection that can read from the specified alternate.

Exceptions
IOException:
The database connection cannot be established with the alternate, such as if the alternate location does not actually exist and the connection's constructor attempts to verify that.
openReaderback to summary
pack-priv BufferedReader openReader(String path) throws IOException

Open a buffered reader around a file.

This method is suitable for reading line-oriented resources like info/packs, info/refs, and the alternates list.

Parameters
path:String

location of the file to read, relative to this objects directory (e.g. info/packs).

Returns:BufferedReader

a stream to read from the file. Never null.

Exceptions
IOException:
The connection is unable to read the remote's file, and the failure occurred prior to being able to determine if the file exists, or after it was determined to exist but before the stream could be created.
FileNotFoundException:
the requested file does not exist at the given location.
readAlternatesback to summary
pack-priv Collection<WalkRemoteObjectDatabase> readAlternates(final String listPath) throws IOException

Read a standard Git alternates file to discover other object databases.

This method is suitable for reading the standard formats of the alternates file, such as found in objects/info/alternates or objects/info/http-alternates within a Git repository.

Alternates appear one per line, with paths expressed relative to this object database.

Parameters
listPath:String

location of the alternate file to read, relative to this object database (e.g. info/alternates).

Returns:Collection<WalkRemoteObjectDatabase>

the list of discovered alternates. Empty list if the file exists, but no entries were discovered.

Exceptions
IOException:
The connection is unable to read the remote's file, and the failure occurred prior to being able to determine if the file exists, or after it was determined to exist but before the stream could be created.
FileNotFoundException:
the requested file does not exist at the given location.
readPackedRefsback to summary
protected void readPackedRefs(Map<String, Ref> avail) throws TransportException

Read a standard Git packed-refs file to discover known references.

Parameters
avail:Map<String, Ref>

return collection of references. Any existing entries will be replaced if they are found in the packed-refs file.

Exceptions
TransportException:
an error occurred reading from the packed refs file.
readPackedRefsImplback to summary
private void readPackedRefsImpl(final Map<String, Ref> avail, final BufferedReader br) throws IOException
writeFileback to summary
pack-priv OutputStream writeFile(final String path, final ProgressMonitor monitor, final String monitorTask) throws IOException

Open a remote file for writing.

Path may start with ../ to request writing of a file that resides in the repository itself.

The requested path may or may not exist. If the path already exists as a file the file should be truncated and completely replaced.

This method creates any missing parent directories, if necessary.

Parameters
path:String

name of the file to write, relative to the current object database.

monitor:ProgressMonitor

(optional) progress monitor to post write completion to during the stream's close method.

monitorTask:String

(optional) task name to display during the close method.

Returns:OutputStream

stream to write into this file. Caller must close the stream to complete the write request. The stream is not buffered and each write may cause a network request/response so callers should buffer to smooth out small writes.

Exceptions
IOException:
writing is not supported, or attempting to write the file failed, possibly due to permissions or remote disk full, etc.
writeFileback to summary
pack-priv void writeFile(String path, byte[] data) throws IOException

Atomically write a remote file.

This method attempts to perform as atomic of an update as it can, reducing (or eliminating) the time that clients might be able to see partial file content. This method is not suitable for very large transfers as the complete content must be passed as an argument.

Path may start with ../ to request writing of a file that resides in the repository itself.

The requested path may or may not exist. If the path already exists as a file the file should be truncated and completely replaced.

This method creates any missing parent directories, if necessary.

Parameters
path:String

name of the file to write, relative to the current object database.

data:byte[]

complete new content of the file.

Exceptions
IOException:
writing is not supported, or attempting to write the file failed, possibly due to permissions or remote disk full, etc.
writeInfoPacksback to summary
pack-priv void writeInfoPacks(Collection<String> packNames) throws IOException

Rebuild the INFO_PACKS for dumb transport clients.

This method rebuilds the contents of the INFO_PACKS file to match the passed list of pack names.

Parameters
packNames:Collection<String>

names of available pack files, in the order they should appear in the file. Valid pack name strings are of the form pack-035760ab452d6eebd123add421f253ce7682355a.pack.

Exceptions
IOException:
writing is not supported, or attempting to write the file failed, possibly due to permissions or remote disk full, etc.
writeRefback to summary
pack-priv void writeRef(String name, ObjectId value) throws IOException

Overwrite (or create) a loose ref in the remote repository.

This method creates any missing parent directories, if necessary.

Parameters
name:String

name of the ref within the ref space, for example refs/heads/pu.

value:ObjectId

new value to store in this ref. Must not be null.

Exceptions
IOException:
writing is not supported, or attempting to write the file failed, possibly due to permissions or remote disk full, etc.
org.eclipse.jgit.transport back to summary

pack-priv final Class WalkRemoteObjectDatabase.FileStream

extends Object
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.transport.WalkRemoteObjectDatabase.FileStream

Field Summary

Modifier and TypeField and Description
pack-priv final InputStream
pack-priv final long

Constructor Summary

AccessConstructor and Description
pack-priv
FileStream(InputStream
stream containing the file data. This stream will be closed by the caller when reading is complete.
i
)

Create a new stream of unknown length.

pack-priv
FileStream(InputStream
stream containing the file data. This stream will be closed by the caller when reading is complete.
i
,
long
total number of bytes available for reading through i.
n
)

Create a new stream of known length.

Method Summary

Modifier and TypeMethod and Description
pack-priv byte[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

inback to summary
pack-priv final InputStream in
lengthback to summary
pack-priv final long length

Constructor Detail

FileStreamback to summary
pack-priv FileStream(InputStream i)

Create a new stream of unknown length.

Parameters
i:InputStream

stream containing the file data. This stream will be closed by the caller when reading is complete.

FileStreamback to summary
pack-priv FileStream(InputStream i, long n)

Create a new stream of known length.

Parameters
i:InputStream

stream containing the file data. This stream will be closed by the caller when reading is complete.

n:long

total number of bytes available for reading through i.

Method Detail

toArrayback to summary
pack-priv byte[] toArray() throws IOException