Class ClientVersionUtil


  • public class ClientVersionUtil
    extends java.lang.Object
    Parses Git client User-Agent strings.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ClientVersionUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static int compare​(int[] a, int[] b)
      Compare two version strings for natural ordering.
      private static int[] grow​(int[] tmp)  
      static boolean hasChunkedEncodingRequestBug​(int[] version, javax.servlet.http.HttpServletRequest request)
      Deprecated.
      no widely used Git versions need this any more
      static boolean hasPushStatusBug​(int[] version)
      Deprecated.
      no widely used Git versions need this any more
      static int[] invalidVersion()
      An invalid version of Git
      static int[] parseVersion​(java.lang.String version)
      Parse a Git client User-Agent header value.
      private static int[] splitVersion​(java.lang.String versionString)  
      static java.lang.String toString​(int[] ver)
      Convert a parsed version back to a string.
      • Methods inherited from class java.lang.Object

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

      • ClientVersionUtil

        private ClientVersionUtil()
    • Method Detail

      • invalidVersion

        public static int[] invalidVersion()
        An invalid version of Git
        Returns:
        maximum version array, indicating an invalid version of Git.
      • parseVersion

        public static int[] parseVersion​(java.lang.String version)
        Parse a Git client User-Agent header value.
        Parameters:
        version - git client version string, of the form "git/1.7.9".
        Returns:
        components of the version string. invalidVersion() if the version string cannot be parsed.
      • splitVersion

        private static int[] splitVersion​(java.lang.String versionString)
      • grow

        private static int[] grow​(int[] tmp)
      • compare

        public static int compare​(int[] a,
                                  int[] b)
        Compare two version strings for natural ordering.
        Parameters:
        a - first parsed version string.
        b - second parsed version string.
        Returns:
        < 0 if a is before b; 0 if a equals b; >0 if a is after b.
      • toString

        public static java.lang.String toString​(int[] ver)
        Convert a parsed version back to a string.
        Parameters:
        ver - the parsed version array.
        Returns:
        a string, e.g. "1.6.6.0".
      • hasPushStatusBug

        @Deprecated
        public static boolean hasPushStatusBug​(int[] version)
        Deprecated.
        no widely used Git versions need this any more
        Check if a Git client has the known push status bug.

        These buggy clients do not display the status report from a failed push over HTTP.

        Parameters:
        version - parsed version of the Git client software.
        Returns:
        true if the bug is present.
      • hasChunkedEncodingRequestBug

        @Deprecated
        public static boolean hasChunkedEncodingRequestBug​(int[] version,
                                                           javax.servlet.http.HttpServletRequest request)
        Deprecated.
        no widely used Git versions need this any more
        Check if a Git client has the known chunked request body encoding bug.

        Git 1.7.5 contains a unique bug where chunked requests are malformed. This applies to both fetch and push.

        Parameters:
        version - parsed version of the Git client software.
        request - incoming HTTP request.
        Returns:
        true if the client has the chunked encoding bug.