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
0a19c151
Unverified
Commit
0a19c151
authored
May 09, 2018
by
Patrick Steinhardt
Committed by
GitHub
May 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4629 from neithernut/enhance-glob-perf
refdb_fs: enhance performance of globbing
parents
81c9894f
20a2b02d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
src/refdb_fs.c
+30
-3
No files found.
src/refdb_fs.c
View file @
0a19c151
...
@@ -505,26 +505,53 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
...
@@ -505,26 +505,53 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
git_iterator
*
fsit
=
NULL
;
git_iterator
*
fsit
=
NULL
;
git_iterator_options
fsit_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
git_iterator_options
fsit_opts
=
GIT_ITERATOR_OPTIONS_INIT
;
const
git_index_entry
*
entry
=
NULL
;
const
git_index_entry
*
entry
=
NULL
;
const
char
*
ref_prefix
=
GIT_REFS_DIR
;
size_t
ref_prefix_len
=
strlen
(
ref_prefix
);
if
(
!
backend
->
commonpath
)
/* do nothing if no commonpath for loose refs */
if
(
!
backend
->
commonpath
)
/* do nothing if no commonpath for loose refs */
return
0
;
return
0
;
fsit_opts
.
flags
=
backend
->
iterator_flags
;
fsit_opts
.
flags
=
backend
->
iterator_flags
;
if
((
error
=
git_buf_printf
(
&
path
,
"%s/refs"
,
backend
->
commonpath
))
<
0
||
if
(
iter
->
glob
)
{
const
char
*
last_sep
=
NULL
;
const
char
*
pos
;
for
(
pos
=
iter
->
glob
;
*
pos
;
++
pos
)
{
switch
(
*
pos
)
{
case
'?'
:
case
'*'
:
case
'['
:
case
'\\'
:
break
;
case
'/'
:
last_sep
=
pos
;
/* FALLTHROUGH */
default:
continue
;
}
break
;
}
if
(
last_sep
)
{
ref_prefix
=
iter
->
glob
;
ref_prefix_len
=
(
last_sep
-
ref_prefix
)
+
1
;
}
}
if
((
error
=
git_buf_printf
(
&
path
,
"%s/"
,
backend
->
commonpath
))
<
0
||
(
error
=
git_buf_put
(
&
path
,
ref_prefix
,
ref_prefix_len
))
<
0
||
(
error
=
git_iterator_for_filesystem
(
&
fsit
,
path
.
ptr
,
&
fsit_opts
))
<
0
)
{
(
error
=
git_iterator_for_filesystem
(
&
fsit
,
path
.
ptr
,
&
fsit_opts
))
<
0
)
{
git_buf_free
(
&
path
);
git_buf_free
(
&
path
);
return
error
;
return
error
;
}
}
error
=
git_buf_sets
(
&
path
,
GIT_REFS_DIR
);
error
=
git_buf_sets
(
&
path
,
ref_prefix
);
while
(
!
error
&&
!
git_iterator_advance
(
&
entry
,
fsit
))
{
while
(
!
error
&&
!
git_iterator_advance
(
&
entry
,
fsit
))
{
const
char
*
ref_name
;
const
char
*
ref_name
;
struct
packref
*
ref
;
struct
packref
*
ref
;
char
*
ref_dup
;
char
*
ref_dup
;
git_buf_truncate
(
&
path
,
strlen
(
GIT_REFS_DIR
)
);
git_buf_truncate
(
&
path
,
ref_prefix_len
);
git_buf_puts
(
&
path
,
entry
->
path
);
git_buf_puts
(
&
path
,
entry
->
path
);
ref_name
=
git_buf_cstr
(
&
path
);
ref_name
=
git_buf_cstr
(
&
path
);
...
...
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