fork of go-git with some jj specific features
at v5.2.0 487 B view raw
1package git 2 3import "strings" 4 5const defaultDotGitPath = ".git" 6 7// countLines returns the number of lines in a string à la git, this is 8// The newline character is assumed to be '\n'. The empty string 9// contains 0 lines. If the last line of the string doesn't end with a 10// newline, it will still be considered a line. 11func countLines(s string) int { 12 if s == "" { 13 return 0 14 } 15 16 nEOL := strings.Count(s, "\n") 17 if strings.HasSuffix(s, "\n") { 18 return nEOL 19 } 20 21 return nEOL + 1 22}