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
ccef1c9d
Commit
ccef1c9d
authored
Feb 27, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the path comparison method to fileops.c
Signed-off-by: Vicent Marti <tanoku@gmail.com>
parent
da7c3c71
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
19 deletions
+24
-19
src/fileops.c
+19
-0
src/fileops.h
+4
-0
src/tree.c
+1
-19
No files found.
src/fileops.c
View file @
ccef1c9d
...
...
@@ -493,3 +493,22 @@ int gitfo_prettify_file_path(char *buffer_out, const char *path)
return
GIT_SUCCESS
;
}
int
gitfo_cmp_path
(
const
char
*
name1
,
int
len1
,
int
isdir1
,
const
char
*
name2
,
int
len2
,
int
isdir2
)
{
int
len
=
len1
<
len2
?
len1
:
len2
;
int
cmp
;
cmp
=
memcmp
(
name1
,
name2
,
len
);
if
(
cmp
)
return
cmp
;
if
(
len1
<
len2
)
return
((
!
isdir1
&&
!
isdir2
)
?
-
1
:
(
isdir1
?
'/'
-
name2
[
len1
]
:
name2
[
len1
]
-
'/'
));
if
(
len1
>
len2
)
return
((
!
isdir1
&&
!
isdir2
)
?
1
:
(
isdir2
?
name1
[
len2
]
-
'/'
:
'/'
-
name1
[
len2
]));
return
0
;
}
src/fileops.h
View file @
ccef1c9d
...
...
@@ -131,6 +131,10 @@ extern int gitfo_write_cached(gitfo_cache *ioc, void *buf, size_t len);
extern
int
gitfo_flush_cached
(
gitfo_cache
*
ioc
);
extern
int
gitfo_close_cached
(
gitfo_cache
*
ioc
);
extern
int
gitfo_cmp_path
(
const
char
*
name1
,
int
len1
,
int
isdir1
,
const
char
*
name2
,
int
len2
,
int
isdir2
);
/**
* Clean up a provided absolute or relative directory path.
*
...
...
src/tree.c
View file @
ccef1c9d
...
...
@@ -40,30 +40,12 @@ int entry_search_cmp(const void *key, const void *array_member)
return
strcmp
(
filename
,
entry
->
filename
);
}
static
int
cache_name_compare
(
const
char
*
name1
,
int
len1
,
int
isdir1
,
const
char
*
name2
,
int
len2
,
int
isdir2
)
{
int
len
=
len1
<
len2
?
len1
:
len2
;
int
cmp
;
cmp
=
memcmp
(
name1
,
name2
,
len
);
if
(
cmp
)
return
cmp
;
if
(
len1
<
len2
)
return
((
!
isdir1
&&
!
isdir2
)
?
-
1
:
(
isdir1
?
'/'
-
name2
[
len1
]
:
name2
[
len1
]
-
'/'
));
if
(
len1
>
len2
)
return
((
!
isdir1
&&
!
isdir2
)
?
1
:
(
isdir2
?
name1
[
len2
]
-
'/'
:
'/'
-
name1
[
len2
]));
return
0
;
}
int
entry_sort_cmp
(
const
void
*
a
,
const
void
*
b
)
{
const
git_tree_entry
*
entry_a
=
*
(
const
git_tree_entry
**
)(
a
);
const
git_tree_entry
*
entry_b
=
*
(
const
git_tree_entry
**
)(
b
);
return
cache_name_compare
(
entry_a
->
filename
,
strlen
(
entry_a
->
filename
),
return
gitfo_cmp_path
(
entry_a
->
filename
,
strlen
(
entry_a
->
filename
),
entry_a
->
attr
&
040000
,
entry_b
->
filename
,
strlen
(
entry_b
->
filename
),
entry_b
->
attr
&
040000
);
...
...
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