diff options
| author | Russell Belfer <rb@github.com> | 2013-04-26 15:35:47 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-04-30 04:25:56 -0700 |
| commit | e26b14c0345ef82771f222aa50be926f5969531d (patch) | |
| tree | 2471b9eaba32bd46589d778e6d6a5dfbeb9b7d03 /tests-clar | |
| parent | fdb3034e725ccf2c7be11871fcc374ced436983e (diff) | |
| download | libgit2-e26b14c0345ef82771f222aa50be926f5969531d.tar.gz | |
Update diff handling of untracked directories
When diff encounters an untracked directory, there was a shortcut
that it took which is not compatible with core git. This makes
the default behavior no longer take that shortcut and instead look
inside the untracked directory to see if there are any untracked
files within it. If there are not, then the directory is treated
as an ignore directory instead of an untracked directory. This
has implications for the git_status APIs.
Diffstat (limited to 'tests-clar')
| -rw-r--r-- | tests-clar/status/status_helpers.c | 3 | ||||
| -rw-r--r-- | tests-clar/status/status_helpers.h | 1 | ||||
| -rw-r--r-- | tests-clar/status/worktree.c | 5 | ||||
| -rw-r--r-- | tests-clar/submodule/status.c | 27 |
4 files changed, 32 insertions, 4 deletions
diff --git a/tests-clar/status/status_helpers.c b/tests-clar/status/status_helpers.c index 24546d45c..f073c2491 100644 --- a/tests-clar/status/status_helpers.c +++ b/tests-clar/status/status_helpers.c @@ -40,7 +40,8 @@ int cb_status__single(const char *p, unsigned int s, void *payload) { status_entry_single *data = (status_entry_single *)payload; - GIT_UNUSED(p); + if (data->debug) + fprintf(stderr, "%02d: %s (%04x)\n", data->count, p, s); data->count++; data->status = s; diff --git a/tests-clar/status/status_helpers.h b/tests-clar/status/status_helpers.h index 1aa0263ee..ae1469e79 100644 --- a/tests-clar/status/status_helpers.h +++ b/tests-clar/status/status_helpers.h @@ -24,6 +24,7 @@ extern int cb_status__count(const char *p, unsigned int s, void *payload); typedef struct { int count; unsigned int status; + bool debug; } status_entry_single; /* cb_status__single takes payload of "status_entry_single *" */ diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c index a9b8a12ed..0138b1712 100644 --- a/tests-clar/status/worktree.c +++ b/tests-clar/status/worktree.c @@ -258,9 +258,8 @@ void test_status_worktree__ignores(void) static int cb_status__check_592(const char *p, unsigned int s, void *payload) { - GIT_UNUSED(payload); - - if (s != GIT_STATUS_WT_DELETED || (payload != NULL && strcmp(p, (const char *)payload) != 0)) + if (s != GIT_STATUS_WT_DELETED || + (payload != NULL && strcmp(p, (const char *)payload) != 0)) return -1; return 0; diff --git a/tests-clar/submodule/status.c b/tests-clar/submodule/status.c index 282e82758..fca84af63 100644 --- a/tests-clar/submodule/status.c +++ b/tests-clar/submodule/status.c @@ -383,3 +383,30 @@ void test_submodule_status__iterator(void) cl_git_pass(git_status_foreach_ext(g_repo, &opts, confirm_submodule_status, &exp)); } + +void test_submodule_status__untracked_dirs_containing_ignored_files(void) +{ + git_buf path = GIT_BUF_INIT; + unsigned int status, expected; + git_submodule *sm; + + cl_git_pass(git_buf_joinpath(&path, git_repository_path(g_repo), "modules/sm_unchanged/info/exclude")); + cl_git_append2file(git_buf_cstr(&path), "\n*.ignored\n"); + + cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "sm_unchanged/directory")); + cl_git_pass(git_futils_mkdir(git_buf_cstr(&path), NULL, 0755, 0)); + cl_git_pass(git_buf_joinpath(&path, git_buf_cstr(&path), "i_am.ignored")); + cl_git_mkfile(git_buf_cstr(&path), "ignored this file, please\n"); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_status(&status, sm)); + + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + expected = GIT_SUBMODULE_STATUS_IN_HEAD | + GIT_SUBMODULE_STATUS_IN_INDEX | + GIT_SUBMODULE_STATUS_IN_CONFIG | + GIT_SUBMODULE_STATUS_IN_WD; + + cl_assert(status == expected); +} |
