Class RemoteConfig
- java.lang.Object
-
- org.eclipse.jgit.transport.RemoteConfig
-
- All Implemented Interfaces:
java.io.Serializable
public class RemoteConfig extends java.lang.Object implements java.io.Serializable
A remembered remote repository, including URLs and RefSpecs.A remote configuration remembers one or more URLs for a frequently accessed remote repository as well as zero or more fetch and push specifications describing how refs should be transferred between this repository and the remote repository.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
DEFAULT_MIRROR
static java.lang.String
DEFAULT_RECEIVE_PACK
Default value forgetReceivePack()
if not specified.static java.lang.String
DEFAULT_UPLOAD_PACK
Default value forgetUploadPack()
if not specified.private java.util.List<RefSpec>
fetch
private static java.lang.String
KEY_FETCH
private static java.lang.String
KEY_INSTEADOF
private static java.lang.String
KEY_MIRROR
private static java.lang.String
KEY_PUSH
private static java.lang.String
KEY_PUSHINSTEADOF
private static java.lang.String
KEY_PUSHURL
private static java.lang.String
KEY_RECEIVEPACK
private static java.lang.String
KEY_TAGOPT
private static java.lang.String
KEY_TIMEOUT
private static java.lang.String
KEY_UPLOADPACK
private static java.lang.String
KEY_URL
private boolean
mirror
private java.lang.String
name
private java.util.List<RefSpec>
push
private java.util.List<URIish>
pushURIs
private java.lang.String
receivepack
private static java.lang.String
SECTION
private static long
serialVersionUID
private TagOpt
tagopt
private int
timeout
private java.lang.String
uploadpack
private java.util.List<URIish>
uris
-
Constructor Summary
Constructors Constructor Description RemoteConfig(Config rc, java.lang.String remoteName)
Parse a remote block from an existing configuration file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addFetchRefSpec(RefSpec s)
Add a new fetch RefSpec to this remote.boolean
addPushRefSpec(RefSpec s)
Add a new push RefSpec to this remote.boolean
addPushURI(URIish toAdd)
Add a new push-only URI to the end of the list of URIs.boolean
addURI(URIish toAdd)
Add a new URI to the end of the list of URIs.static java.util.List<RemoteConfig>
getAllRemoteConfigs(Config rc)
Parse all remote blocks in an existing configuration file, looking for remotes configuration.java.util.List<RefSpec>
getFetchRefSpecs()
Remembered specifications for fetching from a repository.java.lang.String
getName()
Get the local name this remote configuration is recognized as.java.util.List<RefSpec>
getPushRefSpecs()
Remembered specifications for pushing to a repository.java.util.List<URIish>
getPushURIs()
Get all configured push-only URIs under this remote.java.lang.String
getReceivePack()
Override for the location of 'git-receive-pack' on the remote system.private java.util.Map<java.lang.String,java.lang.String>
getReplacements(Config config, java.lang.String keyName)
TagOpt
getTagOpt()
Get the description of how annotated tags should be treated during fetch.int
getTimeout()
Get timeout (in seconds) before aborting an IO operation.java.lang.String
getUploadPack()
Override for the location of 'git-upload-pack' on the remote system.java.util.List<URIish>
getURIs()
Get all configured URIs under this remote.boolean
isMirror()
Whether pushing to the remote automatically deletes remote refs which don't exist on the source side.boolean
removeFetchRefSpec(RefSpec s)
Remove a fetch RefSpec from this remote.boolean
removePushRefSpec(RefSpec s)
Remove a push RefSpec from this remote.boolean
removePushURI(URIish toRemove)
Remove a push-only URI from the list of URIs.boolean
removeURI(URIish toRemove)
Remove a URI from the list of URIs.private java.lang.String
replaceUri(java.lang.String uri, java.util.Map<java.lang.String,java.lang.String> replacements)
private void
set(Config rc, java.lang.String key, boolean currentValue, boolean defaultValue)
private void
set(Config rc, java.lang.String key, int currentValue, int defaultValue)
private void
set(Config rc, java.lang.String key, java.lang.String currentValue, java.lang.String defaultValue)
void
setFetchRefSpecs(java.util.List<RefSpec> specs)
Override existing fetch specifications with new ones.void
setMirror(boolean m)
Set the mirror flag to automatically delete remote refs.void
setPushRefSpecs(java.util.List<RefSpec> specs)
Override existing push specifications with new ones.void
setTagOpt(TagOpt option)
Set the description of how annotated tags should be treated on fetch.void
setTimeout(int seconds)
Set the timeout before willing to abort an IO call.private void
unset(Config rc, java.lang.String key)
void
update(Config rc)
Update this remote's definition within the configuration.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
SECTION
private static final java.lang.String SECTION
- See Also:
- Constant Field Values
-
KEY_URL
private static final java.lang.String KEY_URL
- See Also:
- Constant Field Values
-
KEY_PUSHURL
private static final java.lang.String KEY_PUSHURL
- See Also:
- Constant Field Values
-
KEY_FETCH
private static final java.lang.String KEY_FETCH
- See Also:
- Constant Field Values
-
KEY_PUSH
private static final java.lang.String KEY_PUSH
- See Also:
- Constant Field Values
-
KEY_UPLOADPACK
private static final java.lang.String KEY_UPLOADPACK
- See Also:
- Constant Field Values
-
KEY_RECEIVEPACK
private static final java.lang.String KEY_RECEIVEPACK
- See Also:
- Constant Field Values
-
KEY_TAGOPT
private static final java.lang.String KEY_TAGOPT
- See Also:
- Constant Field Values
-
KEY_MIRROR
private static final java.lang.String KEY_MIRROR
- See Also:
- Constant Field Values
-
KEY_TIMEOUT
private static final java.lang.String KEY_TIMEOUT
- See Also:
- Constant Field Values
-
KEY_INSTEADOF
private static final java.lang.String KEY_INSTEADOF
- See Also:
- Constant Field Values
-
KEY_PUSHINSTEADOF
private static final java.lang.String KEY_PUSHINSTEADOF
- See Also:
- Constant Field Values
-
DEFAULT_MIRROR
private static final boolean DEFAULT_MIRROR
- See Also:
- Constant Field Values
-
DEFAULT_UPLOAD_PACK
public static final java.lang.String DEFAULT_UPLOAD_PACK
Default value forgetUploadPack()
if not specified.- See Also:
- Constant Field Values
-
DEFAULT_RECEIVE_PACK
public static final java.lang.String DEFAULT_RECEIVE_PACK
Default value forgetReceivePack()
if not specified.- See Also:
- Constant Field Values
-
name
private java.lang.String name
-
uris
private java.util.List<URIish> uris
-
pushURIs
private java.util.List<URIish> pushURIs
-
fetch
private java.util.List<RefSpec> fetch
-
push
private java.util.List<RefSpec> push
-
uploadpack
private java.lang.String uploadpack
-
receivepack
private java.lang.String receivepack
-
tagopt
private TagOpt tagopt
-
mirror
private boolean mirror
-
timeout
private int timeout
-
-
Constructor Detail
-
RemoteConfig
public RemoteConfig(Config rc, java.lang.String remoteName) throws java.net.URISyntaxException
Parse a remote block from an existing configuration file.This constructor succeeds even if the requested remote is not defined within the supplied configuration file. If that occurs then there will be no URIs and no ref specifications known to the new instance.
- Parameters:
rc
- the existing configuration to get the remote settings from. The configuration must already be loaded into memory.remoteName
- subsection key indicating the name of this remote.- Throws:
java.net.URISyntaxException
- one of the URIs within the remote's configuration is invalid.
-
-
Method Detail
-
getAllRemoteConfigs
public static java.util.List<RemoteConfig> getAllRemoteConfigs(Config rc) throws java.net.URISyntaxException
Parse all remote blocks in an existing configuration file, looking for remotes configuration.- Parameters:
rc
- the existing configuration to get the remote settings from. The configuration must already be loaded into memory.- Returns:
- all remotes configurations existing in provided repository configuration. Returned configurations are ordered lexicographically by names.
- Throws:
java.net.URISyntaxException
- one of the URIs within the remote's configuration is invalid.
-
update
public void update(Config rc)
Update this remote's definition within the configuration.- Parameters:
rc
- the configuration file to store ourselves into.
-
set
private void set(Config rc, java.lang.String key, java.lang.String currentValue, java.lang.String defaultValue)
-
set
private void set(Config rc, java.lang.String key, boolean currentValue, boolean defaultValue)
-
set
private void set(Config rc, java.lang.String key, int currentValue, int defaultValue)
-
unset
private void unset(Config rc, java.lang.String key)
-
getReplacements
private java.util.Map<java.lang.String,java.lang.String> getReplacements(Config config, java.lang.String keyName)
-
replaceUri
private java.lang.String replaceUri(java.lang.String uri, java.util.Map<java.lang.String,java.lang.String> replacements)
-
getName
public java.lang.String getName()
Get the local name this remote configuration is recognized as.- Returns:
- name assigned by the user to this configuration block.
-
getURIs
public java.util.List<URIish> getURIs()
Get all configured URIs under this remote.- Returns:
- the set of URIs known to this remote.
-
addURI
public boolean addURI(URIish toAdd)
Add a new URI to the end of the list of URIs.- Parameters:
toAdd
- the new URI to add to this remote.- Returns:
- true if the URI was added; false if it already exists.
-
removeURI
public boolean removeURI(URIish toRemove)
Remove a URI from the list of URIs.- Parameters:
toRemove
- the URI to remove from this remote.- Returns:
- true if the URI was added; false if it already exists.
-
getPushURIs
public java.util.List<URIish> getPushURIs()
Get all configured push-only URIs under this remote.- Returns:
- the set of URIs known to this remote.
-
addPushURI
public boolean addPushURI(URIish toAdd)
Add a new push-only URI to the end of the list of URIs.- Parameters:
toAdd
- the new URI to add to this remote.- Returns:
- true if the URI was added; false if it already exists.
-
removePushURI
public boolean removePushURI(URIish toRemove)
Remove a push-only URI from the list of URIs.- Parameters:
toRemove
- the URI to remove from this remote.- Returns:
- true if the URI was added; false if it already exists.
-
getFetchRefSpecs
public java.util.List<RefSpec> getFetchRefSpecs()
Remembered specifications for fetching from a repository.- Returns:
- set of specs used by default when fetching.
-
addFetchRefSpec
public boolean addFetchRefSpec(RefSpec s)
Add a new fetch RefSpec to this remote.- Parameters:
s
- the new specification to add.- Returns:
- true if the specification was added; false if it already exists.
-
setFetchRefSpecs
public void setFetchRefSpecs(java.util.List<RefSpec> specs)
Override existing fetch specifications with new ones.- Parameters:
specs
- list of fetch specifications to set. List is copied, it can be modified after this call.
-
setPushRefSpecs
public void setPushRefSpecs(java.util.List<RefSpec> specs)
Override existing push specifications with new ones.- Parameters:
specs
- list of push specifications to set. List is copied, it can be modified after this call.
-
removeFetchRefSpec
public boolean removeFetchRefSpec(RefSpec s)
Remove a fetch RefSpec from this remote.- Parameters:
s
- the specification to remove.- Returns:
- true if the specification existed and was removed.
-
getPushRefSpecs
public java.util.List<RefSpec> getPushRefSpecs()
Remembered specifications for pushing to a repository.- Returns:
- set of specs used by default when pushing.
-
addPushRefSpec
public boolean addPushRefSpec(RefSpec s)
Add a new push RefSpec to this remote.- Parameters:
s
- the new specification to add.- Returns:
- true if the specification was added; false if it already exists.
-
removePushRefSpec
public boolean removePushRefSpec(RefSpec s)
Remove a push RefSpec from this remote.- Parameters:
s
- the specification to remove.- Returns:
- true if the specification existed and was removed.
-
getUploadPack
public java.lang.String getUploadPack()
Override for the location of 'git-upload-pack' on the remote system.This value is only useful for an SSH style connection, where Git is asking the remote system to execute a program that provides the necessary network protocol.
- Returns:
- location of 'git-upload-pack' on the remote system. If no location has been configured the default of 'git-upload-pack' is returned instead.
-
getReceivePack
public java.lang.String getReceivePack()
Override for the location of 'git-receive-pack' on the remote system.This value is only useful for an SSH style connection, where Git is asking the remote system to execute a program that provides the necessary network protocol.
- Returns:
- location of 'git-receive-pack' on the remote system. If no location has been configured the default of 'git-receive-pack' is returned instead.
-
getTagOpt
public TagOpt getTagOpt()
Get the description of how annotated tags should be treated during fetch.- Returns:
- option indicating the behavior of annotated tags in fetch.
-
setTagOpt
public void setTagOpt(TagOpt option)
Set the description of how annotated tags should be treated on fetch.- Parameters:
option
- method to use when handling annotated tags.
-
isMirror
public boolean isMirror()
Whether pushing to the remote automatically deletes remote refs which don't exist on the source side.- Returns:
- true if pushing to the remote automatically deletes remote refs which don't exist on the source side.
-
setMirror
public void setMirror(boolean m)
Set the mirror flag to automatically delete remote refs.- Parameters:
m
- true to automatically delete remote refs during push.
-
getTimeout
public int getTimeout()
Get timeout (in seconds) before aborting an IO operation.- Returns:
- timeout (in seconds) before aborting an IO operation.
-
setTimeout
public void setTimeout(int seconds)
Set the timeout before willing to abort an IO call.- Parameters:
seconds
- number of seconds to wait (with no data transfer occurring) before aborting an IO read or write operation with this remote. A timeout of 0 will block indefinitely.
-
-