Program: 91232
Project: 91232
Buggy source:
/** 
 * Normalizes the passed branch name into a possible valid branch name. The validity of the returned name should be checked by a subsequent call to  {@link #isValidRefName(String)}. <p/> Future implementations of this method could be more restrictive or more lenient about the validity of specific characters in the returned name. <p/> The current implementation returns the trimmed input string if this is already a valid branch name. Otherwise it returns a trimmed string with special characters not allowed by   {@link #isValidRefName(String)}replaced by hyphens ('-') and blanks replaced by underscores ('_'). Leading and trailing slashes, dots, hyphens, and underscores are removed.
 * @param name to normalize
 * @return The normalized name or an empty String if it is {@code null} orempty.
 * @since 4.7
 * @see #isValidRefName(String)
 */
public static String normalizeBranchName(String name){
  if (name == null || name.isEmpty()) {
    return "String_Node_Str";
  }
  String result=name.trim();
  String fullName=result.startsWith(Constants.R_HEADS) ? result : Constants.R_HEADS + result;
  if (isValidRefName(fullName)) {
    return result;
  }
  result=result.replaceAll("String_Node_Str","String_Node_Str");
  StringBuilder b=new StringBuilder();
  char p='/';
  for (int i=0, len=result.length(); i < len; i++) {
    char c=result.charAt(i);
    if (c < ' ' || c == 127) {
      continue;
    }
switch (c) {
case '\\':
case '^':
case '~':
case ':':
case '?':
case '*':
case '[':
case '@':
case '<':
case '>':
case '|':
case '"':
      c='-';
    break;
default :
  break;
}
switch (c) {
case '/':
if (p == '/') {
  continue;
}
p='/';
break;
case '.':
case '_':
case '-':
if (p == '/' || p == '-') {
continue;
}
p='-';
break;
default :
p=c;
break;
}
b.append(c);
}
result=b.toString().replaceFirst("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
return FORBIDDEN_BRANCH_NAME_COMPONENTS.matcher(result).replaceAll("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Normalizes the passed branch name into a possible valid branch name. The validity of the returned name should be checked by a subsequent call to  {@link #isValidRefName(String)}. <p> Future implementations of this method could be more restrictive or more lenient about the validity of specific characters in the returned name. <p> The current implementation returns the trimmed input string if this is already a valid branch name. Otherwise it returns a trimmed string with special characters not allowed by   {@link #isValidRefName(String)}replaced by hyphens ('-') and blanks replaced by underscores ('_'). Leading and trailing slashes, dots, hyphens, and underscores are removed.
 * @param name to normalize
 * @return The normalized name or an empty String if it is {@code null} orempty.
 * @since 4.7
 * @see #isValidRefName(String)
 */
public static String normalizeBranchName(String name){
  if (name == null || name.isEmpty()) {
    return "String_Node_Str";
  }
  String result=name.trim();
  String fullName=result.startsWith(Constants.R_HEADS) ? result : Constants.R_HEADS + result;
  if (isValidRefName(fullName)) {
    return result;
  }
  result=result.replaceAll("String_Node_Str","String_Node_Str");
  StringBuilder b=new StringBuilder();
  char p='/';
  for (int i=0, len=result.length(); i < len; i++) {
    char c=result.charAt(i);
    if (c < ' ' || c == 127) {
      continue;
    }
switch (c) {
case '\\':
case '^':
case '~':
case ':':
case '?':
case '*':
case '[':
case '@':
case '<':
case '>':
case '|':
case '"':
      c='-';
    break;
default :
  break;
}
switch (c) {
case '/':
if (p == '/') {
  continue;
}
p='/';
break;
case '.':
case '_':
case '-':
if (p == '/' || p == '-') {
continue;
}
p='-';
break;
default :
p=c;
break;
}
b.append(c);
}
result=b.toString().replaceFirst("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
return FORBIDDEN_BRANCH_NAME_COMPONENTS.matcher(result).replaceAll("String_Node_Str");
}