Class LfsConfig


  • public class LfsConfig
    extends java.lang.Object
    Encapsulate access to the .lfsconfig. According to the document https://github.com/git-lfs/git-lfs/blob/main/docs/man/git-lfs-config.5.ronn the order to find the .lfsconfig file is:
       1. in the root of the working tree
       2. in the index
       3. in the HEAD, for bare repositories this is the only place
          that is searched
     
    Values from the .lfsconfig are used only if not specified in another git config file to allow local override without modifiction of a committed file.
    • Constructor Summary

      Constructors 
      Constructor Description
      LfsConfig​(Repository db)
      Create a new instance of the LfsConfig.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private Config emptyConfig()
      Create an empty config as fallback to avoid null pointer checks.
      java.lang.String getString​(java.lang.String section, java.lang.String subsection, java.lang.String name)
      Get string value or null if not found.
      private Config load()
      Read the .lfsconfig file from the repository
      private Config loadFromHead()
      Try to read the lfs config from an entry called .lfsconfig contained in the head revision.
      private Config loadFromIndex()
      Try to read the lfs config from an entry called .lfsconfig contained in the index.
      private Config loadFromWorkingTree()
      Try to read the lfs config from a file called .lfsconfig at the top level of the working tree.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LfsConfig

        public LfsConfig​(Repository db)
                  throws java.io.IOException
        Create a new instance of the LfsConfig.
        Parameters:
        db - the associated repo
        Throws:
        java.io.IOException
    • Method Detail

      • load

        private Config load()
                     throws java.io.IOException
        Read the .lfsconfig file from the repository
        Returns:
        The loaded lfs config or null if it does not exist
        Throws:
        java.io.IOException
      • loadFromWorkingTree

        @Nullable
        private Config loadFromWorkingTree()
                                    throws java.io.IOException
        Try to read the lfs config from a file called .lfsconfig at the top level of the working tree.
        Returns:
        the config, or null
        Throws:
        java.io.IOException
      • loadFromIndex

        @Nullable
        private Config loadFromIndex()
                              throws java.io.IOException
        Try to read the lfs config from an entry called .lfsconfig contained in the index.
        Returns:
        the config, or null if the entry does not exist
        Throws:
        java.io.IOException
      • loadFromHead

        @Nullable
        private Config loadFromHead()
                             throws java.io.IOException
        Try to read the lfs config from an entry called .lfsconfig contained in the head revision.
        Returns:
        the config, or null if the file does not exist
        Throws:
        java.io.IOException
      • emptyConfig

        private Config emptyConfig()
        Create an empty config as fallback to avoid null pointer checks.
        Returns:
        an empty config
      • getString

        public java.lang.String getString​(java.lang.String section,
                                          java.lang.String subsection,
                                          java.lang.String name)
        Get string value or null if not found. First tries to find the value in the git config files. If not found tries to find data in .lfsconfig.
        Parameters:
        section - the section
        subsection - the subsection for the value
        name - the key name
        Returns:
        a String value from the config, null if not found