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
412b3887
Commit
412b3887
authored
Feb 05, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new utility method `git__joinpath`
Signed-off-by: Vicent Marti <tanoku@gmail.com>
parent
f725931b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
src/util.c
+24
-0
src/util.h
+8
-0
No files found.
src/util.c
View file @
412b3887
...
...
@@ -202,6 +202,30 @@ const char *git__topdir(const char *path)
return
&
path
[
i
+
1
];
}
char
*
git__joinpath
(
const
char
*
path_a
,
const
char
*
path_b
)
{
int
len_a
,
len_b
;
char
*
path_new
;
len_a
=
strlen
(
path_a
);
len_b
=
strlen
(
path_b
);
path_new
=
git__malloc
(
len_a
+
len_b
+
2
);
if
(
path_new
==
NULL
)
return
NULL
;
strcpy
(
path_new
,
path_a
);
if
(
path_new
[
len_a
-
1
]
!=
'/'
)
path_new
[
len_a
++
]
=
'/'
;
if
(
path_b
[
0
]
==
'/'
)
path_b
++
;
strcpy
(
path_new
+
len_a
,
path_b
);
return
path_new
;
}
static
char
*
strtok_raw
(
char
*
output
,
char
*
src
,
char
*
delimit
,
int
keep
)
{
while
(
*
src
&&
strchr
(
delimit
,
*
src
)
==
NULL
)
...
...
src/util.h
View file @
412b3887
...
...
@@ -58,6 +58,14 @@ extern int git__basename_r(char *buffer, size_t bufflen, const char *path);
extern
const
char
*
git__topdir
(
const
char
*
path
);
/**
* Join two paths together. Takes care of properly fixing the
* middle slashes and everything
*
* Returns a newly allocated string; must be free'd manually.
*/
extern
char
*
git__joinpath
(
const
char
*
path_a
,
const
char
*
path_b
);
extern
void
git__hexdump
(
const
char
*
buffer
,
size_t
n
);
extern
uint32_t
git__hash
(
const
void
*
key
,
int
len
,
uint32_t
seed
);
...
...
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