~/.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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jgit.lib.Config
Config.ConfigEnum, Config.SectionParser<T> -
Constructor Summary
ConstructorsConstructorDescriptionUserConfigFile(Config parent, File config, File xdgConfig, FS fileSystem) Creates a newUserConfigFile. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the currently loaded configuration file is outdatedvoidload()Load the configuration from the persistent store.booleanremoveSection(String section, String subsection) Removes all configuration values under a single section.voidsave()Save the configuration to the persistent store.voidSet a configuration value.voidRemove a configuration value.voidunsetSection(String section, String subsection) Remove all configuration values under a single section.Methods inherited from class org.eclipse.jgit.storage.file.FileBasedConfig
clear, getFile, notifyUponTransientChanges, readIncludedConfig, toStringMethods inherited from class org.eclipse.jgit.lib.Config
addChangeListener, fireConfigChangedEvent, fromText, get, getBaseConfig, getBoolean, getBoolean, getEnum, getEnum, getInt, getInt, getIntInRange, getIntInRange, getLong, getLong, getNames, getNames, getNames, getNames, getPath, getRefSpecs, getSections, getString, getStringList, getSubsections, getTimeUnit, isMissing, isUtf8, setBoolean, setEnum, setInt, setLong, setString, setTypedConfigGetter, toText, uncache
-
Constructor Details
-
UserConfigFile
public UserConfigFile(Config parent, @NonNull File config, @NonNull File xdgConfig, @NonNull FS fileSystem) Creates a newUserConfigFile.- Parameters:
parent- parentConfig; may benullconfig-Filefor~/.gitconfigxdgConfig-Filefor$XDG_CONFIG_HOME/.gitconfigfileSystem-FSto use for the two files; normallyFS.DETECTED
-
-
Method Details
-
setStringList
Description copied from class:ConfigSet a configuration value.[section "subsection"] name = value1 name = value2- Overrides:
setStringListin classConfig- Parameters:
section- section name, e.g "branch"subsection- optional subsection value, e.g. a branch namename- parameter name, e.g. "filemode"values- list of zero or more values for this key.
-
unset
Description copied from class:ConfigRemove a configuration value. -
unsetSection
Description copied from class:ConfigRemove all configuration values under a single section.- Overrides:
unsetSectionin classConfig- Parameters:
section- section name, e.g "branch"subsection- optional subsection value, e.g. a branch name
-
removeSection
Description copied from class:ConfigRemoves all configuration values under a single section.- Overrides:
removeSectionin classConfig- Parameters:
section- section name, e.g "branch"subsection- optional subsection value, e.g. a branch name- Returns:
trueif a section was present and was removed;falseif the config was not changed (i.e., no such section was present)
-
isOutdated
public boolean isOutdated()Description copied from class:FileBasedConfigWhether the currently loaded configuration file is outdated- Overrides:
isOutdatedin classFileBasedConfig- Returns:
- returns true if the currently loaded configuration file is older than the file on disk
-
load
Description copied from class:FileBasedConfigLoad 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.
- Overrides:
loadin classFileBasedConfig- Throws:
IOException- the configuration could not be read (but does exist).ConfigInvalidException- the configuration is not properly formatted.
-
save
Description copied from class:FileBasedConfigSave 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.
- Overrides:
savein classFileBasedConfig- Throws:
IOException- the configuration could not be written.
-