У меня была идея, подобная Mladen, но противоположному...
String s = "a.b.c.d";
int charCount = s.replaceAll("[^.]", "").length();
println(charCount);
В дополнение к «y» и «n», один из ответов, которые вы можете дать, когда вас спросят о ломе, - это «s», что означает «разделить этот кусок на более мелкие части». Полный список:
y - stage this hunk
n - do not stage this hunk
q - quit, do not stage this hunk nor any of the remaining ones
a - stage this and all the remaining hunks in the file
d - do not stage this hunk nor any of the remaining hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help
git gui
позволит вам фиксировать отдельные строки, даже если они окружены другими измененными строками, которые вы не хотите фиксировать.