Class RemoteConfig
- All Implemented Interfaces:
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean
static final String
Default value forgetReceivePack()
if not specified.static final String
Default value forgetUploadPack()
if not specified.private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private boolean
private String
private String
private static final String
private static final long
private TagOpt
private int
private String
-
Constructor Summary
ConstructorsConstructorDescriptionRemoteConfig
(Config rc, String remoteName) Parse a remote block from an existing configuration file. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add a new fetch RefSpec to this remote.boolean
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
Add a new URI to the end of the list of URIs.static List
<RemoteConfig> Parse all remote blocks in an existing configuration file, looking for remotes configuration.Remembered specifications for fetching from a repository.getName()
Get the local name this remote configuration is recognized as.Remembered specifications for pushing to a repository.Get all configured push-only URIs under this remote.Override for the location of 'git-receive-pack' on the remote system.getReplacements
(Config config, String keyName) Get the description of how annotated tags should be treated during fetch.int
Get timeout (in seconds) before aborting an IO operation.Override for the location of 'git-upload-pack' on the remote system.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
Remove a fetch RefSpec from this remote.boolean
Remove a push RefSpec from this remote.boolean
removePushURI
(URIish toRemove) Remove a push-only URI from the list of URIs.boolean
Remove a URI from the list of URIs.private String
replaceUri
(String uri, Map<String, String> replacements) private void
private void
private void
void
setFetchRefSpecs
(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
(List<RefSpec> specs) Override existing push specifications with new ones.void
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
void
Update this remote's definition within the configuration.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
SECTION
- See Also:
-
KEY_URL
- See Also:
-
KEY_PUSHURL
- See Also:
-
KEY_FETCH
- See Also:
-
KEY_PUSH
- See Also:
-
KEY_UPLOADPACK
- See Also:
-
KEY_RECEIVEPACK
- See Also:
-
KEY_TAGOPT
- See Also:
-
KEY_MIRROR
- See Also:
-
KEY_TIMEOUT
- See Also:
-
KEY_INSTEADOF
- See Also:
-
KEY_PUSHINSTEADOF
- See Also:
-
DEFAULT_MIRROR
private static final boolean DEFAULT_MIRROR- See Also:
-
DEFAULT_UPLOAD_PACK
Default value forgetUploadPack()
if not specified.- See Also:
-
DEFAULT_RECEIVE_PACK
Default value forgetReceivePack()
if not specified.- See Also:
-
name
-
uris
-
pushURIs
-
fetch
-
push
-
uploadpack
-
receivepack
-
tagopt
-
mirror
private boolean mirror -
timeout
private int timeout
-
-
Constructor Details
-
RemoteConfig
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:
URISyntaxException
- one of the URIs within the remote's configuration is invalid.
-
-
Method Details
-
getAllRemoteConfigs
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:
URISyntaxException
- one of the URIs within the remote's configuration is invalid.
-
update
Update this remote's definition within the configuration.- Parameters:
rc
- the configuration file to store ourselves into.
-
set
-
set
-
set
-
unset
-
getReplacements
-
replaceUri
-
getName
Get the local name this remote configuration is recognized as.- Returns:
- name assigned by the user to this configuration block.
-
getURIs
Get all configured URIs under this remote.- Returns:
- the set of URIs known to this remote.
-
addURI
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
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
Get all configured push-only URIs under this remote.- Returns:
- the set of URIs known to this remote.
-
addPushURI
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
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
Remembered specifications for fetching from a repository.- Returns:
- set of specs used by default when fetching.
-
addFetchRefSpec
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
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
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
Remove a fetch RefSpec from this remote.- Parameters:
s
- the specification to remove.- Returns:
- true if the specification existed and was removed.
-
getPushRefSpecs
Remembered specifications for pushing to a repository.- Returns:
- set of specs used by default when pushing.
-
addPushRefSpec
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
Remove a push RefSpec from this remote.- Parameters:
s
- the specification to remove.- Returns:
- true if the specification existed and was removed.
-
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
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
Get the description of how annotated tags should be treated during fetch.- Returns:
- option indicating the behavior of annotated tags in fetch.
-
setTagOpt
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.
-