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
53ba8c9e
Commit
53ba8c9e
authored
Sep 09, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3415 from ethomson/lock_hidden
filebuf: ensure we can lock a hidden file
parents
c1770aeb
8e736a73
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
0 deletions
+94
-0
tests/core/filebuf.c
+26
-0
tests/core/futils.c
+68
-0
No files found.
tests/core/filebuf.c
View file @
53ba8c9e
...
...
@@ -204,3 +204,29 @@ void test_core_filebuf__symlink_depth(void)
cl_git_pass
(
git_futils_rmdir_r
(
dir
,
NULL
,
GIT_RMDIR_REMOVE_FILES
));
}
void
test_core_filebuf__hidden_file
(
void
)
{
#ifndef GIT_WIN32
cl_skip
();
#else
git_filebuf
file
=
GIT_FILEBUF_INIT
;
char
*
dir
=
"hidden"
,
*
test
=
"hidden/test"
;
bool
hidden
;
cl_git_pass
(
p_mkdir
(
dir
,
0666
));
cl_git_mkfile
(
test
,
"dummy content"
);
cl_git_pass
(
git_win32__set_hidden
(
test
,
true
));
cl_git_pass
(
git_win32__hidden
(
&
hidden
,
test
));
cl_assert
(
hidden
);
cl_git_pass
(
git_filebuf_open
(
&
file
,
test
,
0
,
0666
));
cl_git_pass
(
git_filebuf_printf
(
&
file
,
"%s
\n
"
,
"libgit2 rocks"
));
cl_git_pass
(
git_filebuf_commit
(
&
file
));
git_filebuf_cleanup
(
&
file
);
#endif
}
tests/core/futils.c
0 → 100644
View file @
53ba8c9e
#include "clar_libgit2.h"
#include "fileops.h"
// Fixture setup and teardown
void
test_core_futils__initialize
(
void
)
{
cl_must_pass
(
p_mkdir
(
"futils"
,
0777
));
}
void
test_core_futils__cleanup
(
void
)
{
cl_fixture_cleanup
(
"futils"
);
}
void
test_core_futils__writebuffer
(
void
)
{
git_buf
out
=
GIT_BUF_INIT
,
append
=
GIT_BUF_INIT
;
/* create a new file */
git_buf_puts
(
&
out
,
"hello!
\n
"
);
git_buf_printf
(
&
out
,
"this is a %s
\n
"
,
"test"
);
cl_git_pass
(
git_futils_writebuffer
(
&
out
,
"futils/test-file"
,
O_RDWR
|
O_CREAT
,
0666
));
cl_assert_equal_file
(
out
.
ptr
,
out
.
size
,
"futils/test-file"
);
/* append some more data */
git_buf_puts
(
&
append
,
"And some more!
\n
"
);
git_buf_put
(
&
out
,
append
.
ptr
,
append
.
size
);
cl_git_pass
(
git_futils_writebuffer
(
&
append
,
"futils/test-file"
,
O_RDWR
|
O_APPEND
,
0666
));
cl_assert_equal_file
(
out
.
ptr
,
out
.
size
,
"futils/test-file"
);
git_buf_free
(
&
out
);
git_buf_free
(
&
append
);
}
void
test_core_futils__write_hidden_file
(
void
)
{
#ifndef GIT_WIN32
cl_skip
();
#else
git_buf
out
=
GIT_BUF_INIT
,
append
=
GIT_BUF_INIT
;
bool
hidden
;
git_buf_puts
(
&
out
,
"hidden file.
\n
"
);
git_futils_writebuffer
(
&
out
,
"futils/test-file"
,
O_RDWR
|
O_CREAT
,
0666
);
cl_git_pass
(
git_win32__set_hidden
(
"futils/test-file"
,
true
));
/* append some more data */
git_buf_puts
(
&
append
,
"And some more!
\n
"
);
git_buf_put
(
&
out
,
append
.
ptr
,
append
.
size
);
cl_git_pass
(
git_futils_writebuffer
(
&
append
,
"futils/test-file"
,
O_RDWR
|
O_APPEND
,
0666
));
cl_assert_equal_file
(
out
.
ptr
,
out
.
size
,
"futils/test-file"
);
cl_git_pass
(
git_win32__hidden
(
&
hidden
,
"futils/test-file"
));
cl_assert
(
hidden
);
git_buf_free
(
&
out
);
git_buf_free
(
&
append
);
#endif
}
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