public class RemoteConfig
extends java.lang.Object
implements java.io.Serializable
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.
Modifier and Type | Field and Description |
---|---|
private static boolean |
DEFAULT_MIRROR |
static java.lang.String |
DEFAULT_RECEIVE_PACK
Default value for
getReceivePack() if not specified. |
static java.lang.String |
DEFAULT_UPLOAD_PACK
Default value for
getUploadPack() 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 and Description |
---|
RemoteConfig(Config rc,
java.lang.String remoteName)
Parse a remote block from an existing configuration file.
|
Modifier and Type | Method and 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.
|
private static final long serialVersionUID
private static final java.lang.String SECTION
private static final java.lang.String KEY_URL
private static final java.lang.String KEY_PUSHURL
private static final java.lang.String KEY_FETCH
private static final java.lang.String KEY_PUSH
private static final java.lang.String KEY_UPLOADPACK
private static final java.lang.String KEY_RECEIVEPACK
private static final java.lang.String KEY_TAGOPT
private static final java.lang.String KEY_MIRROR
private static final java.lang.String KEY_TIMEOUT
private static final java.lang.String KEY_INSTEADOF
private static final java.lang.String KEY_PUSHINSTEADOF
private static final boolean DEFAULT_MIRROR
public static final java.lang.String DEFAULT_UPLOAD_PACK
getUploadPack()
if not specified.public static final java.lang.String DEFAULT_RECEIVE_PACK
getReceivePack()
if not specified.private java.lang.String name
private java.util.List<URIish> uris
private java.util.List<URIish> pushURIs
private java.util.List<RefSpec> fetch
private java.util.List<RefSpec> push
private java.lang.String uploadpack
private java.lang.String receivepack
private TagOpt tagopt
private boolean mirror
private int timeout
public RemoteConfig(Config rc, java.lang.String remoteName) throws java.net.URISyntaxException
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.
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.java.net.URISyntaxException
- one of the URIs within the remote's configuration is invalid.public static java.util.List<RemoteConfig> getAllRemoteConfigs(Config rc) throws java.net.URISyntaxException
rc
- the existing configuration to get the remote settings from.
The configuration must already be loaded into memory.java.net.URISyntaxException
- one of the URIs within the remote's configuration is invalid.public void update(Config rc)
rc
- the configuration file to store ourselves into.private void set(Config rc, java.lang.String key, java.lang.String currentValue, java.lang.String defaultValue)
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 unset(Config rc, java.lang.String key)
private java.util.Map<java.lang.String,java.lang.String> getReplacements(Config config, java.lang.String keyName)
private java.lang.String replaceUri(java.lang.String uri, java.util.Map<java.lang.String,java.lang.String> replacements)
public java.lang.String getName()
public java.util.List<URIish> getURIs()
public boolean addURI(URIish toAdd)
toAdd
- the new URI to add to this remote.public boolean removeURI(URIish toRemove)
toRemove
- the URI to remove from this remote.public java.util.List<URIish> getPushURIs()
public boolean addPushURI(URIish toAdd)
toAdd
- the new URI to add to this remote.public boolean removePushURI(URIish toRemove)
toRemove
- the URI to remove from this remote.public java.util.List<RefSpec> getFetchRefSpecs()
public boolean addFetchRefSpec(RefSpec s)
s
- the new specification to add.public void setFetchRefSpecs(java.util.List<RefSpec> specs)
specs
- list of fetch specifications to set. List is copied, it can be
modified after this call.public void setPushRefSpecs(java.util.List<RefSpec> specs)
specs
- list of push specifications to set. List is copied, it can be
modified after this call.public boolean removeFetchRefSpec(RefSpec s)
s
- the specification to remove.public java.util.List<RefSpec> getPushRefSpecs()
public boolean addPushRefSpec(RefSpec s)
s
- the new specification to add.public boolean removePushRefSpec(RefSpec s)
s
- the specification to remove.public java.lang.String getUploadPack()
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.
public java.lang.String getReceivePack()
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.
public TagOpt getTagOpt()
public void setTagOpt(TagOpt option)
option
- method to use when handling annotated tags.public boolean isMirror()
public void setMirror(boolean m)
m
- true to automatically delete remote refs during push.public int getTimeout()
public void setTimeout(int seconds)
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.