diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-01-30 16:03:10 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-30 16:03:10 -0800 |
commit | 00d3278c8534a8244ae3447189401111e017fd5d (patch) | |
tree | f1c19903bc10ffe4816642040080fb6cfd5da376 /path-list.c | |
parent | b9b727ddb3c9e005bc4e9af0b990b6ef06d7f621 (diff) | |
parent | b319ef70a94731a5c6f18d07a49d5dda3f06f5d3 (diff) | |
download | git-00d3278c8534a8244ae3447189401111e017fd5d.tar.gz git-00d3278c8534a8244ae3447189401111e017fd5d.tar.xz |
Merge commit 'b319ef7' into jc/maint-fix-test-perm
* commit 'b319ef7': (8132 commits)
Add a small patch-mode testing library
git-apply--interactive: Refactor patch mode code
t8005: Nobody writes Russian in shift_jis
Fix severe breakage in "git-apply --whitespace=fix"
Update release notes for 1.6.4
After renaming a section, print any trailing variable definitions
Make section_name_match start on '[', and return the length on success
send-email: detect cycles in alias expansion
Show the presence of untracked files in the bash prompt.
SunOS grep does not understand -C<n> nor -e
Fix export_marks() error handling.
git repack: keep commits hidden by a graft
Add a test showing that 'git repack' throws away grafted-away parents
git branch: clean up detached branch handling
git branch: avoid unnecessary object lookups
git branch: fix performance problem
git svn: fix shallow clone when upstream revision is too new
do_one_ref(): null_sha1 check is not about broken ref
configure.ac: properly unset NEEDS_SSL_WITH_CRYPTO when sha1 func is missing
janitor: useless checks before free
...
Diffstat (limited to 'path-list.c')
-rw-r--r-- | path-list.c | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/path-list.c b/path-list.c deleted file mode 100644 index caaa5cc57..000000000 --- a/path-list.c +++ /dev/null @@ -1,103 +0,0 @@ -#include "cache.h" -#include "path-list.h" - -/* if there is no exact match, point to the index where the entry could be - * inserted */ -static int get_entry_index(const struct path_list *list, const char *path, - int *exact_match) -{ - int left = -1, right = list->nr; - - while (left + 1 < right) { - int middle = (left + right) / 2; - int compare = strcmp(path, list->items[middle].path); - if (compare < 0) - right = middle; - else if (compare > 0) - left = middle; - else { - *exact_match = 1; - return middle; - } - } - - *exact_match = 0; - return right; -} - -/* returns -1-index if already exists */ -static int add_entry(struct path_list *list, const char *path) -{ - int exact_match; - int index = get_entry_index(list, path, &exact_match); - - if (exact_match) - return -1 - index; - - if (list->nr + 1 >= list->alloc) { - list->alloc += 32; - list->items = xrealloc(list->items, list->alloc - * sizeof(struct path_list_item)); - } - if (index < list->nr) - memmove(list->items + index + 1, list->items + index, - (list->nr - index) - * sizeof(struct path_list_item)); - list->items[index].path = list->strdup_paths ? - xstrdup(path) : (char *)path; - list->items[index].util = NULL; - list->nr++; - - return index; -} - -struct path_list_item *path_list_insert(const char *path, struct path_list *list) -{ - int index = add_entry(list, path); - - if (index < 0) - index = -1 - index; - - return list->items + index; -} - -int path_list_has_path(const struct path_list *list, const char *path) -{ - int exact_match; - get_entry_index(list, path, &exact_match); - return exact_match; -} - -struct path_list_item *path_list_lookup(const char *path, struct path_list *list) -{ - int exact_match, i = get_entry_index(list, path, &exact_match); - if (!exact_match) - return NULL; - return list->items + i; -} - -void path_list_clear(struct path_list *list, int free_items) -{ - if (list->items) { - int i; - if (free_items) - for (i = 0; i < list->nr; i++) { - if (list->strdup_paths) - free(list->items[i].path); - free(list->items[i].util); - } - free(list->items); - } - list->items = NULL; - list->nr = list->alloc = 0; -} - -void print_path_list(const char *text, const struct path_list *p) -{ - int i; - if ( text ) - printf("%s\n", text); - for (i = 0; i < p->nr; i++) - printf("%s:%p\n", p->items[i].path, p->items[i].util); -} - |