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
40a60510
Commit
40a60510
authored
Feb 11, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1324 from nulltoken/topic/remote_isvalidname
Topic/remote isvalidname
parents
390a3c81
2bca5b67
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
128 additions
and
76 deletions
+128
-76
include/git2/remote.h
+8
-0
src/refs.c
+9
-8
src/remote.c
+22
-14
tests-clar/network/remote/createthenload.c
+3
-3
tests-clar/network/remote/isvalidname.c
+17
-0
tests-clar/network/remote/local.c
+6
-6
tests-clar/network/remote/remotes.c
+46
-32
tests-clar/network/remote/rename.c
+13
-13
tests-clar/refs/isvalidname.c
+2
-0
tests-clar/refs/normalize.c
+2
-0
No files found.
include/git2/remote.h
View file @
40a60510
...
...
@@ -450,6 +450,14 @@ GIT_EXTERN(int) git_remote_update_fetchhead(git_remote *remote);
*/
GIT_EXTERN
(
void
)
git_remote_set_update_fetchhead
(
git_remote
*
remote
,
int
value
);
/**
* Ensure the remote name is well-formed.
*
* @param remote_name name to be checked.
* @return 1 if the reference name is acceptable; 0 if it isn't
*/
GIT_EXTERN
(
int
)
git_remote_is_valid_name
(
const
char
*
remote_name
);
/** @} */
GIT_END_DECL
#endif
src/refs.c
View file @
40a60510
...
...
@@ -1599,6 +1599,7 @@ static int ensure_segment_validity(const char *name)
{
const
char
*
current
=
name
;
char
prev
=
'\0'
;
int
lock_len
=
strlen
(
GIT_FILELOCK_EXTENSION
);
if
(
*
current
==
'.'
)
return
-
1
;
/* Refname starts with "." */
...
...
@@ -1619,6 +1620,11 @@ static int ensure_segment_validity(const char *name)
prev
=
*
current
;
}
/* A refname component can not end with ".lock" */
if
(
current
-
name
>=
lock_len
&&
!
memcmp
(
current
-
lock_len
,
GIT_FILELOCK_EXTENSION
,
lock_len
))
return
-
1
;
return
(
int
)(
current
-
name
);
}
...
...
@@ -1691,11 +1697,10 @@ int git_reference__normalize_name(
segments_count
++
;
}
/*
This means that there's a leading slash in the refname
*/
if
(
segment_len
==
0
&&
segments_count
==
0
)
{
/*
No empty segment is allowed when not normalizing
*/
if
(
segment_len
==
0
&&
!
normalize
)
goto
cleanup
;
}
if
(
current
[
segment_len
]
==
'\0'
)
break
;
...
...
@@ -1714,10 +1719,6 @@ int git_reference__normalize_name(
if
(
current
[
segment_len
-
1
]
==
'/'
)
goto
cleanup
;
/* A refname can not end with ".lock" */
if
(
!
git__suffixcmp
(
name
,
GIT_FILELOCK_EXTENSION
))
goto
cleanup
;
if
((
segments_count
==
1
)
&&
!
(
flags
&
GIT_REF_FORMAT_ALLOW_ONELEVEL
))
goto
cleanup
;
...
...
src/remote.c
View file @
40a60510
...
...
@@ -59,21 +59,9 @@ static int download_tags_value(git_remote *remote, git_config *cfg)
static
int
ensure_remote_name_is_valid
(
const
char
*
name
)
{
git_buf
buf
=
GIT_BUF_INIT
;
git_refspec
refspec
;
int
error
=
-
1
;
if
(
!
name
||
*
name
==
'\0'
)
goto
cleanup
;
git_buf_printf
(
&
buf
,
"refs/heads/test:refs/remotes/%s/test"
,
name
);
error
=
git_refspec__parse
(
&
refspec
,
git_buf_cstr
(
&
buf
),
true
);
git_buf_free
(
&
buf
);
git_refspec__free
(
&
refspec
);
int
error
=
0
;
cleanup:
if
(
error
)
{
if
(
!
git_remote_is_valid_name
(
name
))
{
giterr_set
(
GITERR_CONFIG
,
"'%s' is not a valid remote name."
,
name
);
...
...
@@ -1380,3 +1368,23 @@ void git_remote_set_update_fetchhead(git_remote *remote, int value)
{
remote
->
update_fetchhead
=
value
;
}
int
git_remote_is_valid_name
(
const
char
*
remote_name
)
{
git_buf
buf
=
GIT_BUF_INIT
;
git_refspec
refspec
;
int
error
=
-
1
;
if
(
!
remote_name
||
*
remote_name
==
'\0'
)
return
0
;
git_buf_printf
(
&
buf
,
"refs/heads/test:refs/remotes/%s/test"
,
remote_name
);
error
=
git_refspec__parse
(
&
refspec
,
git_buf_cstr
(
&
buf
),
true
);
git_buf_free
(
&
buf
);
git_refspec__free
(
&
refspec
);
giterr_clear
();
return
error
==
0
;
}
tests-clar/network/
createremo
tethenload.c
→
tests-clar/network/
remote/crea
tethenload.c
View file @
40a60510
...
...
@@ -5,7 +5,7 @@ static git_repository *_repo;
static
git_config
*
_config
;
static
char
url
[]
=
"http://github.com/libgit2/libgit2.git"
;
void
test_network_
createremo
tethenload__initialize
(
void
)
void
test_network_
remote_crea
tethenload__initialize
(
void
)
{
cl_fixture_sandbox
(
"testrepo.git"
);
...
...
@@ -19,7 +19,7 @@ void test_network_createremotethenload__initialize(void)
cl_git_pass
(
git_remote_load
(
&
_remote
,
_repo
,
"origin"
));
}
void
test_network_
createremo
tethenload__cleanup
(
void
)
void
test_network_
remote_crea
tethenload__cleanup
(
void
)
{
git_remote_free
(
_remote
);
_remote
=
NULL
;
...
...
@@ -30,7 +30,7 @@ void test_network_createremotethenload__cleanup(void)
cl_fixture_cleanup
(
"testrepo.git"
);
}
void
test_network_
createremo
tethenload__parsing
(
void
)
void
test_network_
remote_crea
tethenload__parsing
(
void
)
{
cl_assert_equal_s
(
git_remote_name
(
_remote
),
"origin"
);
cl_assert_equal_s
(
git_remote_url
(
_remote
),
url
);
...
...
tests-clar/network/remote/isvalidname.c
0 → 100644
View file @
40a60510
#include "clar_libgit2.h"
void
test_network_remote_isvalidname__can_detect_invalid_formats
(
void
)
{
cl_assert_equal_i
(
false
,
git_remote_is_valid_name
(
"/"
));
cl_assert_equal_i
(
false
,
git_remote_is_valid_name
(
"//"
));
cl_assert_equal_i
(
false
,
git_remote_is_valid_name
(
".lock"
));
cl_assert_equal_i
(
false
,
git_remote_is_valid_name
(
"a.lock"
));
cl_assert_equal_i
(
false
,
git_remote_is_valid_name
(
"/no/leading/slash"
));
cl_assert_equal_i
(
false
,
git_remote_is_valid_name
(
"no/trailing/slash/"
));
}
void
test_network_remote_isvalidname__wont_hopefully_choke_on_valid_formats
(
void
)
{
cl_assert_equal_i
(
true
,
git_remote_is_valid_name
(
"webmatrix"
));
cl_assert_equal_i
(
true
,
git_remote_is_valid_name
(
"yishaigalatzer/rules"
));
}
tests-clar/network/remotelocal.c
→
tests-clar/network/remote
/
local.c
View file @
40a60510
...
...
@@ -7,13 +7,13 @@ static git_repository *repo;
static
git_buf
file_path_buf
=
GIT_BUF_INIT
;
static
git_remote
*
remote
;
void
test_network_remotelocal__initialize
(
void
)
void
test_network_remote
_
local__initialize
(
void
)
{
cl_git_pass
(
git_repository_init
(
&
repo
,
"remotelocal/"
,
0
));
cl_assert
(
repo
!=
NULL
);
}
void
test_network_remotelocal__cleanup
(
void
)
void
test_network_remote
_
local__cleanup
(
void
)
{
git_buf_free
(
&
file_path_buf
);
...
...
@@ -55,7 +55,7 @@ static void connect_to_local_repository(const char *local_repository)
}
void
test_network_remotelocal__connected
(
void
)
void
test_network_remote
_
local__connected
(
void
)
{
connect_to_local_repository
(
cl_fixture
(
"testrepo.git"
));
cl_assert
(
git_remote_connected
(
remote
));
...
...
@@ -64,7 +64,7 @@ void test_network_remotelocal__connected(void)
cl_assert
(
!
git_remote_connected
(
remote
));
}
void
test_network_remotelocal__retrieve_advertised_references
(
void
)
void
test_network_remote
_
local__retrieve_advertised_references
(
void
)
{
int
how_many_refs
=
0
;
...
...
@@ -75,7 +75,7 @@ void test_network_remotelocal__retrieve_advertised_references(void)
cl_assert_equal_i
(
how_many_refs
,
26
);
}
void
test_network_remotelocal__retrieve_advertised_references_from_spaced_repository
(
void
)
void
test_network_remote
_
local__retrieve_advertised_references_from_spaced_repository
(
void
)
{
int
how_many_refs
=
0
;
...
...
@@ -94,7 +94,7 @@ void test_network_remotelocal__retrieve_advertised_references_from_spaced_reposi
cl_fixture_cleanup
(
"spaced testrepo.git"
);
}
void
test_network_remotelocal__nested_tags_are_completely_peeled
(
void
)
void
test_network_remote
_
local__nested_tags_are_completely_peeled
(
void
)
{
connect_to_local_repository
(
cl_fixture
(
"testrepo.git"
));
...
...
tests-clar/network/remotes.c
→
tests-clar/network/remote
/remote
s.c
View file @
40a60510
...
...
@@ -7,7 +7,7 @@ static git_remote *_remote;
static
git_repository
*
_repo
;
static
const
git_refspec
*
_refspec
;
void
test_network_remotes__initialize
(
void
)
void
test_network_remote
_remote
s__initialize
(
void
)
{
_repo
=
cl_git_sandbox_init
(
"testrepo.git"
);
...
...
@@ -17,7 +17,7 @@ void test_network_remotes__initialize(void)
cl_assert
(
_refspec
!=
NULL
);
}
void
test_network_remotes__cleanup
(
void
)
void
test_network_remote
_remote
s__cleanup
(
void
)
{
git_remote_free
(
_remote
);
_remote
=
NULL
;
...
...
@@ -25,7 +25,7 @@ void test_network_remotes__cleanup(void)
cl_git_sandbox_cleanup
();
}
void
test_network_remotes__parsing
(
void
)
void
test_network_remote
_remote
s__parsing
(
void
)
{
git_remote
*
_remote2
=
NULL
;
...
...
@@ -51,7 +51,7 @@ void test_network_remotes__parsing(void)
git_remote_free
(
_remote2
);
}
void
test_network_remotes__pushurl
(
void
)
void
test_network_remote
_remote
s__pushurl
(
void
)
{
cl_git_pass
(
git_remote_set_pushurl
(
_remote
,
"git://github.com/libgit2/notlibgit2"
));
cl_assert_equal_s
(
git_remote_pushurl
(
_remote
),
"git://github.com/libgit2/notlibgit2"
);
...
...
@@ -60,7 +60,7 @@ void test_network_remotes__pushurl(void)
cl_assert
(
git_remote_pushurl
(
_remote
)
==
NULL
);
}
void
test_network_remotes__error_when_no_push_available
(
void
)
void
test_network_remote
_remote
s__error_when_no_push_available
(
void
)
{
git_remote
*
r
;
git_transport
*
t
;
...
...
@@ -82,33 +82,33 @@ void test_network_remotes__error_when_no_push_available(void)
git_remote_free
(
r
);
}
void
test_network_remotes__parsing_ssh_remote
(
void
)
void
test_network_remote
_remote
s__parsing_ssh_remote
(
void
)
{
cl_assert
(
git_remote_valid_url
(
"git@github.com:libgit2/libgit2.git"
)
);
}
void
test_network_remotes__parsing_local_path_fails_if_path_not_found
(
void
)
void
test_network_remote
_remote
s__parsing_local_path_fails_if_path_not_found
(
void
)
{
cl_assert
(
!
git_remote_valid_url
(
"/home/git/repos/libgit2.git"
)
);
}
void
test_network_remotes__supported_transport_methods_are_supported
(
void
)
void
test_network_remote
_remote
s__supported_transport_methods_are_supported
(
void
)
{
cl_assert
(
git_remote_supported_url
(
"git://github.com/libgit2/libgit2"
)
);
}
void
test_network_remotes__unsupported_transport_methods_are_unsupported
(
void
)
void
test_network_remote
_remote
s__unsupported_transport_methods_are_unsupported
(
void
)
{
cl_assert
(
!
git_remote_supported_url
(
"git@github.com:libgit2/libgit2.git"
)
);
}
void
test_network_remotes__refspec_parsing
(
void
)
void
test_network_remote
_remote
s__refspec_parsing
(
void
)
{
cl_assert_equal_s
(
git_refspec_src
(
_refspec
),
"refs/heads/*"
);
cl_assert_equal_s
(
git_refspec_dst
(
_refspec
),
"refs/remotes/test/*"
);
}
void
test_network_remotes__set_fetchspec
(
void
)
void
test_network_remote
_remote
s__set_fetchspec
(
void
)
{
cl_git_pass
(
git_remote_set_fetchspec
(
_remote
,
"refs/*:refs/*"
));
_refspec
=
git_remote_fetchspec
(
_remote
);
...
...
@@ -116,7 +116,7 @@ void test_network_remotes__set_fetchspec(void)
cl_assert_equal_s
(
git_refspec_dst
(
_refspec
),
"refs/*"
);
}
void
test_network_remotes__set_pushspec
(
void
)
void
test_network_remote
_remote
s__set_pushspec
(
void
)
{
cl_git_pass
(
git_remote_set_pushspec
(
_remote
,
"refs/*:refs/*"
));
_refspec
=
git_remote_pushspec
(
_remote
);
...
...
@@ -124,7 +124,7 @@ void test_network_remotes__set_pushspec(void)
cl_assert_equal_s
(
git_refspec_dst
(
_refspec
),
"refs/*"
);
}
void
test_network_remotes__save
(
void
)
void
test_network_remote
_remote
s__save
(
void
)
{
git_remote_free
(
_remote
);
_remote
=
NULL
;
...
...
@@ -165,13 +165,13 @@ void test_network_remotes__save(void)
cl_assert
(
git_remote_pushurl
(
_remote
)
==
NULL
);
}
void
test_network_remotes__fnmatch
(
void
)
void
test_network_remote
_remote
s__fnmatch
(
void
)
{
cl_assert
(
git_refspec_src_matches
(
_refspec
,
"refs/heads/master"
));
cl_assert
(
git_refspec_src_matches
(
_refspec
,
"refs/heads/multi/level/branch"
));
}
void
test_network_remotes__transform
(
void
)
void
test_network_remote
_remote
s__transform
(
void
)
{
char
ref
[
1024
]
=
{
0
};
...
...
@@ -179,7 +179,7 @@ void test_network_remotes__transform(void)
cl_assert_equal_s
(
ref
,
"refs/remotes/test/master"
);
}
void
test_network_remotes__transform_destination_to_source
(
void
)
void
test_network_remote
_remote
s__transform_destination_to_source
(
void
)
{
char
ref
[
1024
]
=
{
0
};
...
...
@@ -187,7 +187,7 @@ void test_network_remotes__transform_destination_to_source(void)
cl_assert_equal_s
(
ref
,
"refs/heads/master"
);
}
void
test_network_remotes__transform_r
(
void
)
void
test_network_remote
_remote
s__transform_r
(
void
)
{
git_buf
buf
=
GIT_BUF_INIT
;
...
...
@@ -196,7 +196,7 @@ void test_network_remotes__transform_r(void)
git_buf_free
(
&
buf
);
}
void
test_network_remotes__missing_refspecs
(
void
)
void
test_network_remote
_remote
s__missing_refspecs
(
void
)
{
git_config
*
cfg
;
...
...
@@ -210,7 +210,7 @@ void test_network_remotes__missing_refspecs(void)
git_config_free
(
cfg
);
}
void
test_network_remotes__list
(
void
)
void
test_network_remote
_remote
s__list
(
void
)
{
git_strarray
list
;
git_config
*
cfg
;
...
...
@@ -228,7 +228,7 @@ void test_network_remotes__list(void)
git_config_free
(
cfg
);
}
void
test_network_remotes__loading_a_missing_remote_returns_ENOTFOUND
(
void
)
void
test_network_remote
_remote
s__loading_a_missing_remote_returns_ENOTFOUND
(
void
)
{
git_remote_free
(
_remote
);
_remote
=
NULL
;
...
...
@@ -236,7 +236,7 @@ void test_network_remotes__loading_a_missing_remote_returns_ENOTFOUND(void)
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_remote_load
(
&
_remote
,
_repo
,
"just-left-few-minutes-ago"
));
}
void
test_network_remotes__loading_with_an_invalid_name_returns_EINVALIDSPEC
(
void
)
void
test_network_remote
_remote
s__loading_with_an_invalid_name_returns_EINVALIDSPEC
(
void
)
{
git_remote_free
(
_remote
);
_remote
=
NULL
;
...
...
@@ -253,7 +253,7 @@ void test_network_remotes__loading_with_an_invalid_name_returns_EINVALIDSPEC(voi
* url = http://github.com/libgit2/libgit2
* fetch = +refs/heads/\*:refs/remotes/addtest/\*
*/
void
test_network_remotes__add
(
void
)
void
test_network_remote
_remote
s__add
(
void
)
{
git_remote_free
(
_remote
);
_remote
=
NULL
;
...
...
@@ -271,7 +271,7 @@ void test_network_remotes__add(void)
cl_assert_equal_s
(
git_remote_url
(
_remote
),
"http://github.com/libgit2/libgit2"
);
}
void
test_network_remotes__cannot_add_a_nameless_remote
(
void
)
void
test_network_remote
_remote
s__cannot_add_a_nameless_remote
(
void
)
{
git_remote
*
remote
;
...
...
@@ -280,7 +280,7 @@ void test_network_remotes__cannot_add_a_nameless_remote(void)
git_remote_create
(
&
remote
,
_repo
,
NULL
,
"git://github.com/libgit2/libgit2"
));
}
void
test_network_remotes__cannot_save_an_inmemory_remote
(
void
)
void
test_network_remote
_remote
s__cannot_save_an_inmemory_remote
(
void
)
{
git_remote
*
remote
;
...
...
@@ -292,7 +292,7 @@ void test_network_remotes__cannot_save_an_inmemory_remote(void)
git_remote_free
(
remote
);
}
void
test_network_remotes__cannot_add_a_remote_with_an_invalid_name
(
void
)
void
test_network_remote
_remote
s__cannot_add_a_remote_with_an_invalid_name
(
void
)
{
git_remote
*
remote
=
NULL
;
...
...
@@ -307,7 +307,7 @@ void test_network_remotes__cannot_add_a_remote_with_an_invalid_name(void)
cl_assert_equal_p
(
remote
,
NULL
);
}
void
test_network_remotes__tagopt
(
void
)
void
test_network_remote
_remote
s__tagopt
(
void
)
{
const
char
*
opt
;
git_config
*
cfg
;
...
...
@@ -331,7 +331,7 @@ void test_network_remotes__tagopt(void)
git_config_free
(
cfg
);
}
void
test_network_remotes__cannot_load_with_an_empty_url
(
void
)
void
test_network_remote
_remote
s__cannot_load_with_an_empty_url
(
void
)
{
git_remote
*
remote
=
NULL
;
...
...
@@ -340,7 +340,7 @@ void test_network_remotes__cannot_load_with_an_empty_url(void)
cl_assert_equal_p
(
remote
,
NULL
);
}
void
test_network_remotes__check_structure_version
(
void
)
void
test_network_remote
_remote
s__check_structure_version
(
void
)
{
git_transport
transport
=
GIT_TRANSPORT_INIT
;
const
git_error
*
err
;
...
...
@@ -361,13 +361,27 @@ void test_network_remotes__check_structure_version(void)
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
}
void
test_network_remotes__cannot_create_a_remote_which_name_conflicts_with_an_existing_remote
(
void
)
void
assert_cannot_create_remote
(
const
char
*
name
,
int
expected_error
)
{
git_remote
*
remote
=
NULL
;
cl_
assert_equal_i
(
GIT_EEXISTS
,
git_remote_create
(
&
remote
,
_repo
,
"test"
,
"git://github.com/libgit2/libgit2"
)
);
cl_
git_fail_with
(
git_remote_create
(
&
remote
,
_repo
,
name
,
"git://github.com/libgit2/libgit2"
)
,
expected_error
);
cl_assert_equal_p
(
remote
,
NULL
);
}
void
test_network_remote_remotes__cannot_create_a_remote_which_name_conflicts_with_an_existing_remote
(
void
)
{
assert_cannot_create_remote
(
"test"
,
GIT_EEXISTS
);
}
void
test_network_remote_remotes__cannot_create_a_remote_which_name_is_invalid
(
void
)
{
assert_cannot_create_remote
(
"/"
,
GIT_EINVALIDSPEC
);
assert_cannot_create_remote
(
"//"
,
GIT_EINVALIDSPEC
);
assert_cannot_create_remote
(
".lock"
,
GIT_EINVALIDSPEC
);
assert_cannot_create_remote
(
"a.lock"
,
GIT_EINVALIDSPEC
);
}
tests-clar/network/remoterename.c
→
tests-clar/network/remote
/
rename.c
View file @
40a60510
...
...
@@ -6,14 +6,14 @@
static
git_remote
*
_remote
;
static
git_repository
*
_repo
;
void
test_network_remoterename__initialize
(
void
)
void
test_network_remote
_
rename__initialize
(
void
)
{
_repo
=
cl_git_sandbox_init
(
"testrepo.git"
);
cl_git_pass
(
git_remote_load
(
&
_remote
,
_repo
,
"test"
));
}
void
test_network_remoterename__cleanup
(
void
)
void
test_network_remote
_
rename__cleanup
(
void
)
{
git_remote_free
(
_remote
);
_remote
=
NULL
;
...
...
@@ -31,7 +31,7 @@ static int dont_call_me_cb(const char *fetch_refspec, void *payload)
return
-
1
;
}
void
test_network_remoterename__renaming_a_remote_moves_related_configuration_section
(
void
)
void
test_network_remote
_
rename__renaming_a_remote_moves_related_configuration_section
(
void
)
{
assert_config_entry_existence
(
_repo
,
"remote.test.fetch"
,
true
);
assert_config_entry_existence
(
_repo
,
"remote.just/renamed.fetch"
,
false
);
...
...
@@ -42,7 +42,7 @@ void test_network_remoterename__renaming_a_remote_moves_related_configuration_se
assert_config_entry_existence
(
_repo
,
"remote.just/renamed.fetch"
,
true
);
}
void
test_network_remoterename__renaming_a_remote_updates_branch_related_configuration_entries
(
void
)
void
test_network_remote
_
rename__renaming_a_remote_updates_branch_related_configuration_entries
(
void
)
{
assert_config_entry_value
(
_repo
,
"branch.master.remote"
,
"test"
);
...
...
@@ -51,14 +51,14 @@ void test_network_remoterename__renaming_a_remote_updates_branch_related_configu
assert_config_entry_value
(
_repo
,
"branch.master.remote"
,
"just/renamed"
);
}
void
test_network_remoterename__renaming_a_remote_updates_default_fetchrefspec
(
void
)
void
test_network_remote
_
rename__renaming_a_remote_updates_default_fetchrefspec
(
void
)
{
cl_git_pass
(
git_remote_rename
(
_remote
,
"just/renamed"
,
dont_call_me_cb
,
NULL
));
assert_config_entry_value
(
_repo
,
"remote.just/renamed.fetch"
,
"+refs/heads/*:refs/remotes/just/renamed/*"
);
}
void
test_network_remoterename__renaming_a_remote_without_a_fetchrefspec_doesnt_create_one
(
void
)
void
test_network_remote
_
rename__renaming_a_remote_without_a_fetchrefspec_doesnt_create_one
(
void
)
{
git_config
*
config
;
...
...
@@ -94,7 +94,7 @@ static int ensure_refspecs(const char* refspec_name, void *payload)
return
0
;
}
void
test_network_remoterename__renaming_a_remote_notifies_of_non_default_fetchrefspec
(
void
)
void
test_network_remote
_
rename__renaming_a_remote_notifies_of_non_default_fetchrefspec
(
void
)
{
git_config
*
config
;
...
...
@@ -113,20 +113,20 @@ void test_network_remoterename__renaming_a_remote_notifies_of_non_default_fetchr
assert_config_entry_value
(
_repo
,
"remote.just/renamed.fetch"
,
"+refs/*:refs/*"
);
}
void
test_network_remoterename__new_name_can_contain_dots
(
void
)
void
test_network_remote
_
rename__new_name_can_contain_dots
(
void
)
{
cl_git_pass
(
git_remote_rename
(
_remote
,
"just.renamed"
,
dont_call_me_cb
,
NULL
));
cl_assert_equal_s
(
"just.renamed"
,
git_remote_name
(
_remote
));
}
void
test_network_remoterename__new_name_must_conform_to_reference_naming_conventions
(
void
)
void
test_network_remote
_
rename__new_name_must_conform_to_reference_naming_conventions
(
void
)
{
cl_assert_equal_i
(
GIT_EINVALIDSPEC
,
git_remote_rename
(
_remote
,
"new@{name"
,
dont_call_me_cb
,
NULL
));
}
void
test_network_remoterename__renamed_name_is_persisted
(
void
)
void
test_network_remote
_
rename__renamed_name_is_persisted
(
void
)
{
git_remote
*
renamed
;
git_repository
*
another_repo
;
...
...
@@ -142,13 +142,13 @@ void test_network_remoterename__renamed_name_is_persisted(void)
git_repository_free
(
another_repo
);
}
void
test_network_remoterename__cannot_overwrite_an_existing_remote
(
void
)
void
test_network_remote
_
rename__cannot_overwrite_an_existing_remote
(
void
)
{
cl_assert_equal_i
(
GIT_EEXISTS
,
git_remote_rename
(
_remote
,
"test"
,
dont_call_me_cb
,
NULL
));
cl_assert_equal_i
(
GIT_EEXISTS
,
git_remote_rename
(
_remote
,
"test_with_pushurl"
,
dont_call_me_cb
,
NULL
));
}
void
test_network_remoterename__renaming_a_remote_moves_the_underlying_reference
(
void
)
void
test_network_remote
_
rename__renaming_a_remote_moves_the_underlying_reference
(
void
)
{
git_reference
*
underlying
;
...
...
@@ -163,7 +163,7 @@ void test_network_remoterename__renaming_a_remote_moves_the_underlying_reference
git_reference_free
(
underlying
);
}
void
test_network_remoterename__cannot_rename_an_inmemory_remote
(
void
)
void
test_network_remote
_
rename__cannot_rename_an_inmemory_remote
(
void
)
{
git_remote
*
remote
;
...
...
tests-clar/refs/isvalidname.c
View file @
40a60510
...
...
@@ -12,7 +12,9 @@ void test_refs_isvalidname__can_detect_invalid_formats(void)
cl_assert_equal_i
(
false
,
git_reference_is_valid_name
(
"lower_case"
));
cl_assert_equal_i
(
false
,
git_reference_is_valid_name
(
"/stupid/name/master"
));
cl_assert_equal_i
(
false
,
git_reference_is_valid_name
(
"/"
));
cl_assert_equal_i
(
false
,
git_reference_is_valid_name
(
"//"
));
cl_assert_equal_i
(
false
,
git_reference_is_valid_name
(
""
));
cl_assert_equal_i
(
false
,
git_reference_is_valid_name
(
"refs/heads/sub.lock/webmatrix"
));
}
void
test_refs_isvalidname__wont_hopefully_choke_on_valid_formats
(
void
)
...
...
tests-clar/refs/normalize.c
View file @
40a60510
...
...
@@ -89,6 +89,8 @@ void test_refs_normalize__symbolic(void)
ensure_refname_invalid
(
GIT_REF_FORMAT_ALLOW_ONELEVEL
,
"heads
\f
oo"
);
ensure_refname_invalid
(
GIT_REF_FORMAT_ALLOW_ONELEVEL
,
"/"
);
ensure_refname_invalid
(
GIT_REF_FORMAT_ALLOW_ONELEVEL
,
"///"
);
ensure_refname_normalized
(
...
...
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