@Nullable private static Pair<String,String> parsePackedRefsLine(@NotNull String line){
  line=line.trim();
  if (line.isEmpty()) {
    return null;
  }
  char firstChar=line.charAt(0);
  if (firstChar == '#') {
    return null;
  }
  if (firstChar == '^') {
    return null;
  }
  String hash=null;
  int i;
  for (i=0; i < line.length(); i++) {
    char c=line.charAt(i);
    if (!Character.isLetterOrDigit(c)) {
      hash=line.substring(0,i);
      break;
    }
  }
  if (hash == null) {
    LOG.warn("Ignoring invalid packed-refs line: [" + line + "]");
    return null;
  }
  String branch=null;
  int start=i;
  if (start < line.length() && line.charAt(start++) == ' ') {
    for (i=start; i < line.length(); i++) {
      char c=line.charAt(i);
      if (Character.isWhitespace(c)) {
        break;
      }
    }
    branch=line.substring(start,i);
  }
  if (branch == null || !branch.startsWith(REFS_HEADS_PREFIX) && !branch.startsWith(REFS_REMOTES_PREFIX)) {
    return null;
  }
  return Pair.create(shortBuffer(branch),shortBuffer(hash.trim()));
}

@ Nullable private static Pair < String , String > parsePackedRefsLine ( @ NotNull String line ) { line = line . trim ( ) ; if ( line . isEmpty ( ) ) { return null ; } char firstChar = line . charAt ( 0 ) ; if ( firstChar == '#' ) { return null ; } if ( firstChar == '^' ) { return null ; } String hash = null ; int i ; for ( i = 0 ; i < line . length ( ) ; i ++ ) { char c = line . charAt ( i ) ; if ( ! Character . isLetterOrDigit ( c ) ) { hash = line . substring ( 0 , i ) ; break ; } } if ( hash == null ) { LOG . warn ( "Ignoring invalid packed-refs line: [" + line + "]" ) ; return null ; } String branch = null ; int start = i ; if ( start < line . length ( ) && line . charAt ( start ++ ) == ' ' ) { for ( i = start ; i < line . length ( ) ; i ++ ) { char c = line . charAt ( i ) ; if ( Character . isWhitespace ( c ) ) { break ; } } branch = line . substring ( start , i ) ; } if ( branch == null || ! branch . startsWith ( REFS_HEADS_PREFIX ) && ! branch . startsWith ( REFS_REMOTES_PREFIX ) ) { return null ; } return Pair . create ( shortBuffer ( branch ) , shortBuffer ( hash . trim ( ) ) ) ; }
parses a line from the . git / packed - refs file returning a pair of hash and ref name . comments and tags are ignored , and null is returned . incorrectly formatted lines are ignored , a warning is printed to the log , null is returned . a line indicating a hash which an annotated tag ( specified in the previous line ) points to , is ignored : null is returned .
