List<String> (final @Nullable String decoration) { if (decoration == null) { return ContainerUtil.emptyList(); } final int startParentheses = decoration.indexOf("("); final int endParentheses = decoration.lastIndexOf(")"); if ((startParentheses == -1) || (endParentheses == -1)) return Collections.emptyList(); String refs = decoration.substring(startParentheses + 1, endParentheses); String[] names = refs.split(", "); List<String> result = new ArrayList<>(); for (String item : names) { final String POINTER = " -> "; // HEAD -> refs/heads/master in Git 2.4.3+ if (item.contains(POINTER)) { List<String> parts = StringUtil.split(item, POINTER); result.addAll(ContainerUtil.map(parts, String::trim)); } else { int colon = item.indexOf(':'); // tags have the "tag:" prefix. String raw = colon > 0 ? item.substring(colon + 1).trim() : item; result.add(raw); } } return result; }