Class ClientVersionUtil


  • public class ClientVersionUtil
    extends Object
    Parses Git client User-Agent strings.
    • 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​(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.
      • 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 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.