Artifact 3858ed8a65ef9dbe9e3bcc91f4b360d94d7671998b888d44ba7da9b4fc0e1368:
- File
internal/repo/setting.go
— part of check-in
[430dd5ec70]
at
2026-10-20 01:49:55
on branch fix/cli-path-matching
— fix(cli): match PATH as fossil does; run pragmas in a fixed order
log --path, cat --at and diff drop a leading ./, a trailing / and doubled or /./ separators, and compare names with the repository's case-sensitive setting, fossil's platform default when unset. Not found stays exit 2, where fossil exits 1; the docs now say so. SettingBoolean moves to internal/repo, shared by sync and checkout.
Opening a repository runs every pragma in a fixed order, not only busy_timeout first.
Tracked in #451 (user: [email protected], size: 1711) [annotate] [blame] [check-ins using] [more...]
package repo import ( "runtime" "strings" ) // SettingBoolean is fossil's db_get_boolean on a stored value: is_truth // ("on", "yes", "true" in any case, or a nonzero atoi) gives true, is_false // ("off", "no", "false", "0" in any case) gives false, and anything else // gives dflt. func SettingBoolean(value string, dflt bool) bool { switch strings.ToLower(value) { case "on", "yes", "true": return true case "off", "no", "false", "0": return false } if cAtoi(value) != 0 { return true } return dflt } // cAtoi is C's atoi as fossil's is_truth uses it: leading white space, an // optional sign, then decimal digits up to the first other byte; no digits // give 0. Overflow is not modelled, since only zero versus nonzero matters. func cAtoi(s string) int64 { i := 0 for i < len(s) && strings.IndexByte(" \t\n\v\f\r", s[i]) >= 0 { i++ } negative := false if i < len(s) && (s[i] == '+' || s[i] == '-') { negative = s[i] == '-' i++ } var n int64 for ; i < len(s) && s[i] >= '0' && s[i] <= '9'; i++ { if n < 1<<40 { n = n*10 + int64(s[i]-'0') } } if negative { return -n } return n } // FilenamesCaseSensitive reports whether file names that differ only in case // are distinct, as fossil's filenames_are_case_sensitive does: the // repository's case-sensitive setting, else fossil's platform default, which // is off on macOS and Windows and on elsewhere. Fossil falls back to a global // setting in ~/.fossil that go-libfossil does not read. func (r *Repo) FilenamesCaseSensitive() bool { dflt := runtime.GOOS != "darwin" && runtime.GOOS != "windows" value, err := r.Config("case-sensitive") if err != nil { return dflt } return SettingBoolean(value, dflt) }