diff options
author | Adam Roben <adam@roben.org> | 2012-06-07 09:50:19 -0400 |
---|---|---|
committer | Adam Roben <adam@roben.org> | 2012-06-07 09:50:19 -0400 |
commit | 8e60c712acef798a6b3913359f8d9dffcddf7256 (patch) | |
tree | 111d5cfc0e23bceb4a097a369d29c2992255fa37 /tests-clar/diff/workdir.c | |
parent | b9f78cb87b7a8cb07a660dacdcb59c9adf733c3f (diff) | |
download | libgit2-8e60c712acef798a6b3913359f8d9dffcddf7256.tar.gz |
Fix git_status_file for files that start with a character > 0x7f8bit-filename-status
git_status_file would always return GIT_ENOTFOUND for these files.
The underlying bug was that git__strcmp_cb, which is used by
git_path_with_stat_cmp to sort entries in the working directory,
compares strings based on unsigned chars (this is confirmed by the
strcmp(3) manpage), while git__prefixcmp, which is used by
workdir_iterator__entry_cmp to search for a path in the working
directory, compares strings based on char. So the sort puts this path at
the end of the list, while the search expects it to be at the beginning.
The fix was simply to make git__prefixcmp compare using unsigned chars,
just like strcmp(3). The rest of the change is just adding/updating
tests.
Diffstat (limited to 'tests-clar/diff/workdir.c')
-rw-r--r-- | tests-clar/diff/workdir.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tests-clar/diff/workdir.c b/tests-clar/diff/workdir.c index 1ea1af86a..42152f1ad 100644 --- a/tests-clar/diff/workdir.c +++ b/tests-clar/diff/workdir.c @@ -37,12 +37,12 @@ void test_diff_workdir__to_index(void) * - git diff * - mv .git .gitted */ - cl_assert_equal_i(12, exp.files); + cl_assert_equal_i(13, exp.files); cl_assert_equal_i(0, exp.file_adds); cl_assert_equal_i(4, exp.file_dels); cl_assert_equal_i(4, exp.file_mods); cl_assert_equal_i(1, exp.file_ignored); - cl_assert_equal_i(3, exp.file_untracked); + cl_assert_equal_i(4, exp.file_untracked); cl_assert_equal_i(8, exp.hunks); @@ -87,12 +87,12 @@ void test_diff_workdir__to_tree(void) cl_git_pass(git_diff_foreach( diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); - cl_assert(exp.files == 13); + cl_assert(exp.files == 14); cl_assert(exp.file_adds == 0); cl_assert(exp.file_dels == 4); cl_assert(exp.file_mods == 4); cl_assert(exp.file_ignored == 1); - cl_assert(exp.file_untracked == 4); + cl_assert(exp.file_untracked == 5); /* Since there is no git diff equivalent, let's just assume that the * text diffs produced by git_diff_foreach are accurate here. We will @@ -115,12 +115,12 @@ void test_diff_workdir__to_tree(void) cl_git_pass(git_diff_foreach( diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); - cl_assert(exp.files == 14); + cl_assert(exp.files == 15); cl_assert(exp.file_adds == 2); cl_assert(exp.file_dels == 5); cl_assert(exp.file_mods == 4); cl_assert(exp.file_ignored == 1); - cl_assert(exp.file_untracked == 2); + cl_assert(exp.file_untracked == 3); cl_assert(exp.hunks == 11); @@ -144,12 +144,12 @@ void test_diff_workdir__to_tree(void) cl_git_pass(git_diff_foreach( diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn)); - cl_assert(exp.files == 15); + cl_assert(exp.files == 16); cl_assert(exp.file_adds == 5); cl_assert(exp.file_dels == 4); cl_assert(exp.file_mods == 3); cl_assert(exp.file_ignored == 1); - cl_assert(exp.file_untracked == 2); + cl_assert(exp.file_untracked == 3); cl_assert(exp.hunks == 12); @@ -182,12 +182,12 @@ void test_diff_workdir__to_index_with_pathspec(void) cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff)); cl_git_pass(git_diff_foreach(diff, &exp, diff_file_fn, NULL, NULL)); - cl_assert_equal_i(12, exp.files); + cl_assert_equal_i(13, exp.files); cl_assert_equal_i(0, exp.file_adds); cl_assert_equal_i(4, exp.file_dels); cl_assert_equal_i(4, exp.file_mods); cl_assert_equal_i(1, exp.file_ignored); - cl_assert_equal_i(3, exp.file_untracked); + cl_assert_equal_i(4, exp.file_untracked); git_diff_list_free(diff); |