我使用libgit2 v0.22.2,我把一个文件目录放到git repo中,odb& refdb由mysql数据库支持。 blob,树,提交对象可以在odb中找到。使用git_tree_builder和树结构表下面的树写入odb。
当我尝试使用树步行功能打印目录结构时,只打印了几个条目。
代码:
int tree_walk_cb(const char *root, const git_tree_entry *entry, void *payload)
{
const char *name = git_tree_entry_name(entry);
git_otype type = git_tree_entry_type(entry);
printf("entry: %s \n", name);
return 0;
}
int git_mysql_tree_walk(git_mysql *mysql, git_repository *repo){
int error;
git_oid oid;
git_tree *tree = NULL;
git_oid_fromstr(&oid, "19ee624b3c2983ca0a09b7435dccdaae76a16cad");
error = git_tree_lookup(&tree, repo, &oid);
error = git_tree_walk(tree, GIT_TREEWALK_PRE, tree_walk_cb, NULL);
}
输出:
entry: .gitattributes
entry: .gitignore
entry: .npmignore
entry: CMakeLists.txt
entry: LICENSE
entry: README.md
entry: cmake
root tree' 19ee624b3c2983ca0a09b7435dccdaae76a16cad'含量:
100644 .gitattributes ��u����d��K��c=�{100644 .gitignore �$m������V-�)�k100644 .npmignore ө���u�Ƴ�&�Գ�
100644 CMakeLists.txt ��}���# �6/�?f�h{)�100644 LICENSE O6sa/���m�����-�OY100644 README.md A�/B�74wJa����:�rƄ�40000 cmake yi����^Z���[e�l!ğ�#40000 native ��<���Ξ�} X3� �ϙ100644 package.json M-Iő������J$��K40000 script ��L�� ��� �y��#���40000 test K�]�B�n��`�K�֒���I
从原始根树内容中,我们可以看到其他条目,但它们不会在树步行回调中打印出来。此外,树步行没有像cmake
那样以递归方式打印子树请指教,谢谢!
ODB:
oid type size data
0015cd404c7fa06de9194221e04712f9551146fe 2 115 ...
19ee624b3c2983ca0a09b7435dccdaae76a16cad 2 401 ...
1f6808ef9c0bcb443005acf4542bc1264a5e68f6 3 285 ...
1fe1a4246df70ba6b9a805be1fe7562d9429d46b 3 723 ...
33bbc64e87a5f1baa138d802664a07bf87b81de0 3 366 ...
34832d8c0636fa9a92dbae10f4add7fafe6fc7ab 3 1104 ...
377cc807899a648240718d824306deec8943ab5b 3 7221 ...
37fc4881eff286f264f91aedce13ae7790806061 3 493 ...
41842f42ac3734774a6192c9d7f03ad972c684fc 3 1186 ...
4b825dc642cb6eb9a060e54bf8d69288fbee4904 2 0
4d2d49c591fe1795cfcd1ba8159b4a249c94014b 3 759 ...
4f3673611b2f0e93cdcb6ddaf69499832da94f59 3 1102 ...
5828d750c46503ba9defd5ea37b0d3c46e37b334 3 160 ...
5ac1ceb34a87a8ea589e26a19796e2239cc2e6c5 3 1188 ...
5bc42581996460da22fe58af4537ff454f37fe57 3 14506 ...
5e5af8327eb6ea85d85ea94fd2f64c7317ff3867 1 167 ...
7969f8b194a15e5ae6fec35b65c26c21c49fee23 2 85 ...
7c57e957a1e4abf47cfd58d7fc695262ffbb5673 3 260 ...
7c75467b21b5a8f17a6e5e68c1d12782d39649aa 3 415 ...
801dc03cbabb148dce9ef37d2058339f20b4cf99 2 64 ...
8231cec56dca4ae528ee1253759b0a5cef17de0c 2 408 ...
86b5584b35bcf27022deb9fbf14f3f14f54c4b42 3 8643 ...
8ae61ae3a4cc2882cf1ec883cc4b7ef1d134428b 3 332 ...
8ba87598aa1ed8180bc064e5c84ba7e0633d8e7b 3 37 ...
96c19f76ef41203ddfacba2c2b5975152946aa41 3 1387 ...
aa01580037fd3823bc35c194ee33942f7033246d 2 73 ...
b2811f77461ebaa1314a5c05def22c4220899756 2 145 ...
c2cf7d99a81a9b2300e1362feb3f66cb687b29fa 3 2756 ...
c78274783836eeb8a861d91a03869aab7a58b289 3 385 ...
cd5750aa5dd2214a861900876a905f7bff171970 3 3084 ...
d2a71c98dab94e48e73a262a86e8e79eb7ffdb29 3 78 ...
d3a9ebb5e41ae1751f8314c6b3c12693d4b39b0a 3 225 ...
d64277adcb7d5a41f9088d380f2b498b09341ce9 3 578 ...
e006733c8da938b4401bab8727c301f96abbaf9c 3 335 ...
e271f1db33845ada20afa51a630d68ad0c34a4bf 3 1253 ...
f29ee0d06a2c57bad8406921c6b8dd85e6f29ccc 3 1568 ...
f2cf4cb0e1209cd9df09ad799e0bf5231addd1d0 2 32 ...
f7532185429bb09a7e7c132e21e50a7ea33b4f13 3 10152 ...
树形结构:
tree dir entry type oid
19ee624b3c2983ca0a09b7435dccdaae76a16cad / .gitattributes BLOB 8ba87598aa1ed8180bc064e5c84ba7e0633d8e7b
19ee624b3c2983ca0a09b7435dccdaae76a16cad / .gitignore BLOB 1fe1a4246df70ba6b9a805be1fe7562d9429d46b
19ee624b3c2983ca0a09b7435dccdaae76a16cad / .npmignore BLOB d3a9ebb5e41ae1751f8314c6b3c12693d4b39b0a
19ee624b3c2983ca0a09b7435dccdaae76a16cad / CMakeLists.txt BLOB c2cf7d99a81a9b2300e1362feb3f66cb687b29fa
19ee624b3c2983ca0a09b7435dccdaae76a16cad / LICENSE BLOB 4f3673611b2f0e93cdcb6ddaf69499832da94f59
19ee624b3c2983ca0a09b7435dccdaae76a16cad / README.md BLOB 41842f42ac3734774a6192c9d7f03ad972c684fc
19ee624b3c2983ca0a09b7435dccdaae76a16cad / cmake TREE 7969f8b194a15e5ae6fec35b65c26c21c49fee23
19ee624b3c2983ca0a09b7435dccdaae76a16cad / native TREE 801dc03cbabb148dce9ef37d2058339f20b4cf99
19ee624b3c2983ca0a09b7435dccdaae76a16cad / package.json BLOB 4d2d49c591fe1795cfcd1ba8159b4a249c94014b
19ee624b3c2983ca0a09b7435dccdaae76a16cad / script TREE f2cf4cb0e1209cd9df09ad799e0bf5231addd1d0
19ee624b3c2983ca0a09b7435dccdaae76a16cad / test TREE 4b825dc642cb6eb9a060e54bf8d69288fbee4904
7969f8b194a15e5ae6fec35b65c26c21c49fee23 /cmake/ FindMysql.cmake BLOB 96c19f76ef41203ddfacba2c2b5975152946aa41
7969f8b194a15e5ae6fec35b65c26c21c49fee23 /cmake/ FindNode.cmake BLOB 5ac1ceb34a87a8ea589e26a19796e2239cc2e6c5
801dc03cbabb148dce9ef37d2058339f20b4cf99 /native/ addon TREE 0015cd404c7fa06de9194221e04712f9551146fe
801dc03cbabb148dce9ef37d2058339f20b4cf99 /native/ mysql TREE 8231cec56dca4ae528ee1253759b0a5cef17de0c
0015cd404c7fa06de9194221e04712f9551146fe /native/addon/ addon.cc BLOB 7c57e957a1e4abf47cfd58d7fc695262ffbb5673
0015cd404c7fa06de9194221e04712f9551146fe /native/addon/ git_mysql.cc BLOB 5bc42581996460da22fe58af4537ff454f37fe57
0015cd404c7fa06de9194221e04712f9551146fe /native/addon/ git_mysql.h BLOB 34832d8c0636fa9a92dbae10f4add7fafe6fc7ab
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_backend.c BLOB 377cc807899a648240718d824306deec8943ab5b
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_backend.h BLOB e271f1db33845ada20afa51a630d68ad0c34a4bf
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_index.c BLOB cd5750aa5dd2214a861900876a905f7bff171970
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_index.h BLOB 7c75467b21b5a8f17a6e5e68c1d12782d39649aa
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_odb.c BLOB f7532185429bb09a7e7c132e21e50a7ea33b4f13
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_odb.h BLOB c78274783836eeb8a861d91a03869aab7a58b289
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_refdb.c BLOB 86b5584b35bcf27022deb9fbf14f3f14f54c4b42
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_refdb.h BLOB 37fc4881eff286f264f91aedce13ae7790806061
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_repo.c BLOB f29ee0d06a2c57bad8406921c6b8dd85e6f29ccc
8231cec56dca4ae528ee1253759b0a5cef17de0c /native/mysql/ mysql_repo.h BLOB 1f6808ef9c0bcb443005acf4542bc1264a5e68f6
f2cf4cb0e1209cd9df09ad799e0bf5231addd1d0 /script/ mysql TREE b2811f77461ebaa1314a5c05def22c4220899756
b2811f77461ebaa1314a5c05def22c4220899756 /script/mysql/ index.sql BLOB d64277adcb7d5a41f9088d380f2b498b09341ce9
b2811f77461ebaa1314a5c05def22c4220899756 /script/mysql/ odb.sql BLOB 33bbc64e87a5f1baa138d802664a07bf87b81de0
b2811f77461ebaa1314a5c05def22c4220899756 /script/mysql/ refdb.sql BLOB e006733c8da938b4401bab8727c301f96abbaf9c
b2811f77461ebaa1314a5c05def22c4220899756 /script/mysql/ repo.sql BLOB 8ae61ae3a4cc2882cf1ec883cc4b7ef1d134428b
4b825dc642cb6eb9a060e54bf8d69288fbee4904 /test/ mocha.opts BLOB d2a71c98dab94e48e73a262a86e8e79eb7ffdb29
4b825dc642cb6eb9a060e54bf8d69288fbee4904 /test/ test.js BLOB 5828d750c46503ba9defd5ea37b0d3c46e37b334
答案 0 :(得分:0)
问题在于odb_read函数中的mysql后端,mysql_stmt_fetch mysql_stmt_fetch在调试模式下抛出异常,在发布模式下,它工作正常,并且树中的所有条目都打印
记录了一个新问题来标记:mysql来跟踪问题
mysql C API - mysql_stmt_fetch throw exception: access violation write at 0x00000008