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
677a3c07
Commit
677a3c07
authored
Mar 15, 2011
by
nulltoken
Committed by
Vicent Marti
Mar 23, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add failing test for issue 84
see
https://github.com/libgit2/libgit2/issues#issue/84
parent
ae6ba7f7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
0 deletions
+55
-0
src/fileops.c
+31
-0
src/fileops.h
+2
-0
tests/t12-repo.c
+22
-0
No files found.
src/fileops.c
View file @
677a3c07
...
@@ -633,3 +633,34 @@ int gitfo_cmp_path(const char *name1, int len1, int isdir1,
...
@@ -633,3 +633,34 @@ int gitfo_cmp_path(const char *name1, int len1, int isdir1,
return
0
;
return
0
;
}
}
static
void
posixify_path
(
char
*
path
)
{
while
(
*
path
)
{
if
(
*
path
==
'\\'
)
*
path
=
'/'
;
path
++
;
}
}
int
gitfo_getcwd
(
char
*
buffer_out
,
size_t
size
)
{
char
*
cwd_buffer
;
assert
(
buffer_out
&&
size
>
0
);
#ifdef GIT_WIN32
cwd_buffer
=
_getcwd
(
buffer_out
,
size
);
#else
cwd_buffer
=
getcwd
(
buffer_out
,
size
);
//TODO: Fixme. Ensure the required headers are correctly included
#endif
if
(
cwd_buffer
==
NULL
)
return
GIT_EOSERR
;
posixify_path
(
buffer_out
);
git__joinpath
(
buffer_out
,
buffer_out
,
""
);
//Ensure the path ends with a trailing slash
return
GIT_SUCCESS
;
}
src/fileops.h
View file @
677a3c07
...
@@ -144,6 +144,8 @@ extern int gitfo_close_cached(gitfo_cache *ioc);
...
@@ -144,6 +144,8 @@ extern int gitfo_close_cached(gitfo_cache *ioc);
extern
int
gitfo_cmp_path
(
const
char
*
name1
,
int
len1
,
int
isdir1
,
extern
int
gitfo_cmp_path
(
const
char
*
name1
,
int
len1
,
int
isdir1
,
const
char
*
name2
,
int
len2
,
int
isdir2
);
const
char
*
name2
,
int
len2
,
int
isdir2
);
extern
int
gitfo_getcwd
(
char
*
buffer_out
,
size_t
size
);
/**
/**
* Clean up a provided absolute or relative directory path.
* Clean up a provided absolute or relative directory path.
*
*
...
...
tests/t12-repo.c
View file @
677a3c07
...
@@ -162,11 +162,33 @@ BEGIN_TEST(init1, "initialize a bare repo")
...
@@ -162,11 +162,33 @@ BEGIN_TEST(init1, "initialize a bare repo")
must_pass
(
ensure_repository_init
(
TEMP_REPO_FOLDER_NS
,
BARE_REPOSITORY
,
NULL
,
path_repository
,
NULL
));
must_pass
(
ensure_repository_init
(
TEMP_REPO_FOLDER_NS
,
BARE_REPOSITORY
,
NULL
,
path_repository
,
NULL
));
END_TEST
END_TEST
BEGIN_TEST
(
init2
,
"Initialize a bare repo with a relative path escaping out of the current working directory"
)
char
path_repository
[
GIT_PATH_MAX
];
char
current_workdir
[
GIT_PATH_MAX
];
const
int
mode
=
0755
;
/* or 0777 ? */
git_repository
*
repo
;
must_pass
(
gitfo_getcwd
(
current_workdir
,
sizeof
(
current_workdir
)));
git__joinpath
(
path_repository
,
current_workdir
,
"a/b/c/"
);
must_pass
(
gitfo_mkdir_recurs
(
path_repository
,
mode
));
must_pass
(
chdir
(
path_repository
));
must_pass
(
git_repository_init
(
&
repo
,
"../d/e.git"
,
1
));
git_repository_free
(
repo
);
must_pass
(
chdir
(
current_workdir
));
git__joinpath
(
path_repository
,
current_workdir
,
"a/"
);
must_pass
(
rmdir_recurs
(
path_repository
));
END_TEST
BEGIN_SUITE
(
repository
)
BEGIN_SUITE
(
repository
)
ADD_TEST
(
odb0
);
ADD_TEST
(
odb0
);
ADD_TEST
(
odb1
);
ADD_TEST
(
odb1
);
ADD_TEST
(
init0
);
ADD_TEST
(
init0
);
ADD_TEST
(
init1
);
ADD_TEST
(
init1
);
ADD_TEST
(
init2
);
END_SUITE
END_SUITE
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