On Windows, Cwd::abs_path() returns a path that uses / as its directory separator. This means that after loading from a fully-qualified \-separated path, that same path does not appear in the origins hash. Canonicalize the path using File::Spec->canonpath(), which does not inspect the filesystem, but does normalize path separators.
The following test fails on mac os, where /var is a symlink to /private/var t/casing.t ............. 1/? # Failed test 'Found definition from second file' # at t/casing.t line 53. # got: '/private/var/folders/zz/zyxvpxvq6csfxvn_n00026dc000jlb/T/5fRT_POw_o/other' # expected: '/var/folders/zz/zyxvpxvq6csfxvn_n00026dc000jlb/T/5fRT_POw_o/other' # Looks like you failed 1 test of 19. t/casing.t ............. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/19 subtests The config filename is converted to an absolute path inside load_file, but the test checks the original path. This changes the test to use the same call to Cwd::abs_path.
Cwd::abs_path examines the filesystem to resolve /foo/../bar/ to /bar -- while taking into account symlinks and other complicating factors. Use it to store the simplest form of the filename loaded. As Cwd::abs_path returns undef if it cannot resolve the path, default back to the passed-in value, for error messages and the like.
original_case is and overly and unhelpfully-specific name for the method. Name and document it a bit more generally.
Git canonicalizes the section and key name into lower case for all lookups; subsection names are case-sensitive. However, there are times when is is useful to be able to determine the original case used to set the key. Store the original case, and provide a 'original_case' method to retrieve the kase used for a given key. This also alters the 'name' argument to the 'callback' of 'parse_content' to be the original case, and not the canonical lower case.
This avoids warnings (such as were generated by t/t1300-repo-config!) when ->set was called with an invalid key.
Previously, git correctly parsed configuration variables before the first section marker, although it coult not set or unset such keys. In git 220.127.116.11 and later, the code was modified to match the documentation, and this misfeature was removed. Alter the parsing code and methods to enforce this restriction in the module as well, for consistency with git.
To encode and decode config files. Necessary because, if no encoding is specified, and a UTF-8 string is saved to a config file, when it is read back in, it will not be properly read as UTF-8. The same would go for any coding other than Latin-1 (maybe).