oid: GIT_OID_*SZ is now GIT_OID_SHA1_*SIZE

In preparation for SHA256 support, `GIT_OID_RAWSZ` and `GIT_OID_HEXSZ`
need to indicate that they're the size of _SHA1_ OIDs.
This commit is contained in:
Edward Thomson
2022-01-22 23:10:03 -05:00
parent f98dd5438f
commit dbc4ac1c76
81 changed files with 355 additions and 355 deletions

View File

@@ -49,7 +49,7 @@ static void show_blob(const git_blob *blob)
static void show_tree(const git_tree *tree)
{
size_t i, max_i = (int)git_tree_entrycount(tree);
char oidstr[GIT_OID_HEXSZ + 1];
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
const git_tree_entry *te;
for (i = 0; i < max_i; ++i) {
@@ -70,7 +70,7 @@ static void show_tree(const git_tree *tree)
static void show_commit(const git_commit *commit)
{
unsigned int i, max_i;
char oidstr[GIT_OID_HEXSZ + 1];
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
git_oid_tostr(oidstr, sizeof(oidstr), git_commit_tree_id(commit));
printf("tree %s\n", oidstr);
@@ -90,7 +90,7 @@ static void show_commit(const git_commit *commit)
static void show_tag(const git_tag *tag)
{
char oidstr[GIT_OID_HEXSZ + 1];
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
git_oid_tostr(oidstr, sizeof(oidstr), git_tag_target_id(tag));;
printf("object %s\n", oidstr);
@@ -125,7 +125,7 @@ int lg2_cat_file(git_repository *repo, int argc, char *argv[])
{
struct catfile_options o = { ".", NULL, 0, 0 };
git_object *obj = NULL;
char oidstr[GIT_OID_HEXSZ + 1];
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
parse_opts(&o, argc, argv);
@@ -133,7 +133,7 @@ int lg2_cat_file(git_repository *repo, int argc, char *argv[])
"Could not resolve", o.rev);
if (o.verbose) {
char oidstr[GIT_OID_HEXSZ + 1];
char oidstr[GIT_OID_SHA1_HEXSIZE + 1];
git_oid_tostr(oidstr, sizeof(oidstr), git_object_id(obj));
printf("%s %s\n--\n",

View File

@@ -15,17 +15,17 @@ static int progress_cb(const char *str, int len, void *data)
*/
static int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data)
{
char a_str[GIT_OID_HEXSZ+1], b_str[GIT_OID_HEXSZ+1];
char a_str[GIT_OID_SHA1_HEXSIZE+1], b_str[GIT_OID_SHA1_HEXSIZE+1];
(void)data;
git_oid_fmt(b_str, b);
b_str[GIT_OID_HEXSZ] = '\0';
b_str[GIT_OID_SHA1_HEXSIZE] = '\0';
if (git_oid_is_zero(a)) {
printf("[new] %.20s %s\n", b_str, refname);
} else {
git_oid_fmt(a_str, a);
a_str[GIT_OID_HEXSZ] = '\0';
a_str[GIT_OID_SHA1_HEXSIZE] = '\0';
printf("[updated] %.10s..%.10s %s\n", a_str, b_str, refname);
}

View File

@@ -5,7 +5,7 @@ static int show_ref(git_reference *ref, void *data)
{
git_repository *repo = data;
git_reference *resolved = NULL;
char hex[GIT_OID_HEXSZ+1];
char hex[GIT_OID_SHA1_HEXSIZE+1];
const git_oid *oid;
git_object *obj;
@@ -16,7 +16,7 @@ static int show_ref(git_reference *ref, void *data)
oid = git_reference_target(resolved ? resolved : ref);
git_oid_fmt(hex, oid);
hex[GIT_OID_HEXSZ] = 0;
hex[GIT_OID_SHA1_HEXSIZE] = 0;
check_lg2(git_object_lookup(&obj, repo, oid, GIT_OBJECT_ANY),
"Unable to lookup object", hex);

View File

@@ -129,7 +129,7 @@ int lg2_general(git_repository *repo, int argc, char** argv)
*/
static void oid_parsing(git_oid *oid)
{
char out[GIT_OID_HEXSZ+1];
char out[GIT_OID_SHA1_HEXSIZE+1];
char hex[] = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045";
printf("*Hex to Raw*\n");
@@ -152,7 +152,7 @@ static void oid_parsing(git_oid *oid)
* char hex value.
*/
printf("\n*Raw to Hex*\n");
out[GIT_OID_HEXSZ] = '\0';
out[GIT_OID_SHA1_HEXSIZE] = '\0';
/**
* If you have a oid, you can easily get the hex value of the SHA as well.
@@ -173,7 +173,7 @@ static void oid_parsing(git_oid *oid)
*/
static void object_database(git_repository *repo, git_oid *oid)
{
char oid_hex[GIT_OID_HEXSZ+1] = { 0 };
char oid_hex[GIT_OID_SHA1_HEXSIZE+1] = { 0 };
const unsigned char *data;
const char *str_type;
int error;
@@ -266,7 +266,7 @@ static void commit_writing(git_repository *repo)
git_tree *tree;
git_commit *parent;
git_signature *author, *committer;
char oid_hex[GIT_OID_HEXSZ+1] = { 0 };
char oid_hex[GIT_OID_SHA1_HEXSIZE+1] = { 0 };
printf("\n*Commit Writing*\n");
@@ -345,7 +345,7 @@ static void commit_parsing(git_repository *repo)
const git_signature *author, *cmtter;
git_commit *commit, *parent;
git_oid oid;
char oid_hex[GIT_OID_HEXSZ+1];
char oid_hex[GIT_OID_SHA1_HEXSIZE+1];
const char *message;
unsigned int parents, p;
int error;
@@ -679,7 +679,7 @@ static void reference_listing(git_repository *repo)
for (i = 0; i < ref_list.count; ++i) {
git_reference *ref;
char oid_hex[GIT_OID_HEXSZ+1] = GIT_OID_HEX_ZERO;
char oid_hex[GIT_OID_SHA1_HEXSIZE+1] = GIT_OID_HEX_ZERO;
const char *refname;
refname = ref_list.strings[i];

View File

@@ -329,7 +329,7 @@ static void print_time(const git_time *intime, const char *prefix)
/** Helper to print a commit object. */
static void print_commit(git_commit *commit, struct log_options *opts)
{
char buf[GIT_OID_HEXSZ + 1];
char buf[GIT_OID_SHA1_HEXSIZE + 1];
int i, count;
const git_signature *sig;
const char *scan, *eol;

View File

@@ -34,7 +34,7 @@ static int use_remote(git_repository *repo, char *name)
goto cleanup;
for (i = 0; i < refs_len; i++) {
char oid[GIT_OID_HEXSZ + 1] = {0};
char oid[GIT_OID_SHA1_HEXSIZE + 1] = {0};
git_oid_fmt(oid, &refs[i]->oid);
printf("%s\t%s\n", oid, refs[i]->name);
}

View File

@@ -26,7 +26,7 @@ int lg2_rev_list(git_repository *repo, int argc, char **argv)
git_revwalk *walk;
git_oid oid;
git_sort_t sort;
char buf[GIT_OID_HEXSZ+1];
char buf[GIT_OID_SHA1_HEXSIZE+1];
check_lg2(revwalk_parse_options(&sort, &args), "parsing options", NULL);
@@ -36,7 +36,7 @@ int lg2_rev_list(git_repository *repo, int argc, char **argv)
while (!git_revwalk_next(&oid, walk)) {
git_oid_fmt(buf, &oid);
buf[GIT_OID_HEXSZ] = '\0';
buf[GIT_OID_SHA1_HEXSIZE] = '\0';
printf("%s\n", buf);
}

View File

@@ -65,7 +65,7 @@ static void parse_opts(struct parse_state *ps, int argc, char *argv[])
static int parse_revision(git_repository *repo, struct parse_state *ps)
{
git_revspec rs;
char str[GIT_OID_HEXSZ + 1];
char str[GIT_OID_SHA1_HEXSIZE + 1];
check_lg2(git_revparse(&rs, repo, ps->spec), "Could not parse", ps->spec);

View File

@@ -20,8 +20,8 @@ int lg2_show_index(git_repository *repo, int argc, char **argv)
size_t i, ecount;
char *dir = ".";
size_t dirlen;
char out[GIT_OID_HEXSZ+1];
out[GIT_OID_HEXSZ] = '\0';
char out[GIT_OID_SHA1_HEXSIZE+1];
out[GIT_OID_SHA1_HEXSIZE] = '\0';
if (argc > 2)
fatal("usage: showindex [<repo-dir>]", NULL);