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
4e3949b7
Commit
4e3949b7
authored
Jan 30, 2019
by
Etienne Samson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: test that largefiles can be read through the tree API
parent
cf14215d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
0 deletions
+77
-0
src/posix.c
+17
-0
src/posix.h
+1
-0
src/win32/posix_w32.c
+6
-0
tests/object/tree/read.c
+53
-0
No files found.
src/posix.c
View file @
4e3949b7
...
@@ -216,6 +216,23 @@ int p_write(git_file fd, const void *buf, size_t cnt)
...
@@ -216,6 +216,23 @@ int p_write(git_file fd, const void *buf, size_t cnt)
return
0
;
return
0
;
}
}
int
p_fallocate
(
int
fd
,
off_t
offset
,
off_t
len
)
{
#ifdef __APPLE__
fstore_t
prealloc
;
memset
(
&
prealloc
,
0
,
sizeof
(
prealloc
));
prealloc
.
fst_flags
=
F_ALLOCATEALL
;
prealloc
.
fst_posmode
=
F_PEOFPOSMODE
;
prealloc
.
fst_offset
=
offset
;
prealloc
.
fst_length
=
len
;
return
fcntl
(
fd
,
F_PREALLOCATE
,
&
prealloc
);
#else
return
posix_fallocate
(
fd
,
offset
,
len
);
#endif
}
#ifdef NO_MMAP
#ifdef NO_MMAP
#include "map.h"
#include "map.h"
...
...
src/posix.h
View file @
4e3949b7
...
@@ -115,6 +115,7 @@ extern int p_open(const char *path, int flags, ...);
...
@@ -115,6 +115,7 @@ extern int p_open(const char *path, int flags, ...);
extern
int
p_creat
(
const
char
*
path
,
mode_t
mode
);
extern
int
p_creat
(
const
char
*
path
,
mode_t
mode
);
extern
int
p_getcwd
(
char
*
buffer_out
,
size_t
size
);
extern
int
p_getcwd
(
char
*
buffer_out
,
size_t
size
);
extern
int
p_rename
(
const
char
*
from
,
const
char
*
to
);
extern
int
p_rename
(
const
char
*
from
,
const
char
*
to
);
extern
int
p_fallocate
(
int
fd
,
off_t
offset
,
off_t
len
);
extern
int
git__page_size
(
size_t
*
page_size
);
extern
int
git__page_size
(
size_t
*
page_size
);
extern
int
git__mmap_alignment
(
size_t
*
page_size
);
extern
int
git__mmap_alignment
(
size_t
*
page_size
);
...
...
src/win32/posix_w32.c
View file @
4e3949b7
...
@@ -516,6 +516,12 @@ int p_creat(const char *path, mode_t mode)
...
@@ -516,6 +516,12 @@ int p_creat(const char *path, mode_t mode)
return
p_open
(
path
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
mode
);
return
p_open
(
path
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
mode
);
}
}
int
p_fallocate
(
int
fd
,
off_t
offset
,
off_t
len
)
{
error
=
ENOSYS
;
return
-
1
;
}
int
p_utimes
(
const
char
*
path
,
const
struct
p_timeval
times
[
2
])
int
p_utimes
(
const
char
*
path
,
const
struct
p_timeval
times
[
2
])
{
{
git_win32_path
wpath
;
git_win32_path
wpath
;
...
...
tests/object/tree/read.c
View file @
4e3949b7
...
@@ -73,3 +73,56 @@ void test_object_tree_read__two(void)
...
@@ -73,3 +73,56 @@ void test_object_tree_read__two(void)
git_object_free
(
obj
);
git_object_free
(
obj
);
git_tree_free
(
tree
);
git_tree_free
(
tree
);
}
}
#define BIGFILE "bigfile"
#define BIGFILE_SIZE (off_t)4 * 1024 * 1024 * 1024
/* 4 GiB */
void
test_object_tree_read__largefile
(
void
)
{
git_reference
*
ref
;
git_commit
*
commit
;
git_tree
*
tree
;
git_oid
oid
;
const
git_tree_entry
*
entry
;
git_object
*
object
;
git_buf
file
=
GIT_BUF_INIT
;
int
fd
;
git_index
*
idx
;
#ifdef GIT_WIN32
cl_skip
();
#endif
if
(
!
cl_is_env_set
(
"GITTEST_INVASIVE_FS_SIZE"
))
cl_skip
();
cl_git_pass
(
git_reference_lookup
(
&
ref
,
g_repo
,
"refs/heads/master"
));
cl_git_pass
(
git_repository_index
(
&
idx
,
g_repo
));
cl_git_pass
(
git_buf_puts
(
&
file
,
git_repository_workdir
(
g_repo
)));
cl_git_pass
(
git_buf_joinpath
(
&
file
,
file
.
ptr
,
BIGFILE
));
fd
=
p_open
(
git_buf_cstr
(
&
file
),
O_CREAT
|
O_RDWR
,
0644
);
cl_assert_
(
fd
>=
0
,
"invalid file descriptor"
);
cl_must_pass
(
p_fallocate
(
fd
,
0
,
BIGFILE_SIZE
));
cl_must_pass
(
p_close
(
fd
));
cl_git_pass
(
git_index_add_bypath
(
idx
,
BIGFILE
));
cl_repo_commit_from_index
(
&
oid
,
g_repo
,
NULL
,
0
,
"bigfile"
);
cl_git_pass
(
git_commit_lookup
(
&
commit
,
g_repo
,
&
oid
));
cl_git_pass
(
git_commit_tree
(
&
tree
,
commit
));
entry
=
git_tree_entry_byname
(
tree
,
BIGFILE
);
cl_assert_
(
entry
,
"entry was NULL"
);
cl_git_pass
(
git_tree_entry_to_object
(
&
object
,
g_repo
,
entry
));
git_buf_dispose
(
&
file
);
git_object_free
(
object
);
git_tree_free
(
tree
);
git_index_free
(
idx
);
git_commit_free
(
commit
);
git_reference_free
(
ref
);
}
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