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
9bbc53d6
Commit
9bbc53d6
authored
Jan 21, 2014
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix filemode updating in diff text
parent
2c65602e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
tests/diff/drivers.c
+15
-7
No files found.
tests/diff/drivers.c
View file @
9bbc53d6
...
...
@@ -15,13 +15,21 @@ void test_diff_drivers__cleanup(void)
g_repo
=
NULL
;
}
static
void
overwrite_
chmod_at_offset
(
git_buf
*
buf
,
size_t
offset
)
static
void
overwrite_
filemode
(
const
char
*
expected
,
git_buf
*
actual
)
{
if
(
cl_is_chmod_supported
())
size_t
offset
;
char
*
found
;
found
=
strstr
(
expected
,
"100644"
);
if
(
!
found
)
return
;
offset
=
((
const
char
*
)
found
)
-
expected
;
if
(
actual
->
size
<
offset
+
6
)
return
;
if
(
buf
->
size
>
offset
+
6
&&
memcmp
(
&
buf
->
ptr
[
offset
],
"100644"
,
6
)
!=
0
)
memcpy
(
&
buf
->
ptr
[
offset
],
"100644"
,
6
);
if
(
memcmp
(
&
actual
->
ptr
[
offset
],
"100644"
,
6
)
!=
0
)
memcpy
(
&
actual
->
ptr
[
offset
],
"100644"
,
6
);
}
void
test_diff_drivers__patterns
(
void
)
...
...
@@ -157,7 +165,7 @@ void test_diff_drivers__long_lines(void)
cl_git_pass
(
git_patch_to_buf
(
&
actual
,
patch
));
/* if chmod not supported, overwrite mode bits since anything is possible */
overwrite_
chmod_at_offset
(
&
actual
,
66
);
overwrite_
filemode
(
expected
,
&
actual
);
cl_assert_equal_s
(
expected
,
actual
.
ptr
);
...
...
@@ -210,7 +218,7 @@ void test_diff_drivers__builtins(void)
cl_git_pass
(
git_patch_from_diff
(
&
patch
,
diff
,
0
));
cl_git_pass
(
git_patch_to_buf
(
&
actual
,
patch
));
overwrite_
chmod_at_offset
(
&
actual
,
59
);
overwrite_
filemode
(
expected_nodriver
,
&
actual
);
cl_assert_equal_s
(
expected_nodriver
,
actual
.
ptr
);
...
...
@@ -227,7 +235,7 @@ void test_diff_drivers__builtins(void)
cl_git_pass
(
git_patch_from_diff
(
&
patch
,
diff
,
0
));
cl_git_pass
(
git_patch_to_buf
(
&
actual
,
patch
));
overwrite_
chmod_at_offset
(
&
actual
,
59
);
overwrite_
filemode
(
expected_driver
,
&
actual
);
cl_assert_equal_s
(
expected_driver
,
actual
.
ptr
);
...
...
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