Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
3b2cb2c9
Commit
3b2cb2c9
authored
Sep 16, 2014
by
Ciro Santilli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor 40 and 41 constants from source.
parent
3a495c19
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
25 additions
and
24 deletions
+25
-24
examples/general.c
+2
-2
examples/rev-list.c
+2
-2
examples/showindex.c
+2
-2
src/global.h
+2
-1
src/odb_loose.c
+1
-1
src/transports/smart_protocol.c
+3
-3
tests/blame/blame_helpers.c
+1
-1
tests/checkout/conflict.c
+1
-1
tests/merge/merge_helpers.h
+4
-4
tests/object/raw/chars.c
+1
-1
tests/pack/packbuilder.c
+2
-2
tests/revwalk/basic.c
+4
-4
No files found.
examples/general.c
View file @
3b2cb2c9
...
...
@@ -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
[
4
1
];
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
);
...
...
examples/rev-list.c
View file @
3b2cb2c9
...
...
@@ -22,7 +22,7 @@ int main (int argc, char **argv)
git_repository
*
repo
;
git_revwalk
*
walk
;
git_oid
oid
;
char
buf
[
4
1
];
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
);
}
...
...
examples/showindex.c
View file @
3b2cb2c9
...
...
@@ -20,8 +20,8 @@ int main (int argc, char** argv)
unsigned
int
i
,
ecount
;
char
*
dir
=
"."
;
size_t
dirlen
;
char
out
[
4
1
];
out
[
40
]
=
'\0'
;
char
out
[
GIT_OID_HEXSZ
+
1
];
out
[
GIT_OID_HEXSZ
]
=
'\0'
;
git_threads_init
();
...
...
src/global.h
View file @
3b2cb2c9
...
...
@@ -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
[
4
1
];
char
oid_fmt
[
GIT_OID_HEXSZ
+
1
];
}
git_global_st
;
#ifdef GIT_SSL
...
...
src/odb_loose.c
View file @
3b2cb2c9
...
...
@@ -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
)
!=
4
1
)
if
(
strlen
(
ptr
)
!=
GIT_OID_HEXSZ
+
1
)
return
-
1
;
if
(
ptr
[
2
]
!=
'/'
)
{
...
...
src/transports/smart_protocol.c
View file @
3b2cb2c9
...
...
@@ -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
[
4
1
];
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
);
...
...
tests/blame/blame_helpers.c
View file @
3b2cb2c9
...
...
@@ -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
[
4
1
]
=
{
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
);
...
...
tests/checkout/conflict.c
View file @
3b2cb2c9
...
...
@@ -48,7 +48,7 @@ static git_index *g_index;
struct
checkout_index_entry
{
uint16_t
mode
;
char
oid_str
[
4
1
];
char
oid_str
[
GIT_OID_HEXSZ
+
1
];
int
stage
;
char
path
[
128
];
};
...
...
tests/merge/merge_helpers.h
View file @
3b2cb2c9
...
...
@@ -49,7 +49,7 @@
struct
merge_index_entry
{
uint16_t
mode
;
char
oid_str
[
4
1
];
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
[
4
1
];
char
our_oid_str
[
4
1
];
char
their_oid_str
[
4
1
];
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
{
...
...
tests/object/raw/chars.c
View file @
3b2cb2c9
...
...
@@ -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
++
)
{
...
...
tests/pack/packbuilder.c
View file @
3b2cb2c9
...
...
@@ -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
();
...
...
tests/revwalk/basic.c
View file @
3b2cb2c9
...
...
@@ -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[
4
1];
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);
}*/
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment