Commit 875bfc5f by Russell Belfer

Fix error in tree iterator when popping up trees

There was an error in the tree iterator where it would
delete two tree levels instead of just one when popping
up a tree level.  Unfortunately the test data for the
tree iterator did not have any deep trees with subtrees
in the middle of the tree items, so this problem went
unnoticed.  This contains the 1-line fix plus new test
data and tests that reveal the issue.
parent c8838ee9
......@@ -121,7 +121,6 @@ static int tree_iterator__advance(
break;
tree_iterator__pop_frame(ti);
git_buf_rtruncate_at_char(&ti->path, '/');
}
if (te && entry_is_tree(te))
......
......@@ -139,6 +139,40 @@ void test_diff_iterator__tree_3(void)
tree_iterator_test("status", "0017bd4ab1e", 8, expected_tree_3);
}
/* $ git ls-tree -r --name-only 24fa9a9fc4e202313e24b648087495441dab432b */
const char *expected_tree_4[] = {
"attr0",
"attr1",
"attr2",
"attr3",
"binfile",
"gitattributes",
"macro_bad",
"macro_test",
"root_test1",
"root_test2",
"root_test3",
"root_test4.txt",
"sub/abc",
"sub/file",
"sub/sub/file",
"sub/sub/subsub.txt",
"sub/subdir_test1",
"sub/subdir_test2.txt",
"subdir/.gitattributes",
"subdir/abc",
"subdir/subdir_test1",
"subdir/subdir_test2.txt",
"subdir2/subdir2_test1",
NULL
};
void test_diff_iterator__tree_4(void)
{
tree_iterator_test(
"attr", "24fa9a9fc4e202313e24b648087495441dab432b",
23, expected_tree_4);
}
/* -- INDEX ITERATOR TESTS -- */
......@@ -188,6 +222,12 @@ static const char *expected_index_0[] = {
"root_test2",
"root_test3",
"root_test4.txt",
"sub/abc",
"sub/file",
"sub/sub/file",
"sub/sub/subsub.txt",
"sub/subdir_test1",
"sub/subdir_test2.txt",
"subdir/.gitattributes",
"subdir/abc",
"subdir/subdir_test1",
......@@ -208,6 +248,12 @@ static const char *expected_index_oids_0[] = {
"4d713dc48e6b1bd75b0d61ad078ba9ca3a56745d",
"108bb4e7fd7b16490dc33ff7d972151e73d7166e",
"fe773770c5a6cc7185580c9204b1ff18a33ff3fc",
"3e42ffc54a663f9401cc25843d6c0e71a33e4249",
"45b983be36b73c0788dc9cbcb76cbb80fc7bb057",
"45b983be36b73c0788dc9cbcb76cbb80fc7bb057",
"9e5bdc47d6a80f2be0ea3049ad74231b94609242",
"e563cf4758f0d646f1b14b76016aa17fa9e549a4",
"fb5067b1aef3ac1ada4b379dbcb7d17255df7d78",
"99eae476896f4907224978b88e5ecaa6c5bb67a9",
"3e42ffc54a663f9401cc25843d6c0e71a33e4249",
"e563cf4758f0d646f1b14b76016aa17fa9e549a4",
......@@ -217,7 +263,7 @@ static const char *expected_index_oids_0[] = {
void test_diff_iterator__index_0(void)
{
index_iterator_test("attr", 17, expected_index_0, expected_index_oids_0);
index_iterator_test("attr", 23, expected_index_0, expected_index_oids_0);
}
static const char *expected_index_1[] = {
......
......@@ -4,3 +4,5 @@
a5d76cad53f66f1312bd995909a5bab3c0820770 370fe9ec224ce33e71f9e5ec2bd1142ce9937a6a Russell Belfer <arrbee@arrbee.com> 1327611749 -0800 commit: Updating files so we can do diffs
370fe9ec224ce33e71f9e5ec2bd1142ce9937a6a f5b0af1fb4f5c0cd7aad880711d368a07333c307 Russell Belfer <arrbee@arrbee.com> 1327621027 -0800 commit: Updating test data
f5b0af1fb4f5c0cd7aad880711d368a07333c307 a97cc019851d401a4f1d091cb91a15890a0dd1ba Russell Belfer <arrbee@arrbee.com> 1328653313 -0800 commit: Some whitespace only changes for testing purposes
a97cc019851d401a4f1d091cb91a15890a0dd1ba 217878ab49e1314388ea2e32dc6fdb58a1b969e0 Russell Belfer <arrbee@arrbee.com> 1332734901 -0700 commit: added files in sub/sub
217878ab49e1314388ea2e32dc6fdb58a1b969e0 24fa9a9fc4e202313e24b648087495441dab432b Russell Belfer <arrbee@arrbee.com> 1332735555 -0700 commit: adding more files in sub for tree status
......@@ -4,3 +4,5 @@
a5d76cad53f66f1312bd995909a5bab3c0820770 370fe9ec224ce33e71f9e5ec2bd1142ce9937a6a Russell Belfer <arrbee@arrbee.com> 1327611749 -0800 commit: Updating files so we can do diffs
370fe9ec224ce33e71f9e5ec2bd1142ce9937a6a f5b0af1fb4f5c0cd7aad880711d368a07333c307 Russell Belfer <arrbee@arrbee.com> 1327621027 -0800 commit: Updating test data
f5b0af1fb4f5c0cd7aad880711d368a07333c307 a97cc019851d401a4f1d091cb91a15890a0dd1ba Russell Belfer <arrbee@arrbee.com> 1328653313 -0800 commit: Some whitespace only changes for testing purposes
a97cc019851d401a4f1d091cb91a15890a0dd1ba 217878ab49e1314388ea2e32dc6fdb58a1b969e0 Russell Belfer <arrbee@arrbee.com> 1332734901 -0700 commit: added files in sub/sub
217878ab49e1314388ea2e32dc6fdb58a1b969e0 24fa9a9fc4e202313e24b648087495441dab432b Russell Belfer <arrbee@arrbee.com> 1332735555 -0700 commit: adding more files in sub for tree status
a97cc019851d401a4f1d091cb91a15890a0dd1ba
24fa9a9fc4e202313e24b648087495441dab432b
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment