Factor 40 and 41 constants from source. · nodegit/libgit2@3b2cb2c · GitHub
Skip to content

Commit 3b2cb2c

Browse files
committed
Factor 40 and 41 constants from source.
1 parent 3a495c1 commit 3b2cb2c

12 files changed

Lines changed: 25 additions & 24 deletions

File tree

‎examples/general.c‎

Lines changed: 2 additions & 2 deletions

‎examples/rev-list.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int main (int argc, char **argv)
2222
git_repository *repo;
2323
git_revwalk *walk;
2424
git_oid oid;
25-
char buf[41];
25+
char buf[GIT_OID_HEXSZ+1];
2626

2727
git_threads_init();
2828

@@ -32,7 +32,7 @@ int main (int argc, char **argv)
3232

3333
while (!git_revwalk_next(&oid, walk)) {
3434
git_oid_fmt(buf, &oid);
35-
buf[40] = '\0';
35+
buf[GIT_OID_HEXSZ] = '\0';
3636
printf("%s\n", buf);
3737
}
3838

‎examples/showindex.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ int main (int argc, char** argv)
2020
unsigned int i, ecount;
2121
char *dir = ".";
2222
size_t dirlen;
23-
char out[41];
24-
out[40] = '\0';
23+
char out[GIT_OID_HEXSZ+1];
24+
out[GIT_OID_HEXSZ] = '\0';
2525

2626
git_threads_init();
2727

‎src/global.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
#ifndef INCLUDE_global_h__
88
#define INCLUDE_global_h__
99

10+
#include "common.h"
1011
#include "mwindow.h"
1112
#include "hash.h"
1213

1314
typedef struct {
1415
git_error *last_error;
1516
git_error error_t;
16-
char oid_fmt[41];
17+
char oid_fmt[GIT_OID_HEXSZ+1];
1718
} git_global_st;
1819

1920
#ifdef GIT_SSL

‎src/odb_loose.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ struct foreach_state {
714714
GIT_INLINE(int) filename_to_oid(git_oid *oid, const char *ptr)
715715
{
716716
int v, i = 0;
717-
if (strlen(ptr) != 41)
717+
if (strlen(ptr) != GIT_OID_HEXSZ+1)
718718
return -1;
719719

720720
if (ptr[2] != '/') {

‎src/transports/smart_protocol.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,9 @@ static int gen_pktline(git_buf *buf, git_push *push)
640640
{
641641
push_spec *spec;
642642
size_t i, len;
643-
char old_id[41], new_id[41];
643+
char old_id[GIT_OID_HEXSZ+1], new_id[GIT_OID_HEXSZ+1];
644644

645-
old_id[40] = '\0'; new_id[40] = '\0';
645+
old_id[GIT_OID_HEXSZ] = '\0'; new_id[GIT_OID_HEXSZ] = '\0';
646646

647647
git_vector_foreach(&push->specs, i, spec) {
648648
len = 2*GIT_OID_HEXSZ + 7 + strlen(spec->rref);
@@ -963,7 +963,7 @@ int git_smart__push(git_transport *transport, git_push *push)
963963
#ifdef PUSH_DEBUG
964964
{
965965
git_remote_head *head;
966-
char hex[41]; hex[40] = '\0';
966+
char hex[GIT_OID_HEXSZ+1]; hex[GIT_OID_HEXSZ] = '\0';
967967

968968
git_vector_foreach(&push->remote->refs, i, head) {
969969
git_oid_fmt(hex, &head->oid);

‎tests/blame/blame_helpers.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void hunk_message(size_t idx, const git_blame_hunk *hunk, const char *fmt, ...)
1717
void check_blame_hunk_index(git_repository *repo, git_blame *blame, int idx,
1818
int start_line, int len, char boundary, const char *commit_id, const char *orig_path)
1919
{
20-
char expected[41] = {0}, actual[41] = {0};
20+
char expected[GIT_OID_HEXSZ+1] = {0}, actual[GIT_OID_HEXSZ+1] = {0};
2121
const git_blame_hunk *hunk = git_blame_get_hunk_byindex(blame, idx);
2222
cl_assert(hunk);
2323

‎tests/checkout/conflict.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static git_index *g_index;
4848

4949
struct checkout_index_entry {
5050
uint16_t mode;
51-
char oid_str[41];
51+
char oid_str[GIT_OID_HEXSZ+1];
5252
int stage;
5353
char path[128];
5454
};

‎tests/merge/merge_helpers.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
struct merge_index_entry {
5151
uint16_t mode;
52-
char oid_str[41];
52+
char oid_str[GIT_OID_HEXSZ+1];
5353
int stage;
5454
char path[128];
5555
};
@@ -70,9 +70,9 @@ struct merge_reuc_entry {
7070
unsigned int ancestor_mode;
7171
unsigned int our_mode;
7272
unsigned int their_mode;
73-
char ancestor_oid_str[41];
74-
char our_oid_str[41];
75-
char their_oid_str[41];
73+
char ancestor_oid_str[GIT_OID_HEXSZ+1];
74+
char our_oid_str[GIT_OID_HEXSZ+1];
75+
char their_oid_str[GIT_OID_HEXSZ+1];
7676
};
7777

7878
struct merge_index_conflict_data {

‎tests/object/raw/chars.c‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)