diff options
author | Russell Belfer <arrbee@arrbee.com> | 2012-01-09 15:37:19 -0800 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2012-01-11 14:39:51 -0800 |
commit | df743c7d3a04553ffc04ae7cbc64fb300e7f61d2 (patch) | |
tree | 7f0dfa714ddb292448cbeaa69f2b5d90a3274d85 /tests-clay | |
parent | 7e443f696068cd8c84a759e532c2845348e5a6ad (diff) | |
download | libgit2-df743c7d3a04553ffc04ae7cbc64fb300e7f61d2.tar.gz |
Initial implementation of gitignore support
Adds support for .gitignore files to git_status_foreach() and
git_status_file(). This includes refactoring the gitattributes
code to share logic where possible. The GIT_STATUS_IGNORED flag
will now be passed in for files that are ignored (provided they
are not already in the index or the head of repo).
Diffstat (limited to 'tests-clay')
-rw-r--r-- | tests-clay/core/path.c | 36 | ||||
-rw-r--r-- | tests-clay/status/status_data.h | 4 | ||||
-rw-r--r-- | tests-clay/status/worktree.c | 13 |
3 files changed, 52 insertions, 1 deletions
diff --git a/tests-clay/core/path.c b/tests-clay/core/path.c index bdebfb9c5..712ceb4e0 100644 --- a/tests-clay/core/path.c +++ b/tests-clay/core/path.c @@ -336,3 +336,39 @@ void test_core_path__10_fromurl(void) check_fromurl(ABS_PATH_MARKER "c:/Temp+folder/note.txt", "file:///c:/Temp+folder/note.txt", 0); check_fromurl(ABS_PATH_MARKER "a", "file:///a", 0); } + +void test_core_path__11_walkup(void) +{ + git_buf p = GIT_BUF_INIT, iter; + char *expect[] = { + "/a/b/c/d/e/", "/a/b/c/d/", "/a/b/c/", "/a/b/", "/a/", "/", NULL, + "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", "/a/", "/", NULL, + "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", "/a/", "/", NULL, + "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", "/a/", "/", NULL, + "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", NULL, + "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", NULL, + "this is a path", NULL, + "///a///b///c///d///e///", "///a///b///c///d///", "///a///b///c///", "///a///b///", "///a///", "///", NULL, + NULL + }; + char *root[] = { NULL, NULL, "/", "", "/a/b", "/a/b/", NULL, NULL, NULL }; + int i, j; + + for (i = 0, j = 0; expect[i] != NULL; i++, j++) { + int cb_count = 0; + + git_buf_sets(&p, expect[i]); + + git_path_walk_up(&p, &iter, root[j], { + cl_assert(expect[i + cb_count] != NULL); + cl_assert_strequal(expect[i + cb_count], iter.ptr); + cb_count++; }); + + cl_assert_strequal(p.ptr, expect[i]); + + /* skip to next run of expectations */ + while (expect[i] != NULL) i++; + } + + git_buf_free(&p); +} diff --git a/tests-clay/status/status_data.h b/tests-clay/status/status_data.h index ea903c602..1a68648f4 100644 --- a/tests-clay/status/status_data.h +++ b/tests-clay/status/status_data.h @@ -10,6 +10,7 @@ struct status_entry_counts { static const char *entry_paths0[] = { "file_deleted", + "ignored_file", "modified_file", "new_file", "staged_changes", @@ -28,6 +29,7 @@ static const char *entry_paths0[] = { static const unsigned int entry_statuses0[] = { GIT_STATUS_WT_DELETED, + GIT_STATUS_IGNORED, GIT_STATUS_WT_MODIFIED, GIT_STATUS_WT_NEW, GIT_STATUS_INDEX_MODIFIED, @@ -44,5 +46,5 @@ static const unsigned int entry_statuses0[] = { GIT_STATUS_WT_NEW, }; -static const size_t entry_count0 = 14; +static const size_t entry_count0 = 15; diff --git a/tests-clay/status/worktree.c b/tests-clay/status/worktree.c index 1e8a5ddbc..15cbb2828 100644 --- a/tests-clay/status/worktree.c +++ b/tests-clay/status/worktree.c @@ -122,3 +122,16 @@ void test_status_worktree__empty_repository(void) git_status_foreach(_repository, cb_status__count, &count); cl_assert(count == 0); } + +void test_status_worktree__single_file(void) +{ + int i; + unsigned int status_flags; + + for (i = 0; i < (int)entry_count0; i++) { + cl_git_pass( + git_status_file(&status_flags, _repository, entry_paths0[i]) + ); + cl_assert(entry_statuses0[i] == status_flags); + } +} |