Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nodegit-libgit2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xielei
nodegit-libgit2
Commits
8d89e409
Commit
8d89e409
authored
Apr 17, 2017
by
Carlos Martín Nieto
Committed by
GitHub
Apr 17, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4192 from libgit2/ethomson/win32_posix
Refactor some of the win32 POSIX emulation
parents
f9d3b0d0
86536c7e
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
407 additions
and
111 deletions
+407
-111
CHANGELOG.md
CHANGELOG.md
+4
-0
include/git2/common.h
include/git2/common.h
+13
-0
include/git2/errors.h
include/git2/errors.h
+1
-0
src/posix.h
src/posix.h
+4
-0
src/settings.c
src/settings.c
+12
-0
src/win32/posix.h
src/win32/posix.h
+3
-0
src/win32/posix_w32.c
src/win32/posix_w32.c
+332
-111
tests/odb/freshen.c
tests/odb/freshen.c
+25
-0
tests/threads/diff.c
tests/threads/diff.c
+13
-0
No files found.
CHANGELOG.md
View file @
8d89e409
...
...
@@ -9,6 +9,10 @@ v0.25 + 1
### API additions
*
You can now set the default share mode on Windows for opening files using
`GIT_OPT_SET_WINDOWS_SHAREMODE`
option with
`git_libgit2_opts()`
.
You can query the current share mode with
`GIT_OPT_GET_WINDOWS_SHAREMODE`
.
### API removals
### Breaking API changes
...
...
include/git2/common.h
View file @
8d89e409
...
...
@@ -180,6 +180,8 @@ typedef enum {
GIT_OPT_GET_USER_AGENT
,
GIT_OPT_ENABLE_OFS_DELTA
,
GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION
,
GIT_OPT_GET_WINDOWS_SHAREMODE
,
GIT_OPT_SET_WINDOWS_SHAREMODE
,
}
git_libgit2_opt_t
;
/**
...
...
@@ -284,6 +286,17 @@ typedef enum {
* > - `user_agent` is the value that will be delivered as the
* > User-Agent header on HTTP requests.
*
* * opts(GIT_OPT_SET_WINDOWS_SHAREMODE, unsigned long value)
*
* > Set the share mode used when opening files on Windows.
* > For more information, see the documentation for CreateFile.
* > The default is: FILE_SHARE_READ | FILE_SHARE_WRITE. This is
* > ignored and unused on non-Windows platforms.
*
* * opts(GIT_OPT_GET_WINDOWS_SHAREMODE, unsigned long *value)
*
* > Get the share mode used when opening files on Windows.
*
* * opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, int enabled)
*
* > Enable strict input validation when creating new objects
...
...
include/git2/errors.h
View file @
8d89e409
...
...
@@ -53,6 +53,7 @@ typedef enum {
GIT_PASSTHROUGH
=
-
30
,
/**< Internal only */
GIT_ITEROVER
=
-
31
,
/**< Signals end of iteration with iterator */
GIT_RETRY
=
-
32
,
/**< Internal only */
}
git_error_code
;
/**
...
...
src/posix.h
View file @
8d89e409
...
...
@@ -24,6 +24,10 @@
#define _S_IFLNK S_IFLNK
#endif
#ifndef S_IWUSR
#define S_IWUSR 00200
#endif
#ifndef S_IXUSR
#define S_IXUSR 00100
#endif
...
...
src/settings.c
View file @
8d89e409
...
...
@@ -231,6 +231,18 @@ int git_libgit2_opts(int key, ...)
git_object__synchronous_writing
=
(
va_arg
(
ap
,
int
)
!=
0
);
break
;
case
GIT_OPT_GET_WINDOWS_SHAREMODE
:
#ifdef GIT_WIN32
*
(
va_arg
(
ap
,
unsigned
long
*
))
=
git_win32__createfile_sharemode
;
#endif
break
;
case
GIT_OPT_SET_WINDOWS_SHAREMODE
:
#ifdef GIT_WIN32
git_win32__createfile_sharemode
=
va_arg
(
ap
,
unsigned
long
);
#endif
break
;
default:
giterr_set
(
GITERR_INVALID
,
"invalid option key"
);
error
=
-
1
;
...
...
src/win32/posix.h
View file @
8d89e409
...
...
@@ -14,6 +14,9 @@
#include "utf-conv.h"
#include "dir.h"
extern
unsigned
long
git_win32__createfile_sharemode
;
extern
int
git_win32__retries
;
typedef
SOCKET
GIT_SOCKET
;
#define p_lseek(f,n,w) _lseeki64(f, n, w)
...
...
src/win32/posix_w32.c
View file @
8d89e409
This diff is collapsed.
Click to expand it.
tests/odb/freshen.c
View file @
8d89e409
...
...
@@ -55,6 +55,31 @@ void test_odb_freshen__loose_blob(void)
cl_assert
(
before
.
st_mtime
<
after
.
st_mtime
);
}
#define UNIQUE_STR "doesnt exist in the odb yet\n"
#define UNIQUE_BLOB_ID "78a87d0b8878c5953b9a63015ff4e22a3d898826"
#define UNIQUE_BLOB_FN "78/a87d0b8878c5953b9a63015ff4e22a3d898826"
void
test_odb_freshen__readonly_object
(
void
)
{
git_oid
expected_id
,
id
;
struct
stat
before
,
after
;
cl_git_pass
(
git_oid_fromstr
(
&
expected_id
,
UNIQUE_BLOB_ID
));
cl_git_pass
(
git_blob_create_frombuffer
(
&
id
,
repo
,
UNIQUE_STR
,
CONST_STRLEN
(
UNIQUE_STR
)));
cl_assert_equal_oid
(
&
expected_id
,
&
id
);
set_time_wayback
(
&
before
,
UNIQUE_BLOB_FN
);
cl_assert
((
before
.
st_mode
&
S_IWUSR
)
==
0
);
cl_git_pass
(
git_blob_create_frombuffer
(
&
id
,
repo
,
UNIQUE_STR
,
CONST_STRLEN
(
UNIQUE_STR
)));
cl_assert_equal_oid
(
&
expected_id
,
&
id
);
cl_must_pass
(
p_lstat
(
"testrepo.git/objects/"
UNIQUE_BLOB_FN
,
&
after
));
cl_assert
(
before
.
st_atime
<
after
.
st_atime
);
cl_assert
(
before
.
st_mtime
<
after
.
st_mtime
);
}
#define LOOSE_TREE_ID "944c0f6e4dfa41595e6eb3ceecdb14f50fe18162"
#define LOOSE_TREE_FN "94/4c0f6e4dfa41595e6eb3ceecdb14f50fe18162"
...
...
tests/threads/diff.c
View file @
8d89e409
...
...
@@ -19,12 +19,25 @@ static git_repository *_repo;
static
git_tree
*
_a
,
*
_b
;
static
git_atomic
_counts
[
4
];
static
int
_check_counts
;
static
int
_retries
;
#define THREADS 20
void
test_threads_diff__initialize
(
void
)
{
#ifdef GIT_WIN32
_retries
=
git_win32__retries
;
git_win32__retries
=
1
;
#endif
}
void
test_threads_diff__cleanup
(
void
)
{
cl_git_sandbox_cleanup
();
#ifdef GIT_WIN32
git_win32__retries
=
_retries
;
#endif
}
static
void
setup_trees
(
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