/// <summary>Read standard Git environment variables and configure from those.</summary> /// <remarks> /// Read standard Git environment variables and configure from those. /// <p> /// This method tries to read the standard Git environment variables, such as /// <code>GIT_DIR</code> /// and /// <code>GIT_WORK_TREE</code> /// to configure this builder /// instance. If a property is already set in the builder, the environment /// variable is not used. /// </remarks> /// <param name="sr">the SystemReader abstraction to access the environment.</param> /// <returns> /// /// <code>this</code> /// (for chaining calls). /// </returns> public virtual B ReadEnvironment(SystemReader sr) { if (GetGitDir() == null) { string val = sr.Getenv(Constants.GIT_DIR_KEY); if (val != null) { SetGitDir(new FilePath(val)); } } if (GetObjectDirectory() == null) { string val = sr.Getenv(Constants.GIT_OBJECT_DIRECTORY_KEY); if (val != null) { SetObjectDirectory(new FilePath(val)); } } if (GetAlternateObjectDirectories() == null) { string val = sr.Getenv(Constants.GIT_ALTERNATE_OBJECT_DIRECTORIES_KEY); if (val != null) { foreach (string path in val.RegexSplit(FilePath.pathSeparator)) { AddAlternateObjectDirectory(new FilePath(path)); } } } if (GetWorkTree() == null) { string val = sr.Getenv(Constants.GIT_WORK_TREE_KEY); if (val != null) { SetWorkTree(new FilePath(val)); } } if (GetIndexFile() == null) { string val = sr.Getenv(Constants.GIT_INDEX_FILE_KEY); if (val != null) { SetIndexFile(new FilePath(val)); } } if (ceilingDirectories == null) { string val = sr.Getenv(Constants.GIT_CEILING_DIRECTORIES_KEY); if (val != null) { foreach (string path in val.RegexSplit(FilePath.pathSeparator)) { AddCeilingDirectory(new FilePath(path)); } } } return(Self()); }