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
10063aeb
Commit
10063aeb
authored
Oct 01, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transport-git: Encapsulation ist gut
parent
657ce4b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
src/transport_git.c
+11
-16
No files found.
src/transport_git.c
View file @
10063aeb
...
...
@@ -36,13 +36,12 @@ typedef struct {
*
* For example: 0035git-upload-pack /libgit2/libgit2\0host=github.com\0
*/
static
int
gen_proto
(
char
**
out
,
int
*
outlen
,
const
char
*
cmd
,
const
char
*
url
)
static
int
gen_proto
(
git_buf
*
request
,
const
char
*
cmd
,
const
char
*
url
)
{
char
*
delim
,
*
repo
;
char
default_command
[]
=
"git-upload-pack"
;
char
host
[]
=
"host="
;
int
len
;
git_buf
buf
=
GIT_BUF_INIT
;
delim
=
strchr
(
url
,
'/'
);
if
(
delim
==
NULL
)
...
...
@@ -59,31 +58,27 @@ static int gen_proto(char **out, int *outlen, const char *cmd, const char *url)
len
=
4
+
strlen
(
cmd
)
+
1
+
strlen
(
repo
)
+
1
+
strlen
(
host
)
+
(
delim
-
url
)
+
1
+
1
;
git_buf_grow
(
&
buf
,
len
);
git_buf_grow
(
request
,
len
);
git_buf_printf
(
request
,
"%04x%s %s%c%s"
,
len
,
cmd
,
repo
,
0
,
host
);
git_buf_put
(
request
,
url
,
delim
-
url
);
git_buf_putc
(
request
,
'\0'
);
git_buf_printf
(
&
buf
,
"%04x%s %s%c%s"
,
len
,
cmd
,
repo
,
0
,
host
);
git_buf_put
(
&
buf
,
url
,
delim
-
url
);
git_buf_putc
(
&
buf
,
'\0'
);
*
outlen
=
len
;
*
out
=
buf
.
ptr
;
return
GIT_SUCCESS
;
return
git_buf_oom
(
request
);
}
static
int
send_request
(
GIT_SOCKET
s
,
const
char
*
cmd
,
const
char
*
url
)
{
int
error
,
len
;
char
*
msg
=
NULL
;
int
error
;
git_buf
request
=
GIT_BUF_INIT
;
error
=
gen_proto
(
&
msg
,
&
len
,
cmd
,
url
);
error
=
gen_proto
(
&
request
,
cmd
,
url
);
if
(
error
<
GIT_SUCCESS
)
goto
cleanup
;
error
=
gitno_send
(
s
,
msg
,
len
,
0
);
error
=
gitno_send
(
s
,
request
.
ptr
,
request
.
size
,
0
);
cleanup:
free
(
msg
);
git_buf_free
(
&
request
);
return
error
;
}
...
...
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