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
cada553c
Unverified
Commit
cada553c
authored
Aug 19, 2018
by
Edward Thomson
Committed by
GitHub
Aug 19, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4754 from libgit2/ethomson/threads
threads::diff: use separate git_repository objects
parents
c1ef58ac
2afd0185
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
11 deletions
+21
-11
tests/threads/diff.c
+17
-10
tests/threads/iterator.c
+4
-1
No files found.
tests/threads/diff.c
View file @
cada553c
...
@@ -76,26 +76,29 @@ static void free_trees(void)
...
@@ -76,26 +76,29 @@ static void free_trees(void)
static
void
*
run_index_diffs
(
void
*
arg
)
static
void
*
run_index_diffs
(
void
*
arg
)
{
{
int
thread
=
*
(
int
*
)
arg
;
int
thread
=
*
(
int
*
)
arg
;
git_repository
*
repo
;
git_diff_options
opts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff_options
opts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff
*
diff
=
NULL
;
git_diff
*
diff
=
NULL
;
size_t
i
;
size_t
i
;
int
exp
[
4
]
=
{
0
,
0
,
0
,
0
};
int
exp
[
4
]
=
{
0
,
0
,
0
,
0
};
cl_git_pass
(
git_repository_open
(
&
repo
,
git_repository_path
(
_repo
)));
switch
(
thread
&
0x03
)
{
switch
(
thread
&
0x03
)
{
case
0
:
/* diff index to workdir */
;
case
0
:
/* diff index to workdir */
;
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
_
repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
repo
,
NULL
,
&
opts
));
break
;
break
;
case
1
:
/* diff tree 'a' to index */
;
case
1
:
/* diff tree 'a' to index */
;
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
_
repo
,
_a
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
repo
,
_a
,
NULL
,
&
opts
));
break
;
break
;
case
2
:
/* diff tree 'b' to index */
;
case
2
:
/* diff tree 'b' to index */
;
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
_
repo
,
_b
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
repo
,
_b
,
NULL
,
&
opts
));
break
;
break
;
case
3
:
/* diff index to workdir (explicit index) */
;
case
3
:
/* diff index to workdir (explicit index) */
;
{
{
git_index
*
idx
;
git_index
*
idx
;
cl_git_pass
(
git_repository_index
(
&
idx
,
_
repo
));
cl_git_pass
(
git_repository_index
(
&
idx
,
repo
));
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
_
repo
,
idx
,
&
opts
));
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
repo
,
idx
,
&
opts
));
git_index_free
(
idx
);
git_index_free
(
idx
);
break
;
break
;
}
}
...
@@ -132,6 +135,7 @@ static void *run_index_diffs(void *arg)
...
@@ -132,6 +135,7 @@ static void *run_index_diffs(void *arg)
}
}
git_diff_free
(
diff
);
git_diff_free
(
diff
);
git_repository_free
(
repo
);
giterr_clear
();
giterr_clear
();
return
arg
;
return
arg
;
...
@@ -152,8 +156,10 @@ static void *run_index_diffs_with_modifier(void *arg)
...
@@ -152,8 +156,10 @@ static void *run_index_diffs_with_modifier(void *arg)
git_diff_options
opts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff_options
opts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff
*
diff
=
NULL
;
git_diff
*
diff
=
NULL
;
git_index
*
idx
=
NULL
;
git_index
*
idx
=
NULL
;
git_repository
*
repo
;
cl_git_pass
(
git_repository_index
(
&
idx
,
_repo
));
cl_git_pass
(
git_repository_open
(
&
repo
,
git_repository_path
(
_repo
)));
cl_git_pass
(
git_repository_index
(
&
idx
,
repo
));
/* have first thread altering the index as we go */
/* have first thread altering the index as we go */
if
(
thread
==
0
)
{
if
(
thread
==
0
)
{
...
@@ -176,17 +182,17 @@ static void *run_index_diffs_with_modifier(void *arg)
...
@@ -176,17 +182,17 @@ static void *run_index_diffs_with_modifier(void *arg)
switch
(
thread
&
0x03
)
{
switch
(
thread
&
0x03
)
{
case
0
:
/* diff index to workdir */
;
case
0
:
/* diff index to workdir */
;
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
_
repo
,
idx
,
&
opts
));
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
repo
,
idx
,
&
opts
));
break
;
break
;
case
1
:
/* diff tree 'a' to index */
;
case
1
:
/* diff tree 'a' to index */
;
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
_
repo
,
_a
,
idx
,
&
opts
));
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
repo
,
_a
,
idx
,
&
opts
));
break
;
break
;
case
2
:
/* diff tree 'b' to index */
;
case
2
:
/* diff tree 'b' to index */
;
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
_
repo
,
_b
,
idx
,
&
opts
));
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
repo
,
_b
,
idx
,
&
opts
));
break
;
break
;
case
3
:
/* diff index to workdir reversed */
;
case
3
:
/* diff index to workdir reversed */
;
opts
.
flags
|=
GIT_DIFF_REVERSE
;
opts
.
flags
|=
GIT_DIFF_REVERSE
;
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
_
repo
,
idx
,
&
opts
));
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
repo
,
idx
,
&
opts
));
break
;
break
;
}
}
...
@@ -196,6 +202,7 @@ static void *run_index_diffs_with_modifier(void *arg)
...
@@ -196,6 +202,7 @@ static void *run_index_diffs_with_modifier(void *arg)
done:
done:
git_index_free
(
idx
);
git_index_free
(
idx
);
git_repository_free
(
repo
);
giterr_clear
();
giterr_clear
();
return
arg
;
return
arg
;
...
...
tests/threads/iterator.c
View file @
cada553c
...
@@ -12,14 +12,16 @@ void test_threads_iterator__cleanup(void)
...
@@ -12,14 +12,16 @@ void test_threads_iterator__cleanup(void)
static
void
*
run_workdir_iterator
(
void
*
arg
)
static
void
*
run_workdir_iterator
(
void
*
arg
)
{
{
int
error
=
0
;
int
error
=
0
;
git_repository
*
repo
;
git_iterator
*
iter
;
git_iterator
*
iter
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
git_iterator_options
iter_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
=
NULL
;
const
git_index_entry
*
entry
=
NULL
;
iter_opts
.
flags
=
GIT_ITERATOR_DONT_AUTOEXPAND
;
iter_opts
.
flags
=
GIT_ITERATOR_DONT_AUTOEXPAND
;
cl_git_pass
(
git_repository_open
(
&
repo
,
git_repository_path
(
_repo
)));
cl_git_pass
(
git_iterator_for_workdir
(
cl_git_pass
(
git_iterator_for_workdir
(
&
iter
,
_
repo
,
NULL
,
NULL
,
&
iter_opts
));
&
iter
,
repo
,
NULL
,
NULL
,
&
iter_opts
));
while
(
!
error
)
{
while
(
!
error
)
{
if
(
entry
&&
entry
->
mode
==
GIT_FILEMODE_TREE
)
{
if
(
entry
&&
entry
->
mode
==
GIT_FILEMODE_TREE
)
{
...
@@ -38,6 +40,7 @@ static void *run_workdir_iterator(void *arg)
...
@@ -38,6 +40,7 @@ static void *run_workdir_iterator(void *arg)
cl_assert_equal_i
(
GIT_ITEROVER
,
error
);
cl_assert_equal_i
(
GIT_ITEROVER
,
error
);
git_iterator_free
(
iter
);
git_iterator_free
(
iter
);
git_repository_free
(
repo
);
giterr_clear
();
giterr_clear
();
return
arg
;
return
arg
;
}
}
...
...
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