]> git.proxmox.com Git - libgit2.git/blame - tests-clar/odb/mixed.c
Merge pull request #1769 from ethomson/configparse
[libgit2.git] / tests-clar / odb / mixed.c
CommitLineData
24634c6f
HWN
1#include "clar_libgit2.h"
2#include "odb.h"
24634c6f
HWN
3
4static git_odb *_odb;
5
6void test_odb_mixed__initialize(void)
7{
8 cl_git_pass(git_odb_open(&_odb, cl_fixture("duplicate.git/objects")));
9}
10
11void test_odb_mixed__cleanup(void)
12{
13 git_odb_free(_odb);
9094d30b 14 _odb = NULL;
24634c6f
HWN
15}
16
17void test_odb_mixed__dup_oid(void) {
18 const char hex[] = "ce013625030ba8dba906f756967f9e9ca394464a";
19 git_oid oid;
20 git_odb_object *obj;
437224b4 21
24634c6f
HWN
22 cl_git_pass(git_oid_fromstr(&oid, hex));
23 cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, GIT_OID_HEXSZ));
24 git_odb_object_free(obj);
25}
26
437224b4
RB
27/* some known sha collisions of file content:
28 * 'aabqhq' and 'aaazvc' with prefix 'dea509d0' (+ '9' and + 'b')
29 * 'aaeufo' and 'aaaohs' with prefix '81b5bff5' (+ 'f' and + 'b')
30 * 'aafewy' and 'aaepta' with prefix '739e3c4c'
31 * 'aahsyn' and 'aadrjg' with prefix '0ddeaded' (+ '9' and + 'e')
32 */
33
34void test_odb_mixed__dup_oid_prefix_0(void) {
35 char hex[10];
36 git_oid oid;
37 git_odb_object *obj;
38
39 /* ambiguous in the same pack file */
40
41 strncpy(hex, "dea509d0", sizeof(hex));
42 cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
43 cl_assert_equal_i(
44 GIT_EAMBIGUOUS, git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
45
46 strncpy(hex, "dea509d09", sizeof(hex));
47 cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
48 cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
49 git_odb_object_free(obj);
50
51 strncpy(hex, "dea509d0b", sizeof(hex));
52 cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
53 cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
54 git_odb_object_free(obj);
55
56 /* ambiguous in different pack files */
57
58 strncpy(hex, "81b5bff5", sizeof(hex));
59 cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
60 cl_assert_equal_i(
61 GIT_EAMBIGUOUS, git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
62
63 strncpy(hex, "81b5bff5b", sizeof(hex));
64 cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
65 cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
66 git_odb_object_free(obj);
67
68 strncpy(hex, "81b5bff5f", sizeof(hex));
69 cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
70 cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
71 git_odb_object_free(obj);
72
73 /* ambiguous in pack file and loose */
74
75 strncpy(hex, "0ddeaded", sizeof(hex));
76 cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
77 cl_assert_equal_i(
78 GIT_EAMBIGUOUS, git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
79
80 strncpy(hex, "0ddeaded9", sizeof(hex));
81 cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
82 cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
83 git_odb_object_free(obj);
84
85 strncpy(hex, "0ddeadede", sizeof(hex));
86 cl_git_pass(git_oid_fromstrn(&oid, hex, strlen(hex)));
87 cl_git_pass(git_odb_read_prefix(&obj, _odb, &oid, strlen(hex)));
88 git_odb_object_free(obj);
89}