Commit fa48608e by Vicent Marti

oid: Rename methods

Yeah. Finally. Fuck the old names, this ain't POSIX
and they don't make any sense at all.
parent 43521d06
...@@ -49,7 +49,7 @@ int main (int argc, char** argv) ...@@ -49,7 +49,7 @@ int main (int argc, char** argv)
// The `git_oid` is the structure that keeps the SHA value. We will use this throughout the example // The `git_oid` is the structure that keeps the SHA value. We will use this throughout the example
// for storing the value of the current SHA key we're working with. // for storing the value of the current SHA key we're working with.
git_oid oid; git_oid oid;
git_oid_mkstr(&oid, hex); git_oid_fromstr(&oid, hex);
// Once we've converted the string into the oid value, we can get the raw value of the SHA. // Once we've converted the string into the oid value, we can get the raw value of the SHA.
printf("Raw 20 bytes: [%s]\n", (&oid)->id); printf("Raw 20 bytes: [%s]\n", (&oid)->id);
...@@ -133,7 +133,7 @@ int main (int argc, char** argv) ...@@ -133,7 +133,7 @@ int main (int argc, char** argv)
printf("\n*Commit Parsing*\n"); printf("\n*Commit Parsing*\n");
git_commit *commit; git_commit *commit;
git_oid_mkstr(&oid, "f0877d0b841d75172ec404fc9370173dfffc20d1"); git_oid_fromstr(&oid, "f0877d0b841d75172ec404fc9370173dfffc20d1");
error = git_commit_lookup(&commit, repo, &oid); error = git_commit_lookup(&commit, repo, &oid);
...@@ -192,8 +192,8 @@ int main (int argc, char** argv) ...@@ -192,8 +192,8 @@ int main (int argc, char** argv)
// Commit objects need a tree to point to and optionally one or more parents. Here we're creating oid // Commit objects need a tree to point to and optionally one or more parents. Here we're creating oid
// objects to create the commit with, but you can also use // objects to create the commit with, but you can also use
git_oid_mkstr(&tree_id, "28873d96b4e8f4e33ea30f4c682fd325f7ba56ac"); git_oid_fromstr(&tree_id, "28873d96b4e8f4e33ea30f4c682fd325f7ba56ac");
git_oid_mkstr(&parent_id, "f0877d0b841d75172ec404fc9370173dfffc20d1"); git_oid_fromstr(&parent_id, "f0877d0b841d75172ec404fc9370173dfffc20d1");
// Here we actually create the commit object with a single call with all the values we need to create // Here we actually create the commit object with a single call with all the values we need to create
// the commit. The SHA key is written to the `commit_id` variable here. // the commit. The SHA key is written to the `commit_id` variable here.
...@@ -222,7 +222,7 @@ int main (int argc, char** argv) ...@@ -222,7 +222,7 @@ int main (int argc, char** argv)
// We create an oid for the tag object if we know the SHA and look it up in the repository the same // We create an oid for the tag object if we know the SHA and look it up in the repository the same
// way that we would a commit (or any other) object. // way that we would a commit (or any other) object.
git_oid_mkstr(&oid, "bc422d45275aca289c51d79830b45cecebff7c3a"); git_oid_fromstr(&oid, "bc422d45275aca289c51d79830b45cecebff7c3a");
error = git_tag_lookup(&tag, repo, &oid); error = git_tag_lookup(&tag, repo, &oid);
...@@ -250,7 +250,7 @@ int main (int argc, char** argv) ...@@ -250,7 +250,7 @@ int main (int argc, char** argv)
git_object *objt; git_object *objt;
// Create the oid and lookup the tree object just like the other objects. // Create the oid and lookup the tree object just like the other objects.
git_oid_mkstr(&oid, "2a741c18ac5ff082a7caaec6e74db3075a1906b5"); git_oid_fromstr(&oid, "2a741c18ac5ff082a7caaec6e74db3075a1906b5");
git_tree_lookup(&tree, repo, &oid); git_tree_lookup(&tree, repo, &oid);
// Getting the count of entries in the tree so you can iterate over them if you want to. // Getting the count of entries in the tree so you can iterate over them if you want to.
...@@ -284,7 +284,7 @@ int main (int argc, char** argv) ...@@ -284,7 +284,7 @@ int main (int argc, char** argv)
printf("\n*Blob Parsing*\n"); printf("\n*Blob Parsing*\n");
git_blob *blob; git_blob *blob;
git_oid_mkstr(&oid, "af7574ea73f7b166f869ef1a39be126d9a186ae0"); git_oid_fromstr(&oid, "af7574ea73f7b166f869ef1a39be126d9a186ae0");
git_blob_lookup(&blob, repo, &oid); git_blob_lookup(&blob, repo, &oid);
// You can access a buffer with the raw contents of the blob directly. // You can access a buffer with the raw contents of the blob directly.
...@@ -308,7 +308,7 @@ int main (int argc, char** argv) ...@@ -308,7 +308,7 @@ int main (int argc, char** argv)
git_revwalk *walk; git_revwalk *walk;
git_commit *wcommit; git_commit *wcommit;
git_oid_mkstr(&oid, "f0877d0b841d75172ec404fc9370173dfffc20d1"); git_oid_fromstr(&oid, "f0877d0b841d75172ec404fc9370173dfffc20d1");
// To use the revwalker, create a new walker, tell it how you want to sort the output and then push // To use the revwalker, create a new walker, tell it how you want to sort the output and then push
// one or more starting points onto the walker. If you want to emulate the output of `git log` you // one or more starting points onto the walker. If you want to emulate the output of `git log` you
......
...@@ -61,14 +61,14 @@ typedef struct { ...@@ -61,14 +61,14 @@ typedef struct {
* needed for an oid encoded in hex (40 bytes). * needed for an oid encoded in hex (40 bytes).
* @return GIT_SUCCESS if valid; GIT_ENOTOID on failure. * @return GIT_SUCCESS if valid; GIT_ENOTOID on failure.
*/ */
GIT_EXTERN(int) git_oid_mkstr(git_oid *out, const char *str); GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
/** /**
* Copy an already raw oid into a git_oid structure. * Copy an already raw oid into a git_oid structure.
* @param out oid structure the result is written into. * @param out oid structure the result is written into.
* @param raw the raw input bytes to be copied. * @param raw the raw input bytes to be copied.
*/ */
GIT_EXTERN(void) git_oid_mkraw(git_oid *out, const unsigned char *raw); GIT_EXTERN(void) git_oid_fromraw(git_oid *out, const unsigned char *raw);
/** /**
* Format a git_oid into a hex string. * Format a git_oid into a hex string.
......
...@@ -582,7 +582,7 @@ static int read_tree_internal(git_index_tree **out, ...@@ -582,7 +582,7 @@ static int read_tree_internal(git_index_tree **out,
goto cleanup; goto cleanup;
} }
git_oid_mkraw(&tree->oid, (const unsigned char *)buffer); git_oid_fromraw(&tree->oid, (const unsigned char *)buffer);
buffer += GIT_OID_RAWSZ; buffer += GIT_OID_RAWSZ;
/* Parse children: */ /* Parse children: */
...@@ -670,7 +670,7 @@ static int read_unmerged(git_index *index, const char *buffer, size_t size) ...@@ -670,7 +670,7 @@ static int read_unmerged(git_index *index, const char *buffer, size_t size)
continue; continue;
if (size < 20) if (size < 20)
return git__throw(GIT_ERROR, "Failed to read unmerged entries"); return git__throw(GIT_ERROR, "Failed to read unmerged entries");
git_oid_mkraw(&lost->oid[i], (unsigned char *) buffer); git_oid_fromraw(&lost->oid[i], (unsigned char *) buffer);
size -= 20; size -= 20;
buffer += 20; buffer += 20;
} }
...@@ -867,7 +867,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size) ...@@ -867,7 +867,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse index. Buffer size does not match index footer size"); return git__throw(GIT_EOBJCORRUPTED, "Failed to parse index. Buffer size does not match index footer size");
/* 160-bit SHA-1 over the content of the index file before this checksum. */ /* 160-bit SHA-1 over the content of the index file before this checksum. */
git_oid_mkraw(&checksum_expected, (const unsigned char *)buffer); git_oid_fromraw(&checksum_expected, (const unsigned char *)buffer);
if (git_oid_cmp(&checksum_calculated, &checksum_expected) != 0) if (git_oid_cmp(&checksum_calculated, &checksum_expected) != 0)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse index. Calculated checksum does not match expected checksum"); return git__throw(GIT_EOBJCORRUPTED, "Failed to parse index. Calculated checksum does not match expected checksum");
......
...@@ -546,7 +546,7 @@ static int locate_object_short_oid(char *object_location, git_oid *res_oid, loos ...@@ -546,7 +546,7 @@ static int locate_object_short_oid(char *object_location, git_oid *res_oid, loos
} }
/* Convert obtained hex formatted oid to raw */ /* Convert obtained hex formatted oid to raw */
error = git_oid_mkstr(res_oid, (char *)state.res_oid); error = git_oid_fromstr(res_oid, (char *)state.res_oid);
if (error) { if (error) {
return git__rethrow(error, "Failed to locate object from short oid"); return git__rethrow(error, "Failed to locate object from short oid");
} }
......
...@@ -856,7 +856,7 @@ static int packfile_check(struct pack_file **pack_out, const char *path) ...@@ -856,7 +856,7 @@ static int packfile_check(struct pack_file **pack_out, const char *path)
/* see if we can parse the sha1 oid in the packfile name */ /* see if we can parse the sha1 oid in the packfile name */
if (path_len < 40 || if (path_len < 40 ||
git_oid_mkstr(&p->sha1, path + path_len - GIT_OID_HEXSZ) < GIT_SUCCESS) git_oid_fromstr(&p->sha1, path + path_len - GIT_OID_HEXSZ) < GIT_SUCCESS)
memset(&p->sha1, 0x0, GIT_OID_RAWSZ); memset(&p->sha1, 0x0, GIT_OID_RAWSZ);
*pack_out = p; *pack_out = p;
...@@ -1032,7 +1032,7 @@ static int pack_entry_find_offset( ...@@ -1032,7 +1032,7 @@ static int pack_entry_find_offset(
return git__throw(GIT_EAMBIGUOUSOIDPREFIX, "Failed to find offset for pack entry. Ambiguous sha1 prefix within pack"); return git__throw(GIT_EAMBIGUOUSOIDPREFIX, "Failed to find offset for pack entry. Ambiguous sha1 prefix within pack");
} else { } else {
*offset_out = nth_packed_object_offset(p, pos); *offset_out = nth_packed_object_offset(p, pos);
git_oid_mkraw(found_oid, current); git_oid_fromraw(found_oid, current);
#ifdef INDEX_DEBUG_LOOKUP #ifdef INDEX_DEBUG_LOOKUP
unsigned char hex_sha1[GIT_OID_HEXSZ + 1]; unsigned char hex_sha1[GIT_OID_HEXSZ + 1];
......
...@@ -49,7 +49,7 @@ static signed char from_hex[] = { ...@@ -49,7 +49,7 @@ static signed char from_hex[] = {
}; };
static char to_hex[] = "0123456789abcdef"; static char to_hex[] = "0123456789abcdef";
int git_oid_mkstr(git_oid *out, const char *str) int git_oid_fromstr(git_oid *out, const char *str)
{ {
size_t p; size_t p;
for (p = 0; p < sizeof(out->id); p++, str += 2) { for (p = 0; p < sizeof(out->id); p++, str += 2) {
...@@ -135,7 +135,7 @@ int git__parse_oid(git_oid *oid, const char **buffer_out, ...@@ -135,7 +135,7 @@ int git__parse_oid(git_oid *oid, const char **buffer_out,
if (buffer[header_len + sha_len] != '\n') if (buffer[header_len + sha_len] != '\n')
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse OID. Buffer not terminated correctly"); return git__throw(GIT_EOBJCORRUPTED, "Failed to parse OID. Buffer not terminated correctly");
if (git_oid_mkstr(oid, buffer + header_len) < GIT_SUCCESS) if (git_oid_fromstr(oid, buffer + header_len) < GIT_SUCCESS)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse OID. Failed to generate sha1"); return git__throw(GIT_EOBJCORRUPTED, "Failed to parse OID. Failed to generate sha1");
*buffer_out = buffer + (header_len + sha_len + 1); *buffer_out = buffer + (header_len + sha_len + 1);
...@@ -157,7 +157,7 @@ int git__write_oid(git_odb_stream *stream, const char *header, const git_oid *oi ...@@ -157,7 +157,7 @@ int git__write_oid(git_odb_stream *stream, const char *header, const git_oid *oi
return GIT_SUCCESS; return GIT_SUCCESS;
} }
void git_oid_mkraw(git_oid *out, const unsigned char *raw) void git_oid_fromraw(git_oid *out, const unsigned char *raw)
{ {
memcpy(out->id, raw, sizeof(out->id)); memcpy(out->id, raw, sizeof(out->id));
} }
......
...@@ -272,7 +272,7 @@ static int loose_parse_oid(git_reference *ref, gitfo_buf *file_content) ...@@ -272,7 +272,7 @@ static int loose_parse_oid(git_reference *ref, gitfo_buf *file_content)
return git__throw(GIT_EOBJCORRUPTED, return git__throw(GIT_EOBJCORRUPTED,
"Failed to parse loose reference. Reference too short"); "Failed to parse loose reference. Reference too short");
if ((error = git_oid_mkstr(&ref_oid->oid, buffer)) < GIT_SUCCESS) if ((error = git_oid_fromstr(&ref_oid->oid, buffer)) < GIT_SUCCESS)
return git__rethrow(GIT_EOBJCORRUPTED, "Failed to parse loose reference."); return git__rethrow(GIT_EOBJCORRUPTED, "Failed to parse loose reference.");
buffer = buffer + GIT_OID_HEXSZ; buffer = buffer + GIT_OID_HEXSZ;
...@@ -447,7 +447,7 @@ static int packed_parse_peel( ...@@ -447,7 +447,7 @@ static int packed_parse_peel(
return git__throw(GIT_EPACKEDREFSCORRUPTED, "Failed to parse packed reference. Buffer too small"); return git__throw(GIT_EPACKEDREFSCORRUPTED, "Failed to parse packed reference. Buffer too small");
/* Is this a valid object id? */ /* Is this a valid object id? */
if (git_oid_mkstr(&tag_ref->peel_target, buffer) < GIT_SUCCESS) if (git_oid_fromstr(&tag_ref->peel_target, buffer) < GIT_SUCCESS)
return git__throw(GIT_EPACKEDREFSCORRUPTED, "Failed to parse packed reference. Not a valid object ID"); return git__throw(GIT_EPACKEDREFSCORRUPTED, "Failed to parse packed reference. Not a valid object ID");
buffer = buffer + GIT_OID_HEXSZ; buffer = buffer + GIT_OID_HEXSZ;
...@@ -487,7 +487,7 @@ static int packed_parse_oid( ...@@ -487,7 +487,7 @@ static int packed_parse_oid(
} }
/* Is this a valid object id? */ /* Is this a valid object id? */
if ((error = git_oid_mkstr(&id, buffer)) < GIT_SUCCESS) if ((error = git_oid_fromstr(&id, buffer)) < GIT_SUCCESS)
goto cleanup; goto cleanup;
refname_end = memchr(refname_begin, '\n', buffer_end - refname_begin); refname_end = memchr(refname_begin, '\n', buffer_end - refname_begin);
......
...@@ -209,7 +209,7 @@ static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawo ...@@ -209,7 +209,7 @@ static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawo
for (i = 0; i < parents; ++i) { for (i = 0; i < parents; ++i) {
git_oid oid; git_oid oid;
if (git_oid_mkstr(&oid, (char *)buffer + STRLEN("parent ")) < GIT_SUCCESS) if (git_oid_fromstr(&oid, (char *)buffer + STRLEN("parent ")) < GIT_SUCCESS)
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse commit. Parent object is corrupted"); return git__throw(GIT_EOBJCORRUPTED, "Failed to parse commit. Parent object is corrupted");
commit->parents[i] = commit_lookup(walk, &oid); commit->parents[i] = commit_lookup(walk, &oid);
......
...@@ -183,7 +183,7 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf ...@@ -183,7 +183,7 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
buffer++; buffer++;
git_oid_mkraw(&entry->oid, (const unsigned char *)buffer); git_oid_fromraw(&entry->oid, (const unsigned char *)buffer);
buffer += GIT_OID_RAWSZ; buffer += GIT_OID_RAWSZ;
} }
......
...@@ -44,12 +44,12 @@ END_TEST ...@@ -44,12 +44,12 @@ END_TEST
BEGIN_TEST(oid1, "fail when parsing an empty string as oid") BEGIN_TEST(oid1, "fail when parsing an empty string as oid")
git_oid out; git_oid out;
must_fail(git_oid_mkstr(&out, "")); must_fail(git_oid_fromstr(&out, ""));
END_TEST END_TEST
BEGIN_TEST(oid2, "fail when parsing an invalid string as oid") BEGIN_TEST(oid2, "fail when parsing an invalid string as oid")
git_oid out; git_oid out;
must_fail(git_oid_mkstr(&out, "moo")); must_fail(git_oid_fromstr(&out, "moo"));
END_TEST END_TEST
static int from_hex(unsigned int i) static int from_hex(unsigned int i)
...@@ -79,17 +79,17 @@ BEGIN_TEST(oid3, "find all invalid characters when parsing an oid") ...@@ -79,17 +79,17 @@ BEGIN_TEST(oid3, "find all invalid characters when parsing an oid")
if (from_hex(i) >= 0) { if (from_hex(i) >= 0) {
exp[19] = (unsigned char)(from_hex(i) << 4); exp[19] = (unsigned char)(from_hex(i) << 4);
must_pass(git_oid_mkstr(&out, in)); must_pass(git_oid_fromstr(&out, in));
must_be_true(memcmp(out.id, exp, sizeof(out.id)) == 0); must_be_true(memcmp(out.id, exp, sizeof(out.id)) == 0);
} else { } else {
must_fail(git_oid_mkstr(&out, in)); must_fail(git_oid_fromstr(&out, in));
} }
} }
END_TEST END_TEST
BEGIN_TEST(oid4, "fail when parsing an invalid oid string") BEGIN_TEST(oid4, "fail when parsing an invalid oid string")
git_oid out; git_oid out;
must_fail(git_oid_mkstr(&out, "16a67770b7d8d72317c4b775213c23a8bd74f5ez")); must_fail(git_oid_fromstr(&out, "16a67770b7d8d72317c4b775213c23a8bd74f5ez"));
END_TEST END_TEST
BEGIN_TEST(oid5, "succeed when parsing a valid oid string") BEGIN_TEST(oid5, "succeed when parsing a valid oid string")
...@@ -101,10 +101,10 @@ BEGIN_TEST(oid5, "succeed when parsing a valid oid string") ...@@ -101,10 +101,10 @@ BEGIN_TEST(oid5, "succeed when parsing a valid oid string")
0xa8, 0xbd, 0x74, 0xf5, 0xe0, 0xa8, 0xbd, 0x74, 0xf5, 0xe0,
}; };
must_pass(git_oid_mkstr(&out, "16a67770b7d8d72317c4b775213c23a8bd74f5e0")); must_pass(git_oid_fromstr(&out, "16a67770b7d8d72317c4b775213c23a8bd74f5e0"));
must_pass(memcmp(out.id, exp, sizeof(out.id))); must_pass(memcmp(out.id, exp, sizeof(out.id)));
must_pass(git_oid_mkstr(&out, "16A67770B7D8D72317C4b775213C23A8BD74F5E0")); must_pass(git_oid_fromstr(&out, "16A67770B7D8D72317C4b775213C23A8BD74F5E0"));
must_pass(memcmp(out.id, exp, sizeof(out.id))); must_pass(memcmp(out.id, exp, sizeof(out.id)));
END_TEST END_TEST
...@@ -117,7 +117,7 @@ BEGIN_TEST(oid6, "build a valid oid from raw bytes") ...@@ -117,7 +117,7 @@ BEGIN_TEST(oid6, "build a valid oid from raw bytes")
0xa8, 0xbd, 0x74, 0xf5, 0xe0, 0xa8, 0xbd, 0x74, 0xf5, 0xe0,
}; };
git_oid_mkraw(&out, exp); git_oid_fromraw(&out, exp);
must_pass(memcmp(out.id, exp, sizeof(out.id))); must_pass(memcmp(out.id, exp, sizeof(out.id)));
END_TEST END_TEST
...@@ -131,7 +131,7 @@ BEGIN_TEST(oid7, "properly copy an oid to another") ...@@ -131,7 +131,7 @@ BEGIN_TEST(oid7, "properly copy an oid to another")
}; };
memset(&b, 0, sizeof(b)); memset(&b, 0, sizeof(b));
git_oid_mkraw(&a, exp); git_oid_fromraw(&a, exp);
git_oid_cpy(&b, &a); git_oid_cpy(&b, &a);
must_pass(memcmp(a.id, exp, sizeof(a.id))); must_pass(memcmp(a.id, exp, sizeof(a.id)));
END_TEST END_TEST
...@@ -151,8 +151,8 @@ BEGIN_TEST(oid8, "compare two oids (lesser than)") ...@@ -151,8 +151,8 @@ BEGIN_TEST(oid8, "compare two oids (lesser than)")
0xa8, 0xbd, 0x74, 0xf5, 0xf0, 0xa8, 0xbd, 0x74, 0xf5, 0xf0,
}; };
git_oid_mkraw(&a, a_in); git_oid_fromraw(&a, a_in);
git_oid_mkraw(&b, b_in); git_oid_fromraw(&b, b_in);
must_be_true(git_oid_cmp(&a, &b) < 0); must_be_true(git_oid_cmp(&a, &b) < 0);
END_TEST END_TEST
...@@ -165,8 +165,8 @@ BEGIN_TEST(oid9, "compare two oids (equal)") ...@@ -165,8 +165,8 @@ BEGIN_TEST(oid9, "compare two oids (equal)")
0xa8, 0xbd, 0x74, 0xf5, 0xe0, 0xa8, 0xbd, 0x74, 0xf5, 0xe0,
}; };
git_oid_mkraw(&a, a_in); git_oid_fromraw(&a, a_in);
git_oid_mkraw(&b, a_in); git_oid_fromraw(&b, a_in);
must_be_true(git_oid_cmp(&a, &b) == 0); must_be_true(git_oid_cmp(&a, &b) == 0);
END_TEST END_TEST
...@@ -185,8 +185,8 @@ BEGIN_TEST(oid10, "compare two oids (greater than)") ...@@ -185,8 +185,8 @@ BEGIN_TEST(oid10, "compare two oids (greater than)")
0xa8, 0xbd, 0x74, 0xf5, 0xd0, 0xa8, 0xbd, 0x74, 0xf5, 0xd0,
}; };
git_oid_mkraw(&a, a_in); git_oid_fromraw(&a, a_in);
git_oid_mkraw(&b, b_in); git_oid_fromraw(&b, b_in);
must_be_true(git_oid_cmp(&a, &b) > 0); must_be_true(git_oid_cmp(&a, &b) > 0);
END_TEST END_TEST
...@@ -195,7 +195,7 @@ BEGIN_TEST(oid11, "compare formated oids") ...@@ -195,7 +195,7 @@ BEGIN_TEST(oid11, "compare formated oids")
git_oid in; git_oid in;
char out[GIT_OID_HEXSZ + 1]; char out[GIT_OID_HEXSZ + 1];
must_pass(git_oid_mkstr(&in, exp)); must_pass(git_oid_fromstr(&in, exp));
/* Format doesn't touch the last byte */ /* Format doesn't touch the last byte */
out[GIT_OID_HEXSZ] = 'Z'; out[GIT_OID_HEXSZ] = 'Z';
...@@ -212,7 +212,7 @@ BEGIN_TEST(oid12, "compare oids (allocate + format)") ...@@ -212,7 +212,7 @@ BEGIN_TEST(oid12, "compare oids (allocate + format)")
git_oid in; git_oid in;
char *out; char *out;
must_pass(git_oid_mkstr(&in, exp)); must_pass(git_oid_fromstr(&in, exp));
out = git_oid_allocfmt(&in); out = git_oid_allocfmt(&in);
must_be_true(out); must_be_true(out);
...@@ -226,7 +226,7 @@ BEGIN_TEST(oid13, "compare oids (path format)") ...@@ -226,7 +226,7 @@ BEGIN_TEST(oid13, "compare oids (path format)")
git_oid in; git_oid in;
char out[GIT_OID_HEXSZ + 2]; char out[GIT_OID_HEXSZ + 2];
must_pass(git_oid_mkstr(&in, exp1)); must_pass(git_oid_fromstr(&in, exp1));
/* Format doesn't touch the last byte */ /* Format doesn't touch the last byte */
out[GIT_OID_HEXSZ + 1] = 'Z'; out[GIT_OID_HEXSZ + 1] = 'Z';
...@@ -245,7 +245,7 @@ BEGIN_TEST(oid14, "convert raw oid to string") ...@@ -245,7 +245,7 @@ BEGIN_TEST(oid14, "convert raw oid to string")
char *str; char *str;
int i; int i;
must_pass(git_oid_mkstr(&in, exp)); must_pass(git_oid_fromstr(&in, exp));
/* NULL buffer pointer, returns static empty string */ /* NULL buffer pointer, returns static empty string */
str = git_oid_to_string(NULL, sizeof(out), &in); str = git_oid_to_string(NULL, sizeof(out), &in);
...@@ -288,7 +288,7 @@ BEGIN_TEST(oid15, "convert raw oid to string (big)") ...@@ -288,7 +288,7 @@ BEGIN_TEST(oid15, "convert raw oid to string (big)")
char big[GIT_OID_HEXSZ + 1 + 3]; /* note + 4 => big buffer */ char big[GIT_OID_HEXSZ + 1 + 3]; /* note + 4 => big buffer */
char *str; char *str;
must_pass(git_oid_mkstr(&in, exp)); must_pass(git_oid_fromstr(&in, exp));
/* place some tail material */ /* place some tail material */
big[GIT_OID_HEXSZ+0] = 'W'; /* should be '\0' afterwards */ big[GIT_OID_HEXSZ+0] = 'W'; /* should be '\0' afterwards */
...@@ -412,14 +412,14 @@ BEGIN_TEST(hash0, "normal hash by blocks") ...@@ -412,14 +412,14 @@ BEGIN_TEST(hash0, "normal hash by blocks")
/* should already be init'd */ /* should already be init'd */
git_hash_update(ctx, hello_text, strlen(hello_text)); git_hash_update(ctx, hello_text, strlen(hello_text));
git_hash_final(&id2, ctx); git_hash_final(&id2, ctx);
must_pass(git_oid_mkstr(&id1, hello_id)); must_pass(git_oid_fromstr(&id1, hello_id));
must_be_true(git_oid_cmp(&id1, &id2) == 0); must_be_true(git_oid_cmp(&id1, &id2) == 0);
/* reinit should permit reuse */ /* reinit should permit reuse */
git_hash_init(ctx); git_hash_init(ctx);
git_hash_update(ctx, bye_text, strlen(bye_text)); git_hash_update(ctx, bye_text, strlen(bye_text));
git_hash_final(&id2, ctx); git_hash_final(&id2, ctx);
must_pass(git_oid_mkstr(&id1, bye_id)); must_pass(git_oid_fromstr(&id1, bye_id));
must_be_true(git_oid_cmp(&id1, &id2) == 0); must_be_true(git_oid_cmp(&id1, &id2) == 0);
git_hash_free_ctx(ctx); git_hash_free_ctx(ctx);
...@@ -428,7 +428,7 @@ END_TEST ...@@ -428,7 +428,7 @@ END_TEST
BEGIN_TEST(hash1, "hash whole buffer in a single call") BEGIN_TEST(hash1, "hash whole buffer in a single call")
git_oid id1, id2; git_oid id1, id2;
must_pass(git_oid_mkstr(&id1, hello_id)); must_pass(git_oid_fromstr(&id1, hello_id));
git_hash_buf(&id2, hello_text, strlen(hello_text)); git_hash_buf(&id2, hello_text, strlen(hello_text));
...@@ -439,7 +439,7 @@ BEGIN_TEST(hash2, "hash a vector") ...@@ -439,7 +439,7 @@ BEGIN_TEST(hash2, "hash a vector")
git_oid id1, id2; git_oid id1, id2;
git_buf_vec vec[2]; git_buf_vec vec[2];
must_pass(git_oid_mkstr(&id1, hello_id)); must_pass(git_oid_fromstr(&id1, hello_id));
vec[0].data = hello_text; vec[0].data = hello_text;
vec[0].len = 4; vec[0].len = 4;
...@@ -500,7 +500,7 @@ END_TEST ...@@ -500,7 +500,7 @@ END_TEST
BEGIN_TEST(objhash0, "hash junk data") BEGIN_TEST(objhash0, "hash junk data")
git_oid id, id_zero; git_oid id, id_zero;
must_pass(git_oid_mkstr(&id_zero, zero_id)); must_pass(git_oid_fromstr(&id_zero, zero_id));
/* invalid types: */ /* invalid types: */
junk_obj.data = some_data; junk_obj.data = some_data;
...@@ -531,7 +531,7 @@ END_TEST ...@@ -531,7 +531,7 @@ END_TEST
BEGIN_TEST(objhash1, "hash a commit object") BEGIN_TEST(objhash1, "hash a commit object")
git_oid id1, id2; git_oid id1, id2;
must_pass(git_oid_mkstr(&id1, commit_id)); must_pass(git_oid_fromstr(&id1, commit_id));
must_pass(hash_object(&id2, &commit_obj)); must_pass(hash_object(&id2, &commit_obj));
...@@ -541,7 +541,7 @@ END_TEST ...@@ -541,7 +541,7 @@ END_TEST
BEGIN_TEST(objhash2, "hash a tree object") BEGIN_TEST(objhash2, "hash a tree object")
git_oid id1, id2; git_oid id1, id2;
must_pass(git_oid_mkstr(&id1, tree_id)); must_pass(git_oid_fromstr(&id1, tree_id));
must_pass(hash_object(&id2, &tree_obj)); must_pass(hash_object(&id2, &tree_obj));
...@@ -551,7 +551,7 @@ END_TEST ...@@ -551,7 +551,7 @@ END_TEST
BEGIN_TEST(objhash3, "hash a tag object") BEGIN_TEST(objhash3, "hash a tag object")
git_oid id1, id2; git_oid id1, id2;
must_pass(git_oid_mkstr(&id1, tag_id)); must_pass(git_oid_fromstr(&id1, tag_id));
must_pass(hash_object(&id2, &tag_obj)); must_pass(hash_object(&id2, &tag_obj));
...@@ -561,7 +561,7 @@ END_TEST ...@@ -561,7 +561,7 @@ END_TEST
BEGIN_TEST(objhash4, "hash a zero-length object") BEGIN_TEST(objhash4, "hash a zero-length object")
git_oid id1, id2; git_oid id1, id2;
must_pass(git_oid_mkstr(&id1, zero_id)); must_pass(git_oid_fromstr(&id1, zero_id));
must_pass(hash_object(&id2, &zero_obj)); must_pass(hash_object(&id2, &zero_obj));
...@@ -571,7 +571,7 @@ END_TEST ...@@ -571,7 +571,7 @@ END_TEST
BEGIN_TEST(objhash5, "hash an one-byte long object") BEGIN_TEST(objhash5, "hash an one-byte long object")
git_oid id1, id2; git_oid id1, id2;
must_pass(git_oid_mkstr(&id1, one_id)); must_pass(git_oid_fromstr(&id1, one_id));
must_pass(hash_object(&id2, &one_obj)); must_pass(hash_object(&id2, &one_obj));
...@@ -581,7 +581,7 @@ END_TEST ...@@ -581,7 +581,7 @@ END_TEST
BEGIN_TEST(objhash6, "hash a two-byte long object") BEGIN_TEST(objhash6, "hash a two-byte long object")
git_oid id1, id2; git_oid id1, id2;
must_pass(git_oid_mkstr(&id1, two_id)); must_pass(git_oid_fromstr(&id1, two_id));
must_pass(hash_object(&id2, &two_obj)); must_pass(hash_object(&id2, &two_obj));
...@@ -591,7 +591,7 @@ END_TEST ...@@ -591,7 +591,7 @@ END_TEST
BEGIN_TEST(objhash7, "hash an object several bytes long") BEGIN_TEST(objhash7, "hash an object several bytes long")
git_oid id1, id2; git_oid id1, id2;
must_pass(git_oid_mkstr(&id1, some_id)); must_pass(git_oid_fromstr(&id1, some_id));
must_pass(hash_object(&id2, &some_obj)); must_pass(hash_object(&id2, &some_obj));
......
...@@ -36,12 +36,12 @@ BEGIN_TEST(existsloose0, "check if a loose object exists on the odb") ...@@ -36,12 +36,12 @@ BEGIN_TEST(existsloose0, "check if a loose object exists on the odb")
must_pass(write_object_files(odb_dir, &one)); must_pass(write_object_files(odb_dir, &one));
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id, one.id)); must_pass(git_oid_fromstr(&id, one.id));
must_be_true(git_odb_exists(db, &id)); must_be_true(git_odb_exists(db, &id));
/* Test for a non-existant object */ /* Test for a non-existant object */
must_pass(git_oid_mkstr(&id2, "8b137891791fe96927ad78e64b0aad7bded08baa")); must_pass(git_oid_fromstr(&id2, "8b137891791fe96927ad78e64b0aad7bded08baa"));
must_be_true(0 == git_odb_exists(db, &id2)); must_be_true(0 == git_odb_exists(db, &id2));
git_odb_close(db); git_odb_close(db);
...@@ -55,7 +55,7 @@ BEGIN_TEST(readloose0, "read a loose commit") ...@@ -55,7 +55,7 @@ BEGIN_TEST(readloose0, "read a loose commit")
must_pass(write_object_files(odb_dir, &commit)); must_pass(write_object_files(odb_dir, &commit));
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id, commit.id)); must_pass(git_oid_fromstr(&id, commit.id));
must_pass(git_odb_read(&obj, db, &id)); must_pass(git_odb_read(&obj, db, &id));
must_pass(cmp_objects((git_rawobj *)&obj->raw, &commit)); must_pass(cmp_objects((git_rawobj *)&obj->raw, &commit));
...@@ -72,7 +72,7 @@ BEGIN_TEST(readloose1, "read a loose tree") ...@@ -72,7 +72,7 @@ BEGIN_TEST(readloose1, "read a loose tree")
must_pass(write_object_files(odb_dir, &tree)); must_pass(write_object_files(odb_dir, &tree));
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id, tree.id)); must_pass(git_oid_fromstr(&id, tree.id));
must_pass(git_odb_read(&obj, db, &id)); must_pass(git_odb_read(&obj, db, &id));
must_pass(cmp_objects((git_rawobj *)&obj->raw, &tree)); must_pass(cmp_objects((git_rawobj *)&obj->raw, &tree));
...@@ -89,7 +89,7 @@ BEGIN_TEST(readloose2, "read a loose tag") ...@@ -89,7 +89,7 @@ BEGIN_TEST(readloose2, "read a loose tag")
must_pass(write_object_files(odb_dir, &tag)); must_pass(write_object_files(odb_dir, &tag));
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id, tag.id)); must_pass(git_oid_fromstr(&id, tag.id));
must_pass(git_odb_read(&obj, db, &id)); must_pass(git_odb_read(&obj, db, &id));
must_pass(cmp_objects((git_rawobj *)&obj->raw, &tag)); must_pass(cmp_objects((git_rawobj *)&obj->raw, &tag));
...@@ -106,7 +106,7 @@ BEGIN_TEST(readloose3, "read a loose zero-bytes object") ...@@ -106,7 +106,7 @@ BEGIN_TEST(readloose3, "read a loose zero-bytes object")
must_pass(write_object_files(odb_dir, &zero)); must_pass(write_object_files(odb_dir, &zero));
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id, zero.id)); must_pass(git_oid_fromstr(&id, zero.id));
must_pass(git_odb_read(&obj, db, &id)); must_pass(git_odb_read(&obj, db, &id));
must_pass(cmp_objects((git_rawobj *)&obj->raw, &zero)); must_pass(cmp_objects((git_rawobj *)&obj->raw, &zero));
...@@ -123,7 +123,7 @@ BEGIN_TEST(readloose4, "read a one-byte long loose object") ...@@ -123,7 +123,7 @@ BEGIN_TEST(readloose4, "read a one-byte long loose object")
must_pass(write_object_files(odb_dir, &one)); must_pass(write_object_files(odb_dir, &one));
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id, one.id)); must_pass(git_oid_fromstr(&id, one.id));
must_pass(git_odb_read(&obj, db, &id)); must_pass(git_odb_read(&obj, db, &id));
must_pass(cmp_objects(&obj->raw, &one)); must_pass(cmp_objects(&obj->raw, &one));
...@@ -140,7 +140,7 @@ BEGIN_TEST(readloose5, "read a two-bytes long loose object") ...@@ -140,7 +140,7 @@ BEGIN_TEST(readloose5, "read a two-bytes long loose object")
must_pass(write_object_files(odb_dir, &two)); must_pass(write_object_files(odb_dir, &two));
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id, two.id)); must_pass(git_oid_fromstr(&id, two.id));
must_pass(git_odb_read(&obj, db, &id)); must_pass(git_odb_read(&obj, db, &id));
must_pass(cmp_objects(&obj->raw, &two)); must_pass(cmp_objects(&obj->raw, &two));
...@@ -157,7 +157,7 @@ BEGIN_TEST(readloose6, "read a loose object which is several bytes long") ...@@ -157,7 +157,7 @@ BEGIN_TEST(readloose6, "read a loose object which is several bytes long")
must_pass(write_object_files(odb_dir, &some)); must_pass(write_object_files(odb_dir, &some));
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id, some.id)); must_pass(git_oid_fromstr(&id, some.id));
must_pass(git_odb_read(&obj, db, &id)); must_pass(git_odb_read(&obj, db, &id));
must_pass(cmp_objects(&obj->raw, &some)); must_pass(cmp_objects(&obj->raw, &some));
...@@ -177,7 +177,7 @@ BEGIN_TEST(readpack0, "read several packed objects") ...@@ -177,7 +177,7 @@ BEGIN_TEST(readpack0, "read several packed objects")
git_oid id; git_oid id;
git_odb_object *obj; git_odb_object *obj;
must_pass(git_oid_mkstr(&id, packed_objects[i])); must_pass(git_oid_fromstr(&id, packed_objects[i]));
must_be_true(git_odb_exists(db, &id) == 1); must_be_true(git_odb_exists(db, &id) == 1);
must_pass(git_odb_read(&obj, db, &id)); must_pass(git_odb_read(&obj, db, &id));
...@@ -199,7 +199,7 @@ BEGIN_TEST(readheader0, "read only the header of several packed objects") ...@@ -199,7 +199,7 @@ BEGIN_TEST(readheader0, "read only the header of several packed objects")
size_t len; size_t len;
git_otype type; git_otype type;
must_pass(git_oid_mkstr(&id, packed_objects[i])); must_pass(git_oid_fromstr(&id, packed_objects[i]));
must_pass(git_odb_read(&obj, db, &id)); must_pass(git_odb_read(&obj, db, &id));
must_pass(git_odb_read_header(&len, &type, db, &id)); must_pass(git_odb_read_header(&len, &type, db, &id));
...@@ -225,7 +225,7 @@ BEGIN_TEST(readheader1, "read only the header of several loose objects") ...@@ -225,7 +225,7 @@ BEGIN_TEST(readheader1, "read only the header of several loose objects")
size_t len; size_t len;
git_otype type; git_otype type;
must_pass(git_oid_mkstr(&id, loose_objects[i])); must_pass(git_oid_fromstr(&id, loose_objects[i]));
must_be_true(git_odb_exists(db, &id) == 1); must_be_true(git_odb_exists(db, &id) == 1);
......
...@@ -104,7 +104,7 @@ BEGIN_TEST(write0, "write loose commit object") ...@@ -104,7 +104,7 @@ BEGIN_TEST(write0, "write loose commit object")
must_pass(make_odb_dir()); must_pass(make_odb_dir());
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id1, commit.id)); must_pass(git_oid_fromstr(&id1, commit.id));
must_pass(streaming_write(&id2, db, &commit_obj)); must_pass(streaming_write(&id2, db, &commit_obj));
must_be_true(git_oid_cmp(&id1, &id2) == 0); must_be_true(git_oid_cmp(&id1, &id2) == 0);
...@@ -125,7 +125,7 @@ BEGIN_TEST(write1, "write loose tree object") ...@@ -125,7 +125,7 @@ BEGIN_TEST(write1, "write loose tree object")
must_pass(make_odb_dir()); must_pass(make_odb_dir());
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id1, tree.id)); must_pass(git_oid_fromstr(&id1, tree.id));
must_pass(streaming_write(&id2, db, &tree_obj)); must_pass(streaming_write(&id2, db, &tree_obj));
must_be_true(git_oid_cmp(&id1, &id2) == 0); must_be_true(git_oid_cmp(&id1, &id2) == 0);
...@@ -146,7 +146,7 @@ BEGIN_TEST(write2, "write loose tag object") ...@@ -146,7 +146,7 @@ BEGIN_TEST(write2, "write loose tag object")
must_pass(make_odb_dir()); must_pass(make_odb_dir());
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id1, tag.id)); must_pass(git_oid_fromstr(&id1, tag.id));
must_pass(streaming_write(&id2, db, &tag_obj)); must_pass(streaming_write(&id2, db, &tag_obj));
must_be_true(git_oid_cmp(&id1, &id2) == 0); must_be_true(git_oid_cmp(&id1, &id2) == 0);
...@@ -167,7 +167,7 @@ BEGIN_TEST(write3, "write zero-length object") ...@@ -167,7 +167,7 @@ BEGIN_TEST(write3, "write zero-length object")
must_pass(make_odb_dir()); must_pass(make_odb_dir());
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id1, zero.id)); must_pass(git_oid_fromstr(&id1, zero.id));
must_pass(streaming_write(&id2, db, &zero_obj)); must_pass(streaming_write(&id2, db, &zero_obj));
must_be_true(git_oid_cmp(&id1, &id2) == 0); must_be_true(git_oid_cmp(&id1, &id2) == 0);
...@@ -188,7 +188,7 @@ BEGIN_TEST(write4, "write one-byte long object") ...@@ -188,7 +188,7 @@ BEGIN_TEST(write4, "write one-byte long object")
must_pass(make_odb_dir()); must_pass(make_odb_dir());
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id1, one.id)); must_pass(git_oid_fromstr(&id1, one.id));
must_pass(streaming_write(&id2, db, &one_obj)); must_pass(streaming_write(&id2, db, &one_obj));
must_be_true(git_oid_cmp(&id1, &id2) == 0); must_be_true(git_oid_cmp(&id1, &id2) == 0);
...@@ -209,7 +209,7 @@ BEGIN_TEST(write5, "write two-byte long object") ...@@ -209,7 +209,7 @@ BEGIN_TEST(write5, "write two-byte long object")
must_pass(make_odb_dir()); must_pass(make_odb_dir());
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id1, two.id)); must_pass(git_oid_fromstr(&id1, two.id));
must_pass(streaming_write(&id2, db, &two_obj)); must_pass(streaming_write(&id2, db, &two_obj));
must_be_true(git_oid_cmp(&id1, &id2) == 0); must_be_true(git_oid_cmp(&id1, &id2) == 0);
...@@ -230,7 +230,7 @@ BEGIN_TEST(write6, "write an object which is several bytes long") ...@@ -230,7 +230,7 @@ BEGIN_TEST(write6, "write an object which is several bytes long")
must_pass(make_odb_dir()); must_pass(make_odb_dir());
must_pass(git_odb_open(&db, odb_dir)); must_pass(git_odb_open(&db, odb_dir));
must_pass(git_oid_mkstr(&id1, some.id)); must_pass(git_oid_fromstr(&id1, some.id));
must_pass(streaming_write(&id2, db, &some_obj)); must_pass(streaming_write(&id2, db, &some_obj));
must_be_true(git_oid_cmp(&id1, &id2) == 0); must_be_true(git_oid_cmp(&id1, &id2) == 0);
......
...@@ -370,7 +370,7 @@ BEGIN_TEST(details0, "query the details on a parsed commit") ...@@ -370,7 +370,7 @@ BEGIN_TEST(details0, "query the details on a parsed commit")
unsigned int parents, p; unsigned int parents, p;
git_commit *parent = NULL, *old_parent = NULL; git_commit *parent = NULL, *old_parent = NULL;
git_oid_mkstr(&id, commit_ids[i]); git_oid_fromstr(&id, commit_ids[i]);
must_pass(git_commit_lookup(&commit, repo, &id)); must_pass(git_commit_lookup(&commit, repo, &id));
...@@ -426,8 +426,8 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk") ...@@ -426,8 +426,8 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk")
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&tree_id, tree_oid); git_oid_fromstr(&tree_id, tree_oid);
git_oid_mkstr(&parent_id, commit_ids[4]); git_oid_fromstr(&parent_id, commit_ids[4]);
/* create signatures */ /* create signatures */
committer = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 123456789, 60); committer = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 123456789, 60);
...@@ -489,7 +489,7 @@ BEGIN_TEST(root0, "create a root commit") ...@@ -489,7 +489,7 @@ BEGIN_TEST(root0, "create a root commit")
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&tree_id, tree_oid); git_oid_fromstr(&tree_id, tree_oid);
/* create signatures */ /* create signatures */
committer = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 123456789, 60); committer = git_signature_new(COMMITTER_NAME, COMMITTER_EMAIL, 123456789, 60);
......
...@@ -124,7 +124,7 @@ BEGIN_TEST(walk0, "do a simple walk on a repo with different sorting modes") ...@@ -124,7 +124,7 @@ BEGIN_TEST(walk0, "do a simple walk on a repo with different sorting modes")
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
must_pass(git_revwalk_new(&walk, repo)); must_pass(git_revwalk_new(&walk, repo));
git_oid_mkstr(&id, commit_head); git_oid_fromstr(&id, commit_head);
must_pass(test_walk(walk, &id, GIT_SORT_TIME, commit_sorting_time, 1)); must_pass(test_walk(walk, &id, GIT_SORT_TIME, commit_sorting_time, 1));
must_pass(test_walk(walk, &id, GIT_SORT_TOPOLOGICAL, commit_sorting_topo, 2)); must_pass(test_walk(walk, &id, GIT_SORT_TOPOLOGICAL, commit_sorting_topo, 2));
......
...@@ -196,7 +196,7 @@ BEGIN_TEST(add0, "add a new file to the index") ...@@ -196,7 +196,7 @@ BEGIN_TEST(add0, "add a new file to the index")
* This has been generated by executing the following * This has been generated by executing the following
* $ echo "hey there" | git hash-object --stdin * $ echo "hey there" | git hash-object --stdin
*/ */
must_pass(git_oid_mkstr(&id1, "a8233120f6ad708f843d861ce2b7228ec4e3dec6")); must_pass(git_oid_fromstr(&id1, "a8233120f6ad708f843d861ce2b7228ec4e3dec6"));
/* Add the new file to the index */ /* Add the new file to the index */
must_pass(git_index_add(index, "test.txt", 0)); must_pass(git_index_add(index, "test.txt", 0));
......
...@@ -39,9 +39,9 @@ BEGIN_TEST(read0, "read and parse a tag from the repository") ...@@ -39,9 +39,9 @@ BEGIN_TEST(read0, "read and parse a tag from the repository")
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id1, tag1_id); git_oid_fromstr(&id1, tag1_id);
git_oid_mkstr(&id2, tag2_id); git_oid_fromstr(&id2, tag2_id);
git_oid_mkstr(&id_commit, tagged_commit); git_oid_fromstr(&id_commit, tagged_commit);
must_pass(git_tag_lookup(&tag1, repo, &id1)); must_pass(git_tag_lookup(&tag1, repo, &id1));
...@@ -91,7 +91,7 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again") ...@@ -91,7 +91,7 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again")
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&target_id, tagged_commit); git_oid_fromstr(&target_id, tagged_commit);
/* create signature */ /* create signature */
tagger = git_signature_new(TAGGER_NAME, TAGGER_EMAIL, 123456789, 60); tagger = git_signature_new(TAGGER_NAME, TAGGER_EMAIL, 123456789, 60);
...@@ -139,7 +139,7 @@ BEGIN_TEST(write1, "write a tag to the repository which points to an unknown oid ...@@ -139,7 +139,7 @@ BEGIN_TEST(write1, "write a tag to the repository which points to an unknown oid
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&target_id, "deadbeef1b46c854b31185ea97743be6a8774479"); git_oid_fromstr(&target_id, "deadbeef1b46c854b31185ea97743be6a8774479");
/* create signature */ /* create signature */
tagger = git_signature_new(TAGGER_NAME, TAGGER_EMAIL, 123456789, 60); tagger = git_signature_new(TAGGER_NAME, TAGGER_EMAIL, 123456789, 60);
...@@ -167,7 +167,7 @@ BEGIN_TEST(write2, "Attempt to write a tag bearing the same name than an already ...@@ -167,7 +167,7 @@ BEGIN_TEST(write2, "Attempt to write a tag bearing the same name than an already
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&target_id, tagged_commit); git_oid_fromstr(&target_id, tagged_commit);
/* create signature */ /* create signature */
tagger = git_signature_new(TAGGER_NAME, TAGGER_EMAIL, 123456789, 60); tagger = git_signature_new(TAGGER_NAME, TAGGER_EMAIL, 123456789, 60);
...@@ -196,7 +196,7 @@ BEGIN_TEST(write3, "Replace an already existing tag") ...@@ -196,7 +196,7 @@ BEGIN_TEST(write3, "Replace an already existing tag")
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&target_id, tagged_commit); git_oid_fromstr(&target_id, tagged_commit);
must_pass(git_reference_lookup(&ref_tag, repo, "refs/tags/e90810b")); must_pass(git_reference_lookup(&ref_tag, repo, "refs/tags/e90810b"));
git_oid_cpy(&old_tag_id, git_reference_oid(ref_tag)); git_oid_cpy(&old_tag_id, git_reference_oid(ref_tag));
......
...@@ -71,7 +71,7 @@ BEGIN_TEST(read0, "acces randomly the entries on a loaded tree") ...@@ -71,7 +71,7 @@ BEGIN_TEST(read0, "acces randomly the entries on a loaded tree")
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, tree_oid); git_oid_fromstr(&id, tree_oid);
must_pass(git_tree_lookup(&tree, repo, &id)); must_pass(git_tree_lookup(&tree, repo, &id));
...@@ -96,7 +96,7 @@ BEGIN_TEST(read1, "read a tree from the repository") ...@@ -96,7 +96,7 @@ BEGIN_TEST(read1, "read a tree from the repository")
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, tree_oid); git_oid_fromstr(&id, tree_oid);
must_pass(git_tree_lookup(&tree, repo, &id)); must_pass(git_tree_lookup(&tree, repo, &id));
...@@ -143,9 +143,9 @@ BEGIN_TEST(write2, "write a tree from a memory") ...@@ -143,9 +143,9 @@ BEGIN_TEST(write2, "write a tree from a memory")
git_oid id, bid, rid, id2; git_oid id, bid, rid, id2;
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, first_tree); git_oid_fromstr(&id, first_tree);
git_oid_mkstr(&id2, second_tree); git_oid_fromstr(&id2, second_tree);
git_oid_mkstr(&bid, blob_oid); git_oid_fromstr(&bid, blob_oid);
//create a second tree from first tree using `git_treebuilder_insert` on REPOSITORY_FOLDER. //create a second tree from first tree using `git_treebuilder_insert` on REPOSITORY_FOLDER.
must_pass(git_tree_lookup(&tree, repo, &id)); must_pass(git_tree_lookup(&tree, repo, &id));
...@@ -168,10 +168,10 @@ BEGIN_TEST(write3, "write a hierarchical tree from a memory") ...@@ -168,10 +168,10 @@ BEGIN_TEST(write3, "write a hierarchical tree from a memory")
git_oid id_hiearar; git_oid id_hiearar;
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
git_oid_mkstr(&id, first_tree); git_oid_fromstr(&id, first_tree);
git_oid_mkstr(&id2, second_tree); git_oid_fromstr(&id2, second_tree);
git_oid_mkstr(&id3, third_tree); git_oid_fromstr(&id3, third_tree);
git_oid_mkstr(&bid, blob_oid); git_oid_fromstr(&bid, blob_oid);
//create subtree //create subtree
must_pass(git_treebuilder_create(&builder, NULL)); must_pass(git_treebuilder_create(&builder, NULL));
......
...@@ -89,7 +89,7 @@ BEGIN_TEST(readsym0, "lookup a symbolic reference") ...@@ -89,7 +89,7 @@ BEGIN_TEST(readsym0, "lookup a symbolic reference")
must_be_true(object != NULL); must_be_true(object != NULL);
must_be_true(git_object_type(object) == GIT_OBJ_COMMIT); must_be_true(git_object_type(object) == GIT_OBJ_COMMIT);
git_oid_mkstr(&id, current_master_tip); git_oid_fromstr(&id, current_master_tip);
must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0); must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0);
git_object_close(object); git_object_close(object);
...@@ -116,7 +116,7 @@ BEGIN_TEST(readsym1, "lookup a nested symbolic reference") ...@@ -116,7 +116,7 @@ BEGIN_TEST(readsym1, "lookup a nested symbolic reference")
must_be_true(object != NULL); must_be_true(object != NULL);
must_be_true(git_object_type(object) == GIT_OBJ_COMMIT); must_be_true(git_object_type(object) == GIT_OBJ_COMMIT);
git_oid_mkstr(&id, current_master_tip); git_oid_fromstr(&id, current_master_tip);
must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0); must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0);
git_object_close(object); git_object_close(object);
...@@ -204,7 +204,7 @@ BEGIN_TEST(create0, "create a new symbolic reference") ...@@ -204,7 +204,7 @@ BEGIN_TEST(create0, "create a new symbolic reference")
const char *new_head_tracker = "another-head-tracker"; const char *new_head_tracker = "another-head-tracker";
git_oid_mkstr(&id, current_master_tip); git_oid_fromstr(&id, current_master_tip);
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
...@@ -247,7 +247,7 @@ BEGIN_TEST(create1, "create a deep symbolic reference") ...@@ -247,7 +247,7 @@ BEGIN_TEST(create1, "create a deep symbolic reference")
const char *new_head_tracker = "deep/rooted/tracker"; const char *new_head_tracker = "deep/rooted/tracker";
git_oid_mkstr(&id, current_master_tip); git_oid_fromstr(&id, current_master_tip);
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
...@@ -268,7 +268,7 @@ BEGIN_TEST(create2, "create a new OID reference") ...@@ -268,7 +268,7 @@ BEGIN_TEST(create2, "create a new OID reference")
const char *new_head = "refs/heads/new-head"; const char *new_head = "refs/heads/new-head";
git_oid_mkstr(&id, current_master_tip); git_oid_fromstr(&id, current_master_tip);
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER)); must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
...@@ -305,7 +305,7 @@ BEGIN_TEST(create3, "Can not create a new OID reference which targets at an unkn ...@@ -305,7 +305,7 @@ BEGIN_TEST(create3, "Can not create a new OID reference which targets at an unkn
const char *new_head = "refs/heads/new-head"; const char *new_head = "refs/heads/new-head";
git_oid_mkstr(&id, "deadbeef3f795b2b4353bcce3a527ad0a4f7f644"); git_oid_fromstr(&id, "deadbeef3f795b2b4353bcce3a527ad0a4f7f644");
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER)); must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
......
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