libgit2/libgit2 — pull request #812 by arrbee (2012-07-11 06:38:39+00:00)
Title: Assorted goodies

This is a collection of small additions that I've made while trying to build out more complete support for submodules. The submodules work has gone on for too long, so I thought I would extract these useful pieces and try to gather them together into a set of smaller easy-to-read commits.

These 5 commits contain 4 significant changes and 3 minor ones that may be worth discussing:

1. Added new external API `git_config_foreach_match` to iterate over config values that match a regular expression
2. Add an `update_gitlink` parameter to existing external API `git_repository_set_workdir` allowing it to permanently update the workdir of a repository (creating gitlink and setting config options), instead of just updating the workdir in memory. Note: this is a breaking change (extra parameter) to an existing public API, so it will have ramifications for bindings.
3. Add internal function `git_buf_puts_escaped` to copy a string into a buffer while escaping characters in a set of the caller's choice with the escape prefix of the caller's choice.
4. Add internal functions `git_path_resolve_relative` and `git_path_apply_relative` that eliminate ".." and "." patterns from path buffers (in place). These apply not just to file paths, but to URLs as well (which is helpful for setting up submodule remotes).

And:

1. Fixed apparent bug in `git_config_foreach` where error return code from callback function was not properly aborting iteration and was not propagated back to the caller.
2. Enabled drive-letter prefix detection on paths on all platforms, not just Windows. I did this to make test behavior consistent, but I recognize it may be a problem. If you had a path in a repo like `/home/rb/myrepo/x:/myfile.txt` where the relative path to the file from the repo root was `x:/myfile.txt`, then with my change, this would be detected as having a drive prefix. Of course, a directory named `:` in the root of a repo is kind of asking for trouble, but I'm sure someone does it, just because they can (but not on Windows).
3. Added 0x85 (Unicode CR+LF) to `git__isspace` for consistency with CRLF text stats in filter.c

I suspect/hope that the only controversial part of this will be the drive-letter prefix detection on all platforms. The only other aspect that could be undesirable is the extension of the `set_workdir` API with a new parameter / behavior - that could be done in a second, new function, I suppose, but I really felt like it made more sense to do the way I did it.