diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2013-08-21 14:07:53 -0500 | 
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2013-08-28 08:30:19 -0500 | 
| commit | 17c7fbf6d276443344c54f55800367b9837c0259 (patch) | |
| tree | 97aeafdfa0eca4736a4f0cd733250f5d150278e8 /tests-clar/diff/rename.c | |
| parent | 1ef05e3f0ea8fa8db2167307101c8c43d1c1784b (diff) | |
| download | libgit2-17c7fbf6d276443344c54f55800367b9837c0259.tar.gz | |
Split rewrites, status doesn't return rewrites
Ensure that we apply splits to rewrites, even if we're not
interested in examining it closely for rename/copy detection.
In keeping with core git, status should not display rewrites,
it should simply show files as "modified".
Diffstat (limited to 'tests-clar/diff/rename.c')
| -rw-r--r-- | tests-clar/diff/rename.c | 49 | 
1 files changed, 49 insertions, 0 deletions
| diff --git a/tests-clar/diff/rename.c b/tests-clar/diff/rename.c index 5a35495f7..ac3814d59 100644 --- a/tests-clar/diff/rename.c +++ b/tests-clar/diff/rename.c @@ -1235,3 +1235,52 @@ void test_diff_rename__unmodified_can_be_renamed(void)  	git_index_free(index);  	git_tree_free(tree);  } + +void test_diff_rename__rewrite_on_single_file(void) +{ +	git_index *index; +	git_diff_list *diff = NULL; +	diff_expects exp; +	git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT; +	git_diff_find_options findopts = GIT_DIFF_FIND_OPTIONS_INIT; + +	diffopts.flags = GIT_DIFF_INCLUDE_UNTRACKED; + +	findopts.flags = GIT_DIFF_FIND_FOR_UNTRACKED | +		GIT_DIFF_FIND_AND_BREAK_REWRITES | +		GIT_DIFF_FIND_RENAMES_FROM_REWRITES; + +	cl_git_pass(git_repository_index(&index, g_repo)); + +	cl_git_rewritefile("renames/ikeepsix.txt", +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n" \ +		"This is enough content for the file to be rewritten.\n"); + +	cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, index, &diffopts)); +	cl_git_pass(git_diff_find_similar(diff, &findopts)); + +	memset(&exp, 0, sizeof(exp)); + +	cl_git_pass(git_diff_foreach( +		diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp)); +	cl_assert_equal_i(2, exp.files); +	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]); +	cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]); + +	git_diff_list_free(diff); +	git_index_free(index); +} | 
