diff options
| author | Russell Belfer <rb@github.com> | 2013-01-09 16:07:54 -0800 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-01-15 09:51:35 -0800 |
| commit | 25423d03b826f9647e72a56b14e08967d92ae479 (patch) | |
| tree | 49b53c1c5ca7ac1f262eb3e1b5a6b3ceaf0b1692 /src/status.c | |
| parent | 98527b5b241ce9d240537f60e87aa9dd084c0f36 (diff) | |
| download | libgit2-25423d03b826f9647e72a56b14e08967d92ae479.tar.gz | |
Support case insensitive tree iterators and status
This makes tree iterators directly support case insensitivity by
using a secondary index that can be sorted by icase. Also, this
fixes the ambiguity check in the git_status_file API to also be
case insensitive. Lastly, this adds new test cases for case
insensitive range boundary checking for all types of iterators.
With this change, it should be possible to deprecate the spool
and sort iterator, but I haven't done that yet.
Diffstat (limited to 'src/status.c')
| -rw-r--r-- | src/status.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/status.c b/src/status.c index 5b89e8c0d..282cb396b 100644 --- a/src/status.c +++ b/src/status.c @@ -196,19 +196,23 @@ struct status_file_info { char *expected; unsigned int count; unsigned int status; + int fnm_flags; int ambiguous; }; static int get_one_status(const char *path, unsigned int status, void *data) { struct status_file_info *sfi = data; + int (*strcomp)(const char *a, const char *b); sfi->count++; sfi->status = status; + strcomp = (sfi->fnm_flags & FNM_CASEFOLD) ? git__strcasecmp : git__strcmp; + if (sfi->count > 1 || - (strcmp(sfi->expected, path) != 0 && - p_fnmatch(sfi->expected, path, 0) != 0)) + (strcomp(sfi->expected, path) != 0 && + p_fnmatch(sfi->expected, path, sfi->fnm_flags) != 0)) { sfi->ambiguous = true; return GIT_EAMBIGUOUS; @@ -225,11 +229,17 @@ int git_status_file( int error; git_status_options opts = GIT_STATUS_OPTIONS_INIT; struct status_file_info sfi = {0}; + git_index *index; assert(status_flags && repo && path); + if ((error = git_repository_index__weakptr(&index, repo)) < 0) + return error; + if ((sfi.expected = git__strdup(path)) == NULL) return -1; + if (index->ignore_case) + sfi.fnm_flags = FNM_CASEFOLD; opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR; opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED | |
