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
48005936
Unverified
Commit
48005936
authored
Feb 14, 2019
by
Edward Thomson
Committed by
GitHub
Feb 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4965 from hackworks/eliminate-check-for-keep-file
Allow bypassing check for '.keep' file
parents
b8837827
004a3398
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
1 deletions
+26
-1
include/git2/common.h
+6
-1
src/pack.c
+5
-0
src/settings.c
+5
-0
tests/pack/packbuilder.c
+10
-0
No files found.
include/git2/common.h
View file @
48005936
...
...
@@ -205,7 +205,8 @@ typedef enum {
GIT_OPT_SET_ALLOCATOR
,
GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY
,
GIT_OPT_GET_PACK_MAX_OBJECTS
,
GIT_OPT_SET_PACK_MAX_OBJECTS
GIT_OPT_SET_PACK_MAX_OBJECTS
,
GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS
}
git_libgit2_opt_t
;
/**
...
...
@@ -395,6 +396,10 @@ typedef enum {
* > Set the maximum number of objects libgit2 will allow in a pack
* > file when downloading a pack file from a remote.
*
* opts(GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS, int enabled)
* > This will cause .keep file existence checks to be skipped when
* > accessing packfiles, which can help performance with remote filesystems.
*
* @param option Option key
* @param ... value to set the option
* @return 0 on success, <0 on failure
...
...
src/pack.c
View file @
48005936
...
...
@@ -16,6 +16,9 @@
#include <zlib.h>
/* Option to bypass checking existence of '.keep' files */
bool
git_disable_pack_keep_file_checks
=
false
;
static
int
packfile_open
(
struct
git_pack_file
*
p
);
static
git_off_t
nth_packed_object_offset
(
const
struct
git_pack_file
*
p
,
uint32_t
n
);
static
int
packfile_unpack_compressed
(
...
...
@@ -1141,9 +1144,11 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
if
(
git__suffixcmp
(
path
,
".idx"
)
==
0
)
{
size_t
root_len
=
path_len
-
strlen
(
".idx"
);
if
(
!
git_disable_pack_keep_file_checks
)
{
memcpy
(
p
->
pack_name
+
root_len
,
".keep"
,
sizeof
(
".keep"
));
if
(
git_path_exists
(
p
->
pack_name
)
==
true
)
p
->
pack_keep
=
1
;
}
memcpy
(
p
->
pack_name
+
root_len
,
".pack"
,
sizeof
(
".pack"
));
}
...
...
src/settings.c
View file @
48005936
...
...
@@ -57,6 +57,7 @@ int git_libgit2_features(void)
extern
size_t
git_mwindow__window_size
;
extern
size_t
git_mwindow__mapped_limit
;
extern
size_t
git_indexer__max_objects
;
extern
bool
git_disable_pack_keep_file_checks
;
static
int
config_level_to_sysdir
(
int
config_level
)
{
...
...
@@ -279,6 +280,10 @@ int git_libgit2_opts(int key, ...)
*
(
va_arg
(
ap
,
size_t
*
))
=
git_indexer__max_objects
;
break
;
case
GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS
:
git_disable_pack_keep_file_checks
=
(
va_arg
(
ap
,
int
)
!=
0
);
break
;
default:
git_error_set
(
GIT_ERROR_INVALID
,
"invalid option key"
);
error
=
-
1
;
...
...
tests/pack/packbuilder.c
View file @
48005936
...
...
@@ -14,6 +14,8 @@ static git_vector _commits;
static
int
_commits_is_initialized
;
static
git_transfer_progress
_stats
;
extern
bool
git_disable_pack_keep_file_checks
;
void
test_pack_packbuilder__initialize
(
void
)
{
_repo
=
cl_git_sandbox_init
(
"testrepo.git"
);
...
...
@@ -32,6 +34,7 @@ void test_pack_packbuilder__cleanup(void)
unsigned
int
i
;
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_ENABLE_FSYNC_GITDIR
,
0
));
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS
,
false
));
if
(
_commits_is_initialized
)
{
_commits_is_initialized
=
0
;
...
...
@@ -260,3 +263,10 @@ void test_pack_packbuilder__foreach_with_cancel(void)
git_packbuilder_foreach
(
_packbuilder
,
foreach_cancel_cb
,
idx
),
-
1111
);
git_indexer_free
(
idx
);
}
void
test_pack_packbuilder__keep_file_check
(
void
)
{
assert
(
!
git_disable_pack_keep_file_checks
);
cl_git_pass
(
git_libgit2_opts
(
GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS
,
true
));
assert
(
git_disable_pack_keep_file_checks
);
}
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