Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCiro Santilli <ciro.santilli@gmail.com>2014-09-16 13:49:25 +0400
committerCiro Santilli <ciro.santilli@gmail.com>2014-09-16 15:07:04 +0400
commit3b2cb2c91ee77e5e45957e8355025e3e742c07bd (patch)
tree01213a03d821babf6103754afe64fed6e9849a6f
parent3a495c19bd280f5455047a9ac0e936f2c2f2f9a9 (diff)
Factor 40 and 41 constants from source.
-rw-r--r--examples/general.c4
-rw-r--r--examples/rev-list.c4
-rw-r--r--examples/showindex.c4
-rw-r--r--src/global.h3
-rw-r--r--src/odb_loose.c2
-rw-r--r--src/transports/smart_protocol.c6
-rw-r--r--tests/blame/blame_helpers.c2
-rw-r--r--tests/checkout/conflict.c2
-rw-r--r--tests/merge/merge_helpers.h8
-rw-r--r--tests/object/raw/chars.c2
-rw-r--r--tests/pack/packbuilder.c4
-rw-r--r--tests/revwalk/basic.c8
12 files changed, 25 insertions, 24 deletions
diff --git a/examples/general.c b/examples/general.c
index ae8756338..051d69380 100644
--- a/examples/general.c
+++ b/examples/general.c
@@ -94,8 +94,8 @@ int main (int argc, char** argv)
// Next we will convert the 20 byte raw SHA1 value to a human readable 40
// char hex value.
printf("\n*Raw to Hex*\n");
- char out[41];
- out[40] = '\0';
+ char out[GIT_OID_HEXSZ+1];
+ out[GIT_OID_HEXSZ] = '\0';
// If you have a oid, you can easily get the hex value of the SHA as well.
git_oid_fmt(out, &oid);
diff --git a/examples/rev-list.c b/examples/rev-list.c
index 5c0d751a3..940a01136 100644
--- a/examples/rev-list.c
+++ b/examples/rev-list.c
@@ -22,7 +22,7 @@ int main (int argc, char **argv)
git_repository *repo;
git_revwalk *walk;
git_oid oid;
- char buf[41];
+ char buf[GIT_OID_HEXSZ+1];
git_threads_init();
@@ -32,7 +32,7 @@ int main (int argc, char **argv)
while (!git_revwalk_next(&oid, walk)) {
git_oid_fmt(buf, &oid);
- buf[40] = '\0';
+ buf[GIT_OID_HEXSZ] = '\0';
printf("%s\n", buf);
}
diff --git a/examples/showindex.c b/examples/showindex.c
index ad4a16e8e..604124f12 100644
--- a/examples/showindex.c
+++ b/examples/showindex.c
@@ -20,8 +20,8 @@ int main (int argc, char** argv)
unsigned int i, ecount;
char *dir = ".";
size_t dirlen;
- char out[41];
- out[40] = '\0';
+ char out[GIT_OID_HEXSZ+1];
+ out[GIT_OID_HEXSZ] = '\0';
git_threads_init();
diff --git a/src/global.h b/src/global.h
index 106504628..a89a8d6ab 100644
--- a/src/global.h
+++ b/src/global.h
@@ -7,13 +7,14 @@
#ifndef INCLUDE_global_h__
#define INCLUDE_global_h__
+#include "common.h"
#include "mwindow.h"
#include "hash.h"
typedef struct {
git_error *last_error;
git_error error_t;
- char oid_fmt[41];
+ char oid_fmt[GIT_OID_HEXSZ+1];
} git_global_st;
#ifdef GIT_SSL
diff --git a/src/odb_loose.c b/src/odb_loose.c
index b2e8bed4d..ef6de41a9 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -714,7 +714,7 @@ struct foreach_state {
GIT_INLINE(int) filename_to_oid(git_oid *oid, const char *ptr)
{
int v, i = 0;
- if (strlen(ptr) != 41)
+ if (strlen(ptr) != GIT_OID_HEXSZ+1)
return -1;
if (ptr[2] != '/') {
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 5ca5065ac..7c20382dc 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -640,9 +640,9 @@ static int gen_pktline(git_buf *buf, git_push *push)
{
push_spec *spec;
size_t i, len;
- char old_id[41], new_id[41];
+ char old_id[GIT_OID_HEXSZ+1], new_id[GIT_OID_HEXSZ+1];
- old_id[40] = '\0'; new_id[40] = '\0';
+ old_id[GIT_OID_HEXSZ] = '\0'; new_id[GIT_OID_HEXSZ] = '\0';
git_vector_foreach(&push->specs, i, spec) {
len = 2*GIT_OID_HEXSZ + 7 + strlen(spec->rref);
@@ -963,7 +963,7 @@ int git_smart__push(git_transport *transport, git_push *push)
#ifdef PUSH_DEBUG
{
git_remote_head *head;
- char hex[41]; hex[40] = '\0';
+ char hex[GIT_OID_HEXSZ+1]; hex[GIT_OID_HEXSZ] = '\0';
git_vector_foreach(&push->remote->refs, i, head) {
git_oid_fmt(hex, &head->oid);
diff --git a/tests/blame/blame_helpers.c b/tests/blame/blame_helpers.c
index 9bb77a52d..21cd1a615 100644
--- a/tests/blame/blame_helpers.c
+++ b/tests/blame/blame_helpers.c
@@ -17,7 +17,7 @@ void hunk_message(size_t idx, const git_blame_hunk *hunk, const char *fmt, ...)
void check_blame_hunk_index(git_repository *repo, git_blame *blame, int idx,
int start_line, int len, char boundary, const char *commit_id, const char *orig_path)
{
- char expected[41] = {0}, actual[41] = {0};
+ char expected[GIT_OID_HEXSZ+1] = {0}, actual[GIT_OID_HEXSZ+1] = {0};
const git_blame_hunk *hunk = git_blame_get_hunk_byindex(blame, idx);
cl_assert(hunk);
diff --git a/tests/checkout/conflict.c b/tests/checkout/conflict.c
index b8ae80576..943371dac 100644
--- a/tests/checkout/conflict.c
+++ b/tests/checkout/conflict.c
@@ -48,7 +48,7 @@ static git_index *g_index;
struct checkout_index_entry {
uint16_t mode;
- char oid_str[41];
+ char oid_str[GIT_OID_HEXSZ+1];
int stage;
char path[128];
};
diff --git a/tests/merge/merge_helpers.h b/tests/merge/merge_helpers.h
index fddf8fab1..554c24b7c 100644
--- a/tests/merge/merge_helpers.h
+++ b/tests/merge/merge_helpers.h
@@ -49,7 +49,7 @@
struct merge_index_entry {
uint16_t mode;
- char oid_str[41];
+ char oid_str[GIT_OID_HEXSZ+1];
int stage;
char path[128];
};
@@ -70,9 +70,9 @@ struct merge_reuc_entry {
unsigned int ancestor_mode;
unsigned int our_mode;
unsigned int their_mode;
- char ancestor_oid_str[41];
- char our_oid_str[41];
- char their_oid_str[41];
+ char ancestor_oid_str[GIT_OID_HEXSZ+1];
+ char our_oid_str[GIT_OID_HEXSZ+1];
+ char their_oid_str[GIT_OID_HEXSZ+1];
};
struct merge_index_conflict_data {
diff --git a/tests/object/raw/chars.c b/tests/object/raw/chars.c
index 206bf7119..cde0bdbf6 100644
--- a/tests/object/raw/chars.c
+++ b/tests/object/raw/chars.c
@@ -12,7 +12,7 @@ void test_object_raw_chars__find_invalid_chars_in_oid(void)
0xb7, 0x75, 0x21, 0x3c, 0x23,
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
};
- char in[41] = "16a67770b7d8d72317c4b775213c23a8bd74f5e0";
+ char in[] = "16a67770b7d8d72317c4b775213c23a8bd74f5e0";
unsigned int i;
for (i = 0; i < 256; i++) {
diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c
index 1059424ed..12273ec85 100644
--- a/tests/pack/packbuilder.c
+++ b/tests/pack/packbuilder.c
@@ -93,7 +93,7 @@ void test_pack_packbuilder__create_pack(void)
git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
git_hash_ctx ctx;
git_oid hash;
- char hex[41]; hex[40] = '\0';
+ char hex[GIT_OID_HEXSZ+1]; hex[GIT_OID_HEXSZ] = '\0';
seed_packbuilder();
@@ -135,7 +135,7 @@ void test_pack_packbuilder__create_pack(void)
void test_pack_packbuilder__get_hash(void)
{
- char hex[41]; hex[40] = '\0';
+ char hex[GIT_OID_HEXSZ+1]; hex[GIT_OID_HEXSZ] = '\0';
seed_packbuilder();
diff --git a/tests/revwalk/basic.c b/tests/revwalk/basic.c
index b015db18b..ff05fa249 100644
--- a/tests/revwalk/basic.c
+++ b/tests/revwalk/basic.c
@@ -49,12 +49,12 @@ static const int result_bytes = 24;
static int get_commit_index(git_oid *raw_oid)
{
int i;
- char oid[40];
+ char oid[GIT_OID_HEXSZ];
git_oid_fmt(oid, raw_oid);
for (i = 0; i < commit_count; ++i)
- if (memcmp(oid, commit_ids[i], 40) == 0)
+ if (memcmp(oid, commit_ids[i], GIT_OID_HEXSZ) == 0)
return i;
return -1;
@@ -74,9 +74,9 @@ static int test_walk_only(git_revwalk *walk,
while (git_revwalk_next(&oid, walk) == 0) {
result_array[i++] = get_commit_index(&oid);
/*{
- char str[41];
+ char str[GIT_OID_HEXSZ+1];
git_oid_fmt(str, &oid);
- str[40] = 0;
+ str[GIT_OID_HEXSZ] = 0;
printf(" %d) %s\n", i, str);
}*/
}