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
4d811c3b
Commit
4d811c3b
authored
Feb 07, 2013
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refs: No component of a refname can end with '.lock'
parent
624924e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
src/refs.c
+6
-4
tests-clar/refs/isvalidname.c
+1
-0
No files found.
src/refs.c
View file @
4d811c3b
...
...
@@ -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
&&
!
git__strncmp
(
current
-
lock_len
,
GIT_FILELOCK_EXTENSION
,
lock_len
))
return
-
1
;
return
(
int
)(
current
-
name
);
}
...
...
@@ -1714,10 +1720,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
;
...
...
tests-clar/refs/isvalidname.c
View file @
4d811c3b
...
...
@@ -13,6 +13,7 @@ void test_refs_isvalidname__can_detect_invalid_formats(void)
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
(
"refs/heads/sub.lock/webmatrix"
));
}
void
test_refs_isvalidname__wont_hopefully_choke_on_valid_formats
(
void
)
...
...
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