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

public Class UserConfigFile

extends FileBasedConfig
Class Inheritance
Imports
java.io.File, .IOException, java.util.List, org.eclipse.jgit.annotations.NonNull, org.eclipse.jgit.errors.ConfigInvalidException, org.eclipse.jgit.lib.Config, org.eclipse.jgit.util.FS

User (global) git config based on two possible locations, ~/.gitconfig and $XDG_CONFIG_HOME/git/config.

For reading, both locations are considered, first the XDG file, then the file in the home directory. All updates occur in the last file read that exists, or in the home directory file if neither exists. In other words: if only the XDG file exists, it is updated, otherwise the home directory file is updated.

Since
6.7

Field Summary

Modifier and TypeField and Description
private final FileBasedConfig

Constructor Summary

AccessConstructor and Description
public
UserConfigFile(Config
parent Config; may be null
parent
,
File
File for ~/.gitconfig
config
,
File
File for $XDG_CONFIG_HOME/.gitconfig
xdgConfig
,
FS
FS to use for the two files; normally FS#DETECTED
fileSystem
)

Creates a new UserConfigFile.

Method Summary

Modifier and TypeMethod and Description
public boolean
isOutdated()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.isOutdated.

Whether the currently loaded configuration file is outdated

public void
load()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.load.

Load the configuration from the persistent store.

public boolean
removeSection(String
section name, e.g "branch"
section
,
String
optional subsection value, e.g. a branch name
subsection
)

Overrides org.eclipse.jgit.lib.Config.removeSection.

Removes all configuration values under a single section.

public void
save()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.save.

Save the configuration to the persistent store.

public void
setStringList(String
section name, e.g "branch"
section
,
String
optional subsection value, e.g. a branch name
subsection
,
String
parameter name, e.g. "filemode"
name
,
List<String>
list of zero or more values for this key.
values
)

Overrides org.eclipse.jgit.lib.Config.setStringList.

Set a configuration value.

public void
unset(String
section name, e.g "branch"
section
,
String
optional subsection value, e.g. a branch name
subsection
,
String
parameter name, e.g. "filemode"
name
)

Overrides org.eclipse.jgit.lib.Config.unset.

Remove a configuration value.

public void
unsetSection(String
section name, e.g "branch"
section
,
String
optional subsection value, e.g. a branch name
subsection
)

Overrides org.eclipse.jgit.lib.Config.unsetSection.

Remove all configuration values under a single section.

Inherited from org.eclipse.jgit.storage.file.FileBasedConfig:
clearexistsgetFilenotifyUponTransientChangesreadIncludedConfigtoString

Field Detail

parentback to summary
private final FileBasedConfig parent

Constructor Detail

UserConfigFileback to summary
public UserConfigFile(Config parent, File config, File xdgConfig, FS fileSystem)

Creates a new UserConfigFile.

Parameters
parent:Config

parent Config; may be null

config:File

File for ~/.gitconfig

xdgConfig:File

File for $XDG_CONFIG_HOME/.gitconfig

fileSystem:FS

FS to use for the two files; normally FS#DETECTED

Method Detail

isOutdatedback to summary
public boolean isOutdated()

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.isOutdated.

Doc from org.eclipse.jgit.storage.file.FileBasedConfig.isOutdated.

Whether the currently loaded configuration file is outdated

Returns:boolean

returns true if the currently loaded configuration file is older than the file on disk

Annotations
@Override
loadback to summary
public void load() throws IOException, ConfigInvalidException

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.load.

Doc from org.eclipse.jgit.storage.file.FileBasedConfig.load.

Load the configuration from the persistent store.

If the configuration does not exist, this configuration is cleared, and thus behaves the same as though the backing store exists, but is empty.

Load the configuration as a Git text style configuration file.

If the file does not exist, this configuration is cleared, and thus behaves the same as though the file exists, but is empty.

Annotations
@Override
Exceptions
IOException:

Doc from org.eclipse.jgit.lib.StoredConfig.load.

the configuration could not be read (but does exist).

ConfigInvalidException:

Doc from org.eclipse.jgit.lib.StoredConfig.load.

the configuration is not properly formatted.

removeSectionback to summary
public boolean removeSection(String section, String subsection)

Overrides org.eclipse.jgit.lib.Config.removeSection.

Doc from org.eclipse.jgit.lib.Config.removeSection.

Removes all configuration values under a single section.

Parameters
section:String

section name, e.g "branch"

subsection:String

optional subsection value, e.g. a branch name

Returns:boolean

true if a section was present and was removed; false if the config was not changed (i.e., no such section was present)

Annotations
@Override
saveback to summary
public void save() throws IOException

Overrides org.eclipse.jgit.storage.file.FileBasedConfig.save.

Doc from org.eclipse.jgit.storage.file.FileBasedConfig.save.

Save the configuration to the persistent store.

Save the configuration as a Git text style configuration file.

Warning

Although this method uses the traditional Git file locking approach to protect against concurrent writes of the configuration file, it does not ensure that the file has not been modified since the last read, which means updates performed by other objects accessing the same backing file may be lost.

Annotations
@Override
Exceptions
IOException:

Doc from org.eclipse.jgit.lib.StoredConfig.save.

the configuration could not be written.

setStringListback to summary
public void setStringList(String section, String subsection, String name, List<String> values)

Overrides org.eclipse.jgit.lib.Config.setStringList.

Doc from org.eclipse.jgit.lib.Config.setStringList.

Set a configuration value.

[section "subsection"]
        name = value1
        name = value2
Parameters
section:String

section name, e.g "branch"

subsection:String

optional subsection value, e.g. a branch name

name:String

parameter name, e.g. "filemode"

values:List<String>

list of zero or more values for this key.

Annotations
@Override
unsetback to summary
public void unset(String section, String subsection, String name)

Overrides org.eclipse.jgit.lib.Config.unset.

Doc from org.eclipse.jgit.lib.Config.unset.

Remove a configuration value.

Parameters
section:String

section name, e.g "branch"

subsection:String

optional subsection value, e.g. a branch name

name:String

parameter name, e.g. "filemode"

Annotations
@Override
unsetSectionback to summary
public void unsetSection(String section, String subsection)

Overrides org.eclipse.jgit.lib.Config.unsetSection.

Doc from org.eclipse.jgit.lib.Config.unsetSection.

Remove all configuration values under a single section.

Parameters
section:String

section name, e.g "branch"

subsection:String

optional subsection value, e.g. a branch name

Annotations
@Override