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
65fbc48a
Commit
65fbc48a
authored
Jun 24, 2011
by
Carlos Martín Nieto
Committed by
Vicent Marti
Aug 18, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
negotiation
parent
0132cf64
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
4 deletions
+76
-4
include/git2/net.h
+2
-0
src/fetch.c
+73
-3
src/pkt.c
+1
-1
No files found.
include/git2/net.h
View file @
65fbc48a
...
...
@@ -59,7 +59,9 @@ enum git_whn {
*/
struct
git_remote_head
{
enum
git_whn
type
;
int
local
;
/** Exists locally */
git_oid
oid
;
git_oid
loid
;
char
*
name
;
};
...
...
src/fetch.c
View file @
65fbc48a
...
...
@@ -26,6 +26,7 @@
#include "git2/remote.h"
#include "git2/oid.h"
#include "git2/refs.h"
#include "git2/revwalk.h"
#include "common.h"
#include "transport.h"
...
...
@@ -50,9 +51,10 @@ int git_fetch_list_want(git_headarray *whn_list, git_repository *repo, git_remot
git_headarray
refs
,
lrefs
;
git_transport
*
t
=
remote
->
transport
;
const
git_refspec
*
spec
;
int
error
,
i
;
int
error
;
unsigned
int
i
;
error
=
git_vector_init
(
&
list
,
16
,
whn_cmp
);
error
=
git_vector_init
(
&
list
,
whn_list
->
len
,
whn_cmp
);
if
(
error
<
GIT_SUCCESS
)
return
error
;
...
...
@@ -99,11 +101,15 @@ int git_fetch_list_want(git_headarray *whn_list, git_repository *repo, git_remot
if
(
ref
!=
NULL
)
{
if
(
!
git_oid_cmp
(
&
head
->
oid
,
git_reference_oid
(
ref
)))
continue
;
head
->
local
=
1
;
git_oid_cpy
(
&
head
->
loid
,
git_reference_oid
(
ref
));
}
/*
* Now we know we want to have that ref, so add it as a "want"
* to the list.
* to the list, storing the local oid for that branch so we
* don't have to look for it again.
*/
head
->
type
=
GIT_WHN_WANT
;
error
=
git_vector_insert
(
&
list
,
head
);
...
...
@@ -121,3 +127,67 @@ cleanup:
git_vector_free
(
&
list
);
return
error
;
}
/* Push any (OID) ref it gets into the walker */
static
int
push_stuff
(
const
char
*
name
,
void
*
data
)
{
git_revwalk
*
walk
=
(
git_revwalk
*
)
data
;
git_reference
*
ref
;
git_repository
*
repo
;
int
error
;
repo
=
git_revwalk_repository
(
walk
);
error
=
git_reference_lookup
(
&
ref
,
repo
,
name
);
if
(
error
<
GIT_SUCCESS
)
return
error
;
return
git_revwalk_push
(
walk
,
git_reference_oid
(
ref
));
}
/*
* In this first version, we push all our refs in and start sending
* them out. When we get an ACK we hide that commit and continue
* traversing until we're done
*/
int
git_fetch_negotiate
(
git_headarray
*
list
,
git_repository
*
repo
,
git_remote
*
remote
)
{
git_revwalk
*
walk
;
int
error
;
unsigned
int
i
;
char
local
[
1024
];
git_refspec
*
spec
;
error
=
git_revwalk_new
(
&
walk
,
repo
);
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to create walker"
);
for
(
i
=
0
;
i
<
list
->
len
;
++
i
)
{
git_reference
*
ref
;
git_remote_head
*
head
=
list
->
heads
[
i
];
if
(
!
head
->
local
)
continue
;
error
=
git_revwalk_push
(
walk
,
&
head
->
loid
);
if
(
error
<
GIT_SUCCESS
)
{
error
=
git__rethrow
(
error
,
"Failed to push a local OID"
);
goto
cleanup
;
}
}
/*
* Now we have everything set up so we can start tell the server
* what we want and what we have.
*/
git_pkt_send_wants
(
list
);
cleanup:
git_revwalk_free
(
walk
);
return
error
;
}
int
git_fetch_download_pack
(
git_remote
*
remote
)
{
return
GIT_ENOTIMPLEMENTED
;
}
src/pkt.c
View file @
65fbc48a
...
...
@@ -216,7 +216,7 @@ int git_pkt_send_flush(int s)
*/
#define WANT_PREFIX "0032want "
int
git_pkt_send_wants
(
git_headarray
*
refs
)
int
git_pkt_send_wants
(
git_headarray
*
refs
,
int
fd
)
{
unsigned
int
i
;
int
ret
=
GIT_SUCCESS
;
...
...
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