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
d6d52348
Commit
d6d52348
authored
Sep 01, 2013
by
Krzysztof Adamski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing unneeded code duplication in ls-remote.c
parent
ac2e7dc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
33 deletions
+7
-33
examples/network/ls-remote.c
+7
-33
No files found.
examples/network/ls-remote.c
View file @
d6d52348
...
...
@@ -14,31 +14,6 @@ static int show_ref__cb(git_remote_head *head, void *payload)
return
0
;
}
static
int
use_unnamed
(
git_repository
*
repo
,
const
char
*
url
)
{
git_remote
*
remote
=
NULL
;
int
error
;
// Create an instance of a remote from the URL. The transport to use
// is detected from the URL
error
=
git_remote_create_inmemory
(
&
remote
,
repo
,
NULL
,
url
);
if
(
error
<
0
)
goto
cleanup
;
// When connecting, the underlying code needs to know wether we
// want to push or fetch
error
=
git_remote_connect
(
remote
,
GIT_DIRECTION_FETCH
);
if
(
error
<
0
)
goto
cleanup
;
// With git_remote_ls we can retrieve the advertised heads
error
=
git_remote_ls
(
remote
,
&
show_ref__cb
,
NULL
);
cleanup:
git_remote_free
(
remote
);
return
error
;
}
static
int
use_remote
(
git_repository
*
repo
,
char
*
name
)
{
git_remote
*
remote
=
NULL
;
...
...
@@ -46,8 +21,12 @@ static int use_remote(git_repository *repo, char *name)
// Find the remote by name
error
=
git_remote_load
(
&
remote
,
repo
,
name
);
if
(
error
<
0
)
goto
cleanup
;
if
(
error
<
0
)
{
error
=
git_remote_create_inmemory
(
&
remote
,
repo
,
NULL
,
name
);
if
(
error
<
0
)
goto
cleanup
;
}
error
=
git_remote_connect
(
remote
,
GIT_DIRECTION_FETCH
);
if
(
error
<
0
)
...
...
@@ -72,12 +51,7 @@ int ls_remote(git_repository *repo, int argc, char **argv)
return
EXIT_FAILURE
;
}
/* If there's a ':' in the name, assume it's an URL */
if
(
strchr
(
argv
[
1
],
':'
)
!=
NULL
)
{
error
=
use_unnamed
(
repo
,
argv
[
1
]);
}
else
{
error
=
use_remote
(
repo
,
argv
[
1
]);
}
error
=
use_remote
(
repo
,
argv
[
1
]);
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