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
fdb116b3
Commit
fdb116b3
authored
Jun 20, 2018
by
Etienne Samson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remote: add a creation flag for ignoring url.insteadOf
parent
3cbaebdf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletions
+29
-1
include/git2/remote.h
+11
-0
src/remote.c
+1
-1
tests/remote/create.c
+17
-0
No files found.
include/git2/remote.h
View file @
fdb116b3
...
...
@@ -42,6 +42,14 @@ GIT_EXTERN(int) git_remote_create(
const
char
*
url
);
/**
* Remote creation options flags
*/
typedef
enum
{
/** Ignore the repository apply.insteadOf configuration */
GIT_REMOTE_CREATE_SKIP_INSTEADOF
=
(
1
<<
0
),
}
git_remote_create_flags
;
/**
* Remote creation options structure
*
* Initialize with `GIT_REMOTE_CREATE_OPTIONS_INIT`. Alternatively, you can
...
...
@@ -65,6 +73,9 @@ typedef struct git_remote_create_options {
/** The fetchspec the remote should use. */
const
char
*
fetchspec
;
/** Additional flags for the remote. See git_remote_create_flags. */
unsigned
int
flags
;
}
git_remote_create_options
;
#define GIT_REMOTE_CREATE_OPTIONS_VERSION 1
...
...
src/remote.c
View file @
fdb116b3
...
...
@@ -264,7 +264,7 @@ static int create_internal(git_remote **out, const char *url, const git_remote_c
(
error
=
canonicalize_url
(
&
canonical_url
,
url
))
<
0
)
goto
on_error
;
if
(
opts
->
repository
)
{
if
(
opts
->
repository
&&
!
(
opts
->
flags
&
GIT_REMOTE_CREATE_SKIP_INSTEADOF
)
)
{
remote
->
url
=
apply_insteadof
(
config_ro
,
canonical_url
.
ptr
,
GIT_DIRECTION_FETCH
);
}
else
{
remote
->
url
=
git__strdup
(
canonical_url
.
ptr
);
...
...
tests/remote/create.c
View file @
fdb116b3
...
...
@@ -311,6 +311,23 @@ void test_remote_create__with_opts_detached(void)
git_remote_free
(
remote
);
}
void
test_remote_create__with_opts_insteadof_disabled
(
void
)
{
git_remote
*
remote
;
git_remote_create_options
opts
=
GIT_REMOTE_CREATE_OPTIONS_INIT
;
opts
.
repository
=
_repo
;
opts
.
flags
=
GIT_REMOTE_CREATE_SKIP_INSTEADOF
;
cl_git_pass
(
git_remote_create_with_opts
(
&
remote
,
"http://example.com/libgit2/libgit2"
,
&
opts
));
cl_assert_equal_s
(
git_remote_url
(
remote
),
"http://example.com/libgit2/libgit2"
);
cl_assert_equal_p
(
git_remote_pushurl
(
remote
),
NULL
);
git_remote_free
(
remote
);
}
static
int
create_with_name
(
git_remote
**
remote
,
git_repository
*
repo
,
const
char
*
name
,
const
char
*
url
)
{
git_remote_create_options
opts
=
GIT_REMOTE_CREATE_OPTIONS_INIT
;
...
...
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