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
ff85adf0
Unverified
Commit
ff85adf0
authored
Apr 12, 2022
by
Edward Thomson
Committed by
GitHub
Apr 12, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6269 from libgit2/ethomson/14_backports
Backports to v1.4
parents
8bc1f0d0
8d984299
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
4 deletions
+84
-4
fuzzers/corpora/midx/666a779eed16847c6930a71c0547a34e52db409e
+0
-0
src/diff_print.c
+5
-0
src/fetch.c
+3
-0
src/midx.c
+8
-3
src/remote.c
+4
-1
tests/diff/parse.c
+26
-0
tests/online/fetch.c
+29
-0
tests/patch/patch_common.h
+9
-0
No files found.
fuzzers/corpora/midx/666a779eed16847c6930a71c0547a34e52db409e
0 → 100644
View file @
ff85adf0
File added
src/diff_print.c
View file @
ff85adf0
...
@@ -316,6 +316,11 @@ static int diff_print_oid_range(
...
@@ -316,6 +316,11 @@ static int diff_print_oid_range(
static
int
diff_delta_format_path
(
static
int
diff_delta_format_path
(
git_str
*
out
,
const
char
*
prefix
,
const
char
*
filename
)
git_str
*
out
,
const
char
*
prefix
,
const
char
*
filename
)
{
{
if
(
!
filename
)
{
/* don't prefix "/dev/null" */
return
git_str_puts
(
out
,
"/dev/null"
);
}
if
(
git_str_joinpath
(
out
,
prefix
,
filename
)
<
0
)
if
(
git_str_joinpath
(
out
,
prefix
,
filename
)
<
0
)
return
-
1
;
return
-
1
;
...
...
src/fetch.c
View file @
ff85adf0
...
@@ -76,8 +76,11 @@ static int maybe_want_oid(git_remote *remote, git_refspec *spec)
...
@@ -76,8 +76,11 @@ static int maybe_want_oid(git_remote *remote, git_refspec *spec)
GIT_ERROR_CHECK_ALLOC
(
oid_head
);
GIT_ERROR_CHECK_ALLOC
(
oid_head
);
git_oid_fromstr
(
&
oid_head
->
oid
,
spec
->
src
);
git_oid_fromstr
(
&
oid_head
->
oid
,
spec
->
src
);
if
(
spec
->
dst
)
{
oid_head
->
name
=
git__strdup
(
spec
->
dst
);
oid_head
->
name
=
git__strdup
(
spec
->
dst
);
GIT_ERROR_CHECK_ALLOC
(
oid_head
->
name
);
GIT_ERROR_CHECK_ALLOC
(
oid_head
->
name
);
}
if
(
git_vector_insert
(
&
remote
->
local_heads
,
oid_head
)
<
0
||
if
(
git_vector_insert
(
&
remote
->
local_heads
,
oid_head
)
<
0
||
git_vector_insert
(
&
remote
->
refs
,
oid_head
)
<
0
)
git_vector_insert
(
&
remote
->
refs
,
oid_head
)
<
0
)
...
...
src/midx.c
View file @
ff85adf0
...
@@ -225,8 +225,13 @@ int git_midx_parse(
...
@@ -225,8 +225,13 @@ int git_midx_parse(
chunk_hdr
=
data
+
sizeof
(
struct
git_midx_header
);
chunk_hdr
=
data
+
sizeof
(
struct
git_midx_header
);
last_chunk
=
NULL
;
last_chunk
=
NULL
;
for
(
i
=
0
;
i
<
hdr
->
chunks
;
++
i
,
chunk_hdr
+=
12
)
{
for
(
i
=
0
;
i
<
hdr
->
chunks
;
++
i
,
chunk_hdr
+=
12
)
{
chunk_offset
=
((
off64_t
)
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
4
))))
<<
32
|
uint32_t
chunk_id
=
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
0
)));
((
off64_t
)
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
8
))));
uint64_t
high_offset
=
((
uint64_t
)
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
4
))))
&
0xffffffffu
;
uint64_t
low_offset
=
((
uint64_t
)
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
8
))))
&
0xffffffffu
;
if
(
high_offset
>=
INT32_MAX
)
return
midx_error
(
"chunk offset out of range"
);
chunk_offset
=
(
off64_t
)(
high_offset
<<
32
|
low_offset
);
if
(
chunk_offset
<
last_chunk_offset
)
if
(
chunk_offset
<
last_chunk_offset
)
return
midx_error
(
"chunks are non-monotonic"
);
return
midx_error
(
"chunks are non-monotonic"
);
if
(
chunk_offset
>=
trailer_offset
)
if
(
chunk_offset
>=
trailer_offset
)
...
@@ -235,7 +240,7 @@ int git_midx_parse(
...
@@ -235,7 +240,7 @@ int git_midx_parse(
last_chunk
->
length
=
(
size_t
)(
chunk_offset
-
last_chunk_offset
);
last_chunk
->
length
=
(
size_t
)(
chunk_offset
-
last_chunk_offset
);
last_chunk_offset
=
chunk_offset
;
last_chunk_offset
=
chunk_offset
;
switch
(
ntohl
(
*
((
uint32_t
*
)(
chunk_hdr
+
0
)))
)
{
switch
(
chunk_id
)
{
case
MIDX_PACKFILE_NAMES_ID
:
case
MIDX_PACKFILE_NAMES_ID
:
chunk_packfile_names
.
offset
=
last_chunk_offset
;
chunk_packfile_names
.
offset
=
last_chunk_offset
;
last_chunk
=
&
chunk_packfile_names
;
last_chunk
=
&
chunk_packfile_names
;
...
...
src/remote.c
View file @
ff85adf0
...
@@ -1895,7 +1895,10 @@ static int update_tips_for_spec(
...
@@ -1895,7 +1895,10 @@ static int update_tips_for_spec(
if
(
git_oid__is_hexstr
(
spec
->
src
))
{
if
(
git_oid__is_hexstr
(
spec
->
src
))
{
git_oid
id
;
git_oid
id
;
if
((
error
=
git_oid_fromstr
(
&
id
,
spec
->
src
))
<
0
||
if
((
error
=
git_oid_fromstr
(
&
id
,
spec
->
src
))
<
0
)
goto
on_error
;
if
(
spec
->
dst
&&
(
error
=
update_ref
(
remote
,
spec
->
dst
,
&
id
,
log_message
,
callbacks
))
<
0
)
(
error
=
update_ref
(
remote
,
spec
->
dst
,
&
id
,
log_message
,
callbacks
))
<
0
)
goto
on_error
;
goto
on_error
;
...
...
tests/diff/parse.c
View file @
ff85adf0
...
@@ -431,6 +431,32 @@ void test_diff_parse__new_file_with_space(void)
...
@@ -431,6 +431,32 @@ void test_diff_parse__new_file_with_space(void)
git_diff_free
(
diff
);
git_diff_free
(
diff
);
}
}
void
test_diff_parse__new_file_with_space_and_regenerate_patch
(
void
)
{
const
char
*
content
=
PATCH_ORIGINAL_NEW_FILE_WITH_SPACE
;
git_diff
*
diff
=
NULL
;
git_buf
buf
=
GIT_BUF_INIT
;
cl_git_pass
(
git_diff_from_buffer
(
&
diff
,
content
,
strlen
(
content
)));
cl_git_pass
(
git_diff_to_buf
(
&
buf
,
diff
,
GIT_DIFF_FORMAT_PATCH
));
git_buf_dispose
(
&
buf
);
git_diff_free
(
diff
);
}
void
test_diff_parse__delete_file_with_space_and_regenerate_patch
(
void
)
{
const
char
*
content
=
PATCH_DELETE_FILE_WITH_SPACE
;
git_diff
*
diff
=
NULL
;
git_buf
buf
=
GIT_BUF_INIT
;
cl_git_pass
(
git_diff_from_buffer
(
&
diff
,
content
,
strlen
(
content
)));
cl_git_pass
(
git_diff_to_buf
(
&
buf
,
diff
,
GIT_DIFF_FORMAT_PATCH
));
git_buf_dispose
(
&
buf
);
git_diff_free
(
diff
);
}
void
test_diff_parse__crlf
(
void
)
void
test_diff_parse__crlf
(
void
)
{
{
const
char
*
text
=
PATCH_CRLF
;
const
char
*
text
=
PATCH_CRLF
;
...
...
tests/online/fetch.c
View file @
ff85adf0
...
@@ -321,3 +321,32 @@ void test_online_fetch__reachable_commit(void)
...
@@ -321,3 +321,32 @@ void test_online_fetch__reachable_commit(void)
git_object_free
(
obj
);
git_object_free
(
obj
);
git_remote_free
(
remote
);
git_remote_free
(
remote
);
}
}
void
test_online_fetch__reachable_commit_without_destination
(
void
)
{
git_remote
*
remote
;
git_strarray
refspecs
;
git_object
*
obj
;
git_oid
expected_id
;
git_str
fetchhead
=
GIT_STR_INIT
;
char
*
refspec
=
"2c349335b7f797072cf729c4f3bb0914ecb6dec9"
;
refspecs
.
strings
=
&
refspec
;
refspecs
.
count
=
1
;
git_oid_fromstr
(
&
expected_id
,
"2c349335b7f797072cf729c4f3bb0914ecb6dec9"
);
cl_git_pass
(
git_remote_create
(
&
remote
,
_repo
,
"test"
,
"https://github.com/libgit2/TestGitRepository"
));
cl_git_pass
(
git_remote_fetch
(
remote
,
&
refspecs
,
NULL
,
NULL
));
cl_git_fail_with
(
GIT_ENOTFOUND
,
git_revparse_single
(
&
obj
,
_repo
,
"refs/success"
));
cl_git_pass
(
git_futils_readbuffer
(
&
fetchhead
,
"./fetch/.git/FETCH_HEAD"
));
cl_assert_equal_s
(
fetchhead
.
ptr
,
"2c349335b7f797072cf729c4f3bb0914ecb6dec9
\t\t
'2c349335b7f797072cf729c4f3bb0914ecb6dec9' of https://github.com/libgit2/TestGitRepository
\n
"
);
git_str_dispose
(
&
fetchhead
);
git_object_free
(
obj
);
git_remote_free
(
remote
);
}
tests/patch/patch_common.h
View file @
ff85adf0
...
@@ -933,6 +933,15 @@
...
@@ -933,6 +933,15 @@
"@@ -0,0 +1 @@\n" \
"@@ -0,0 +1 @@\n" \
"+a\n"
"+a\n"
#define PATCH_DELETE_FILE_WITH_SPACE \
"diff --git a/sp ace.txt b/sp ace.txt\n" \
"deleted file mode 100644\n" \
"index 789819226..000000000\n" \
"--- a/sp ace.txt\n" \
"+++ /dev/null\n" \
"@@ -1 +0,0 @@\n" \
"-a\n"
#define PATCH_CRLF \
#define PATCH_CRLF \
"diff --git a/test-file b/test-file\r\n" \
"diff --git a/test-file b/test-file\r\n" \
"new file mode 100644\r\n" \
"new file mode 100644\r\n" \
...
...
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