-
Notifications
You must be signed in to change notification settings - Fork 2.5k
tests: graft commits
- Loading branch information
10000
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#include "clar_libgit2.h" | ||
|
||
#include "futils.h" | ||
#include "graft.h" | ||
|
||
static git_repository *g_repo; | ||
|
||
void test_grafts_basic__initialize(void) | ||
{ | ||
g_repo = cl_git_sandbox_init("grafted.git"); | ||
} | ||
|
||
void test_grafts_basic__cleanup(void) | ||
{ | ||
cl_git_sandbox_cleanup(); | ||
} | ||
|
||
void test_grafts_basic__graft_add(void) | ||
{ | ||
git_oid oid_src, *oid1; | ||
git_commit_graft *graft; | ||
git_graftmap *grafts; | ||
git_array_oid_t parents = GIT_ARRAY_INIT; | ||
|
||
cl_git_pass(git_oidmap_new(&grafts)); | ||
|
||
cl_assert(oid1 = git_array_alloc(parents)); | ||
cl_git_pass(git_oid_fromstr(&oid_src, "2f3053cbff8a4ca2f0666de364ddb734a28a31a9")); | ||
git_oid_cpy(oid1, &oid_src); | ||
|
||
git_oid_fromstr(&oid_src, "f503807ffa920e407a600cfaee96b7152259acc7"); | ||
cl_git_pass(git__graft_register(grafts, &oid_src, parents)); | ||
git_array_clear(parents); | ||
|
||
cl_assert_equal_i(1, git_oidmap_size(grafts)); | ||
cl_git_pass(git__graft_for_oid(&graft, grafts, &oid_src)); | ||
cl_assert_equal_s("f503807ffa920e407a600cfaee96b7152259acc7", git_oid_tostr_s(&graft->oid)); | ||
cl_assert_equal_i(1, git_array_size(graft->parents)); | ||
cl_assert_equal_s("2f3053cbff8a4ca2f0666de364ddb734a28a31a9", git_oid_tostr_s(git_array_get(graft->parents, 0))); | ||
|
||
git__graft_clear(grafts); | ||
git_oidmap_free(grafts); | ||
} | ||
|
||
void test_grafts_basic__grafted_revwalk(void) | ||
{ | ||
git_revwalk *w; | ||
git_oid oids[10]; | ||
size_t i = 0; | ||
git_commit *commit; | ||
|
||
cl_git_pass(git_revwalk_new(&w, g_repo)); | ||
cl_git_pass(git_revwalk_push_ref(w, "refs/heads/branch")); | ||
|
||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[0]), "8a00e91619098618be97c0d2ceabb05a2c58edd9"); | ||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[1]), "f503807ffa920e407a600cfaee96b7152259acc7"); | ||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[2]), "2f3053cbff8a4ca2f0666de364ddb734a28a31a9"); | ||
|
||
cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oids[i++], w)); | ||
|
||
cl_git_pass(git_commit_lookup(&commit, g_repo, &oids[0])); | ||
|
||
cl_assert_equal_i(1, git_commit_parentcount(commit)); | ||
|
||
git_commit_free(commit); | ||
git_revwalk_free(w); | ||
} | ||
|
||
void test_grafts_basic__grafted_objects(void) | ||
{ | ||
git_oid oid; | ||
git_commit *commit; | ||
|
||
cl_git_pass(git_oid_fromstr(&oid, "f503807ffa920e407a600cfaee96b7152259acc7")); | ||
cl_git_pass(git_commit_lookup(&commit, g_repo, &oid)); | ||
cl_assert_equal_i(1, git_commit_parentcount(commit)); | ||
git_commit_free(commit); | ||
|
||
cl_git_pass(git_oid_fromstr(&oid, "0512adebd3782157f0d5c9b22b043f87b4aaff9e")); | ||
cl_git_pass(git_commit_lookup(&commit, g_repo, &oid)); | ||
cl_assert_equal_i(1, git_commit_parentcount(commit)); | ||
git_commit_free(commit); | ||
|
||
cl_git_pass(git_oid_fromstr(&oid, "66cc22a015f6ca75b34c82d28f78ba663876bade")); | ||
cl_git_pass(git_commit_lookup(&commit, g_repo, &oid)); | ||
cl_assert_equal_i(4, git_commit_parentcount(commit)); | ||
git_commit_free(commit); | ||
} | ||
|
||
void test_grafts_basic__grafted_merge_revwalk(void) | ||
{ | ||
git_revwalk *w; | ||
git_oid oids[10]; | ||
size_t i = 0; | ||
|
||
cl_git_pass(git_revwalk_new(&w, g_repo)); | ||
cl_git_pass(git_revwalk_push_ref(w, "refs/heads/bottom")); | ||
|
||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[i - 1]), "66cc22a015f6ca75b34c82d28f78ba663876bade"); | ||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[i - 1]), "e414f42f4e6bc6934563a2349a8600f0ab68618e"); | ||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[i - 1]), "8a00e91619098618be97c0d2ceabb05a2c58edd9"); | ||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[i - 1]), "1c18e80a276611bb9b146590616bbc5aebdf2945"); | ||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[i - 1]), "d7224d49d6d5aff6ade596ed74f4bcd4f77b29e2"); | ||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[i - 1]), "0512adebd3782157f0d5c9b22b043f87b4aaff9e"); | ||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[i - 1]), "f503807ffa920e407a600cfaee96b7152259acc7"); | ||
cl_git_pass(git_revwalk_next(&oids[i++], w)); | ||
cl_assert_equal_s(git_oid_tostr_s(&oids[i - 1]), "2f3053cbff8a4ca2f0666de364ddb734a28a31a9"); | ||
|
||
cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oids[i++], w)); | ||
|
||
git_revwalk_free(w); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#include "clar_libgit2.h" | ||
#include "futils.h" | ||
|
||
static git_repository *g_repo; | ||
static git_oid g_shallow_oid; | ||
|
||
void test_grafts_shallow__initialize(void) | ||
{ | ||
cl_git_pass(git_oid_fromstr(&g_shallow_oid, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644")); | ||
} | ||
|
||
void test_grafts_shallow__cleanup(void) | ||
{ | ||
cl_git_sandbox_cleanup(); | ||
} | ||
|
||
void test_grafts_shallow__no_shallow_file(void) | ||
{ | ||
g_repo = cl_git_sandbox_init("testrepo.git"); | ||
cl_assert_equal_i(0, git_repository_is_shallow(g_repo)); | ||
} | ||
|
||
void test_grafts_shallow__empty_shallow_file(void) | ||
{ | ||
g_repo = cl_git_sandbox_init("testrepo.git"); | ||
cl_git_mkfile("testrepo.git/shallow", ""); | ||
cl_assert_equal_i(0, git_repository_is_shallow(g_repo)); | ||
} | ||
|
||
void test_grafts_shallow__shallow_repo(void) | ||
{ | ||
g_repo = cl_git_sandbox_init("shallow.git"); | ||
cl_assert_equal_i(1, git_repository_is_shallow(g_repo)); | ||
} | ||
|
||
void test_grafts_shallow__clears_errors(void) | ||
{ | ||
g_repo = cl_git_sandbox_init("testrepo.git"); | ||
cl_assert_equal_i(0, git_repository_is_shallow(g_repo)); | ||
cl_assert_equal_p(NULL, git_error_last()); | ||
} | ||
|
||
void test_grafts_shallow__shallow_oids(void) | ||
{ | ||
git_oidarray oids, oids2; | ||
g_repo = cl_git_sandbox_init("shallow.git"); | ||
|
||
cl_git_pass(git_repository_shallow_roots(&oids, g_repo)); | ||
cl_assert_equal_i(1, oids.count); | ||
cl_assert_equal_oid(&g_shallow_oid, &oids.ids[0]); | ||
|
||
cl_git_pass(git_repository_shallow_roots(&oids2, g_repo)); | ||
cl_assert_equal_p(oids.ids, oids2.ids); | ||
} | ||
|
||
void test_grafts_shallow__cache_clearing(void) | ||
{ | ||
git_oidarray oids, oids2; | ||
git_oid tmp_oid; | ||
|
||
git_oid_fromstr(&tmp_oid, "0000000000000000000000000000000000000000"); | ||
g_repo = cl_git_sandbox_init("shallow.git"); | ||
|
||
cl_git_pass(git_repository_shallow_roots(&oids, g_repo)); | ||
cl_assert_equal_i(1, oids.count); | ||
cl_assert_equal_oid(&g_shallow_oid, &oids.ids[0]); | ||
|
||
cl_git_mkfile("shallow.git/shallow", | ||
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644\n" | ||
"0000000000000000000000000000000000000000\n" | ||
); | ||
|
||
cl_git_ 8000 pass(git_repository_shallow_roots(&oids2, g_repo)); | ||
cl_assert_equal_i(2, oids2.count); | ||
cl_assert_equal_oid(&g_shallow_oid, &oids2.ids[0]); | ||
cl_assert_equal_oid(&tmp_oid, &oids2.ids[1]); | ||
|
||
cl_git_pass(p_unlink("shallow.git/shallow")); | ||
cl_git_pass(git_repository_shallow_roots(&oids, g_repo)); | ||
cl_assert_equal_i(0, oids.count); | ||
git_oidarray_free(&oids); | ||
} | ||
|
||
void test_grafts_shallow__errors_on_borked(void) | ||
{ | ||
git_oidarray oids; | ||
|
||
g_repo = cl_git_sandbox_init("shallow.git"); | ||
|
||
cl_git_mkfile("shallow.git/shallow", "lolno"); | ||
|
||
cl_git_fail_with(-1, git_repository_shallow_roots(&oids, g_repo)); | ||
|
||
cl_git_mkfile("shallow.git/shallow", "lolno\n"); | ||
|
||
cl_git_fail_with(-1, git_repository_shallow_roots(&oids, g_repo)); | ||
} | ||
|
||
void test_grafts_shallow__revwalk_behavior(void) | ||
{ | ||
git_revwalk *w; | ||
git_oid oid_1, oid_2, oid_3; | ||
|
||
g_repo = cl_git_sandbox_init("shallow.git"); | ||
|
||
cl_git_pass(git_revwalk_new(&w, g_repo)); | ||
cl_git_pass(git_revwalk_push_head(w)); | ||
|
||
cl_git_pass(git_revwalk_next(&oid_1, w)); // a65fedf39aefe402d3bb6e24df4d4f5fe4547750 | ||
cl_git_pass(git_revwalk_next(&oid_2, w)); // be3563ae3f795b2b4353bcce3a527ad0a4f7f644 | ||
cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oid_3, w)); | ||
|
||
cl_assert_equal_s(git_oid_tostr_s(&oid_1), "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"); | ||
cl_assert_equal_s(git_oid_tostr_s(&oid_2), "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); | ||
|
||
git_revwalk_free(w); | ||
} | ||
|
||
void test_grafts_shallow__grafted_object(void) | ||
{ | ||
git_commit *commit; | ||
|
||
g_repo = cl_git_sandbox_init("shallow.git"); | ||
|
||
cl_git_pass(git_commit_lookup(&commit, g_repo, &g_shallow_oid)); | ||
|
||
cl_assert_equal_i(0, git_commit_parentcount(commit)); | ||
|
||
git_commit_free(commit); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ref: refs/heads/master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[core] | ||
repositoryformatversion = 0 | ||
filemode = true | ||
bare = true | ||
ignorecase = true | ||
precomposeunicode = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
f503807ffa920e407a600cfaee96b7152259acc7 2f3053cbff8a4ca2f0666de364ddb734a28a31a9 | ||
0512adebd3782157f0d5c9b22b043f87b4aaff9e 2f3053cbff8a4ca2f0666de364ddb734a28a31a9 | ||
66cc22a015f6ca75b34c82d28f78ba663876bade e414f42f4e6bc6934563a2349a8600f0ab68618e 8a00e91619098618be97c0d2ceabb05a2c58edd9 1c18e80a276611bb9b146590616bbc5aebdf2945 2f3053cbff8a4ca2f0666de364ddb734a28a31a9 |
Binary file added
BIN
+133 Bytes
tests/resources/grafted.git/objects/05/12adebd3782157f0d5c9b22b043f87b4aaff9e
Binary file not shown.
Binary file added
BIN
+170 Bytes
tests/resources/grafted.git/objects/1c/18e80a276611bb9b146590616bbc5aebdf2945
Binary file not shown.
Binary file added
BIN
+46 Bytes
tests/resources/grafted.git/objects/1c/3f11eca55d76bc1bf7353ca7e4226246d353ed
Binary file not shown.
Binary file added
BIN
+73 Bytes
tests/resources/grafted.git/objects/2a/f02ebff1fc0142d2380c98758d81c67b365869
Binary file not shown.
Binary file added
BIN
+74 Bytes
tests/resources/grafted.git/objects/2b/ecadd3f1ecad07a054392421edf9c0e1c375b2
Binary file not shown.
Binary file added
BIN
+133 Bytes
tests/resources/grafted.git/objects/2f/3053cbff8a4ca2f0666de364ddb734a28a31a9
Binary file not shown.
Binary file added
BIN
+50 Bytes
tests/resources/grafted.git/objects/45/342912745ba6f8893b1e126df4653a4355df1a
Binary file not shown.
Binary file added
BIN
+49 Bytes
tests/resources/grafted.git/objects/48/b2b333732644eafb385771a992b923fa88f135
Binary file not shown.
Binary file added
BIN
+74 Bytes
tests/resources/grafted.git/objects/5d/31bf4b437e1191b6c709c665f1bd329d0ed0bf
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
tests/resources/grafted.git/objects/66/cc22a015f6ca75b34c82d28f78ba663876bade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10000
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x���M | ||
�0F]���$��D�x=�4N��4�Fϯ�#����x|��260dvm�ap1��a�}���N�hL!E&}�BTO^dn �)��$~�ꖜ�l,�=bF|�:��W{��m�y�rY��u�N~�t/<N]��ڡEHkأATi��䯈�H�o�<N�>ѫM, |
Binary file added
BIN
+36 Bytes
tests/resources/grafted.git/objects/6c/f192eb71cd3243c9fbbe2551012c4449de3fcf
Binary file not shown.
Binary file added
BIN
+76 Bytes
tests/resources/grafted.git/objects/7c/9da502b2744b70522bb694cd607fb00104a233
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
tests/resources/grafted.git/objects/8a/00e91619098618be97c0d2ceabb05a2c58edd9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x���A | ||
�0E]���t�4Dt� <�$��@�J��#���������ч��@B�5�@b$�'��[�i���g&V/^�6H� ]J<�A�bH,2���Ȏ�S�n�e�{�R���˶T8o�v��שp����|���d�����~��_u�1� R�ŨߚNC |
Binary file added
BIN
+42 Bytes
tests/resources/grafted.git/objects/a0/4de168dd5c43aa2af594d794d62e922f8b3b34
Binary file not shown.
Binary file added
BIN
+54 Bytes
tests/resources/grafted.git/objects/b2/b4f9e5fe5dacbb2f98bd71d1dc86c7b571ddd1
Binary file not shown.
Binary file added
BIN
+37 Bytes
tests/resources/grafted.git/objects/ba/54010f8d41532eb130eba420f50248881f7fc2
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
tests/resources/grafted.git/objects/d7/224d49d6d5aff6ade596ed74f4bcd4f77b29e2
8000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x���A | ||
�0E]���dҐD�x=�$�h�I���_�Gp��/����Ԁ,��"�%p�&�/�1�ތԓ��ƀ��q֓z�"�ZM�G���%�6���co��|Ϝ�(���^8�IJ�r^k�ú���|�e��.�|mѠu��H�*lW��%Q��%��Y�ZڧbUoaRj |
Binary file added
BIN
+35 Bytes
tests/resources/grafted.git/objects/db/8e43f297a313c439530c977b733aaa8c10d54e
Binary file not shown.
Binary file added
BIN
+139 Bytes
tests/resources/grafted.git/objects/e4/14f42f4e6bc6934563a2349a8600f0ab68618e
Binary file not shown.
Binary file added
BIN
+74 Bytes
tests/resources/grafted.git/objects/e6/7b587a57850c69f6f9351ee10c7c8a41dacc78
Binary file not shown.
Binary file added
BIN
+77 Bytes
tests/resources/grafted.git/objects/f0/7330bc2e4ed4bd0bf2301505f6c6bbad01aa2a
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
tests/resources/grafted.git/objects/f5/03807ffa920e407a600cfaee96b7152259acc7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
x���A | ||
�0E]��J&�6)��� ���@�@��#����x�Z)�z{�D/ɋMb9P�&yyBF&7�헙Q�w�=K��P�V�;�Oߖ�:P+3��Ə���6Z+:���Qw�\Hy�>zA� | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
66cc22a015f6ca75b34c82d28f78ba663876bade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
8a00e91619098618be97c0d2ceabb05a2c58edd9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2f3053cbff8a4ca2f0666de364ddb734a28a31a9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1c18e80a276611bb9b146590616bbc5aebdf2945 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Shallow support v2 #5254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Shallow support v2 #5254
Changes from 1 commit
0668384
919501a
3c17f22
a8b1d51
a35cc40
d54c008
22f201b
14a309a
05e286f
a11026e
70867f7
fd2398b
a4803c3
79af067
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.