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
5915a2a2
Commit
5915a2a2
authored
Aug 03, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3349 from libgit2/cmn/for-v23
A second round of 0.23 maint updates
parents
6a0d5696
16cee5d6
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
137 additions
and
31 deletions
+137
-31
CMakeLists.txt
+2
-1
README.md
+1
-1
include/git2/repository.h
+1
-1
include/git2/sys/config.h
+1
-1
include/git2/sys/diff.h
+4
-4
include/git2/sys/odb_backend.h
+1
-1
include/git2/sys/refdb_backend.h
+1
-1
src/describe.c
+1
-1
src/filebuf.c
+6
-1
src/filebuf.h
+2
-0
src/index.c
+58
-5
src/indexer.c
+1
-1
src/iterator.c
+4
-1
src/pack-objects.c
+1
-1
src/pack.c
+2
-2
src/path.h
+1
-1
src/push.h
+3
-1
src/revwalk.c
+1
-1
src/transports/git.c
+2
-0
src/transports/http.c
+1
-1
src/transports/ssh.c
+2
-0
tests/core/filebuf.c
+27
-0
tests/index/bypath.c
+13
-0
tests/repo/iterator.c
+1
-5
No files found.
CMakeLists.txt
View file @
5915a2a2
...
...
@@ -12,7 +12,7 @@
# > cmake --build . --target install
PROJECT
(
libgit2 C
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.
6
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.
8
)
CMAKE_POLICY
(
SET CMP0015 NEW
)
# Add find modules to the path
...
...
@@ -412,6 +412,7 @@ ELSE ()
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fPIC"
)
ENDIF
()
ADD_C_FLAG_IF_SUPPORTED
(
-Wdocumentation
)
ADD_C_FLAG_IF_SUPPORTED
(
-Wno-missing-field-initializers
)
ADD_C_FLAG_IF_SUPPORTED
(
-Wstrict-aliasing=2
)
ADD_C_FLAG_IF_SUPPORTED
(
-Wstrict-prototypes
)
...
...
README.md
View file @
5915a2a2
...
...
@@ -88,7 +88,7 @@ Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthrea
they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API
for threading.
The
`libgit2`
library is built using
[
CMake
](
<
http://www.cmake.org
>
)
(
version
2.
6
or newer) on all platforms.
The
`libgit2`
library is built using
[
CMake
](
<
http://www.cmake.org
>
)
(
version
2.
8
or newer) on all platforms.
On most systems you can build the library using the following commands
...
...
include/git2/repository.h
View file @
5915a2a2
...
...
@@ -745,7 +745,7 @@ GIT_EXTERN(int) git_repository_ident(const char **name, const char **email, cons
*
* @param repo the repository to configure
* @param name the name to use for the reflog entries
* @param
name
the email to use for the reflog entries
* @param
email
the email to use for the reflog entries
*/
GIT_EXTERN
(
int
)
git_repository_set_ident
(
git_repository
*
repo
,
const
char
*
name
,
const
char
*
email
);
...
...
include/git2/sys/config.h
View file @
5915a2a2
...
...
@@ -76,7 +76,7 @@ struct git_config_backend {
* Initializes a `git_config_backend` with default values. Equivalent to
* creating an instance with GIT_CONFIG_BACKEND_INIT.
*
* @param
opts
the `git_config_backend` struct to initialize.
* @param
backend
the `git_config_backend` struct to initialize.
* @param version Version of struct; pass `GIT_CONFIG_BACKEND_VERSION`
* @return Zero on success; -1 on failure.
*/
...
...
include/git2/sys/diff.h
View file @
5915a2a2
...
...
@@ -38,7 +38,7 @@ GIT_EXTERN(int) git_diff_print_callback__to_buf(
const
git_diff_delta
*
delta
,
const
git_diff_hunk
*
hunk
,
const
git_diff_line
*
line
,
void
*
payload
);
/*< payload must be a `git_buf *` */
void
*
payload
);
/*
*
< payload must be a `git_buf *` */
/**
* Diff print callback that writes to stdio FILE handle.
...
...
@@ -58,7 +58,7 @@ GIT_EXTERN(int) git_diff_print_callback__to_file_handle(
const
git_diff_delta
*
delta
,
const
git_diff_hunk
*
hunk
,
const
git_diff_line
*
line
,
void
*
payload
);
/*< payload must be a `FILE *` */
void
*
payload
);
/*
*
< payload must be a `FILE *` */
/**
...
...
@@ -66,8 +66,8 @@ GIT_EXTERN(int) git_diff_print_callback__to_file_handle(
*/
typedef
struct
{
unsigned
int
version
;
size_t
stat_calls
;
/*< Number of stat() calls performed */
size_t
oid_calculations
;
/*< Number of ID calculations */
size_t
stat_calls
;
/*
*
< Number of stat() calls performed */
size_t
oid_calculations
;
/*
*
< Number of ID calculations */
}
git_diff_perfdata
;
#define GIT_DIFF_PERFDATA_VERSION 1
...
...
include/git2/sys/odb_backend.h
View file @
5915a2a2
...
...
@@ -93,7 +93,7 @@ struct git_odb_backend {
* Initializes a `git_odb_backend` with default values. Equivalent to
* creating an instance with GIT_ODB_BACKEND_INIT.
*
* @param
opts
the `git_odb_backend` struct to initialize.
* @param
backend
the `git_odb_backend` struct to initialize.
* @param version Version the struct; pass `GIT_ODB_BACKEND_VERSION`
* @return Zero on success; -1 on failure.
*/
...
...
include/git2/sys/refdb_backend.h
View file @
5915a2a2
...
...
@@ -175,7 +175,7 @@ struct git_refdb_backend {
* Initializes a `git_refdb_backend` with default values. Equivalent to
* creating an instance with GIT_REFDB_BACKEND_INIT.
*
* @param
opts
the `git_refdb_backend` struct to initialize
* @param
backend
the `git_refdb_backend` struct to initialize
* @param version Version of struct; pass `GIT_REFDB_BACKEND_VERSION`
* @return Zero on success; -1 on failure.
*/
...
...
src/describe.c
View file @
5915a2a2
...
...
@@ -19,7 +19,7 @@
#include "vector.h"
#include "repository.h"
GIT__USE_OIDMAP
;
GIT__USE_OIDMAP
/* Ported from https://github.com/git/git/blob/89dde7882f71f846ccd0359756d27bebc31108de/builtin/describe.c */
...
...
src/filebuf.c
View file @
5915a2a2
...
...
@@ -101,7 +101,7 @@ void git_filebuf_cleanup(git_filebuf *file)
if
(
file
->
fd_is_open
&&
file
->
fd
>=
0
)
p_close
(
file
->
fd
);
if
(
file
->
fd_is_open
&&
file
->
path_lock
&&
git_path_exists
(
file
->
path_lock
))
if
(
file
->
created_lock
&&
!
file
->
did_rename
&&
file
->
path_lock
&&
git_path_exists
(
file
->
path_lock
))
p_unlink
(
file
->
path_lock
);
if
(
file
->
compute_digest
)
{
...
...
@@ -258,6 +258,7 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags, mode_t mode
goto
cleanup
;
}
file
->
fd_is_open
=
true
;
file
->
created_lock
=
true
;
/* No original path */
file
->
path_original
=
NULL
;
...
...
@@ -281,6 +282,8 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags, mode_t mode
/* open the file for locking */
if
((
error
=
lock_file
(
file
,
flags
,
mode
))
<
0
)
goto
cleanup
;
file
->
created_lock
=
true
;
}
return
0
;
...
...
@@ -340,6 +343,8 @@ int git_filebuf_commit(git_filebuf *file)
goto
on_error
;
}
file
->
did_rename
=
true
;
git_filebuf_cleanup
(
file
);
return
0
;
...
...
src/filebuf.h
View file @
5915a2a2
...
...
@@ -44,6 +44,8 @@ struct git_filebuf {
size_t
buf_size
,
buf_pos
;
git_file
fd
;
bool
fd_is_open
;
bool
created_lock
;
bool
did_rename
;
bool
do_not_buffer
;
int
last_error
;
};
...
...
src/index.c
View file @
5915a2a2
...
...
@@ -1228,6 +1228,45 @@ int git_index_add_frombuffer(
return
0
;
}
static
int
add_repo_as_submodule
(
git_index_entry
**
out
,
git_index
*
index
,
const
char
*
path
)
{
git_repository
*
sub
;
git_buf
abspath
=
GIT_BUF_INIT
;
git_repository
*
repo
=
INDEX_OWNER
(
index
);
git_reference
*
head
;
git_index_entry
*
entry
;
struct
stat
st
;
int
error
;
if
(
index_entry_create
(
&
entry
,
INDEX_OWNER
(
index
),
path
)
<
0
)
return
-
1
;
if
((
error
=
git_buf_joinpath
(
&
abspath
,
git_repository_workdir
(
repo
),
path
))
<
0
)
return
error
;
if
((
error
=
p_stat
(
abspath
.
ptr
,
&
st
))
<
0
)
{
giterr_set
(
GITERR_OS
,
"failed to stat repository dir"
);
return
-
1
;
}
git_index_entry__init_from_stat
(
entry
,
&
st
,
!
index
->
distrust_filemode
);
if
((
error
=
git_repository_open
(
&
sub
,
abspath
.
ptr
))
<
0
)
return
error
;
if
((
error
=
git_repository_head
(
&
head
,
sub
))
<
0
)
return
error
;
git_oid_cpy
(
&
entry
->
id
,
git_reference_target
(
head
));
entry
->
mode
=
GIT_FILEMODE_COMMIT
;
git_reference_free
(
head
);
git_repository_free
(
sub
);
git_buf_free
(
&
abspath
);
*
out
=
entry
;
return
0
;
}
int
git_index_add_bypath
(
git_index
*
index
,
const
char
*
path
)
{
...
...
@@ -1252,12 +1291,26 @@ int git_index_add_bypath(git_index *index, const char *path)
ret
=
git_submodule_lookup
(
&
sm
,
INDEX_OWNER
(
index
),
path
);
if
(
ret
==
GIT_ENOTFOUND
)
return
giterr_restore
(
&
err
);
else
git__free
(
err
.
error_msg
.
message
);
ret
=
git_submodule_add_to_index
(
sm
,
false
);
git_submodule_free
(
sm
);
return
ret
;
git__free
(
err
.
error_msg
.
message
);
/*
* EEXISTS means that there is a repository at that path, but it's not known
* as a submodule. We add its HEAD as an entry and don't register it.
*/
if
(
ret
==
GIT_EEXISTS
)
{
if
((
ret
=
add_repo_as_submodule
(
&
entry
,
index
,
path
))
<
0
)
return
ret
;
if
((
ret
=
index_insert
(
index
,
&
entry
,
1
,
false
))
<
0
)
return
ret
;
}
else
if
(
ret
<
0
)
{
return
ret
;
}
else
{
ret
=
git_submodule_add_to_index
(
sm
,
false
);
git_submodule_free
(
sm
);
return
ret
;
}
}
/* Adding implies conflict was resolved, move conflict entries to REUC */
...
...
src/indexer.c
View file @
5915a2a2
...
...
@@ -18,7 +18,7 @@
#include "oidmap.h"
#include "zstream.h"
GIT__USE_OIDMAP
;
GIT__USE_OIDMAP
extern
git_mutex
git__mwindow_mutex
;
...
...
src/iterator.c
View file @
5915a2a2
...
...
@@ -1027,8 +1027,11 @@ static int dirload_with_stat(
strncomp
=
(
flags
&
GIT_PATH_DIR_IGNORE_CASE
)
!=
0
?
git__strncasecmp
:
git__strncmp
;
if
((
error
=
git_path_diriter_init
(
&
diriter
,
dirpath
,
flags
))
<
0
)
/* Any error here is equivalent to the dir not existing, skip over it */
if
((
error
=
git_path_diriter_init
(
&
diriter
,
dirpath
,
flags
))
<
0
)
{
error
=
GIT_ENOTFOUND
;
goto
done
;
}
while
((
error
=
git_path_diriter_next
(
&
diriter
))
==
0
)
{
if
((
error
=
git_path_diriter_fullpath
(
&
path
,
&
path_len
,
&
diriter
))
<
0
)
...
...
src/pack-objects.c
View file @
5915a2a2
...
...
@@ -41,7 +41,7 @@ struct pack_write_context {
git_transfer_progress
*
stats
;
};
GIT__USE_OIDMAP
;
GIT__USE_OIDMAP
#ifdef GIT_THREADS
...
...
src/pack.c
View file @
5915a2a2
...
...
@@ -16,8 +16,8 @@
#include <zlib.h>
GIT__USE_OFFMAP
;
GIT__USE_OIDMAP
;
GIT__USE_OFFMAP
GIT__USE_OIDMAP
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
);
...
...
src/path.h
View file @
5915a2a2
...
...
@@ -319,7 +319,7 @@ extern int git_path_cmp(
* @param callback Function to invoke on each path. Passed the `payload`
* and the buffer containing the current path. The path should not
* be modified in any way. Return non-zero to stop iteration.
* @param
state
Passed to fn as the first ath.
* @param
payload
Passed to fn as the first ath.
*/
extern
int
git_path_walk_up
(
git_buf
*
pathbuf
,
...
...
src/push.h
View file @
5915a2a2
...
...
@@ -83,7 +83,7 @@ int git_push_add_refspec(git_push *push, const char *refspec);
* Update remote tips after a push
*
* @param push The push object
* @param
signature The identity to use when updating reflogs
* @param
callbacks the callbacks to use for this connection
*
* @return 0 or an error code
*/
...
...
@@ -100,6 +100,7 @@ int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks);
* order to find out which updates were accepted or rejected.
*
* @param push The push object
* @param callbacks the callbacks to use for this connection
*
* @return 0 or an error code
*/
...
...
@@ -117,6 +118,7 @@ int git_push_finish(git_push *push, const git_remote_callbacks *callbacks);
*
* @param push The push object
* @param cb The callback to call on each object
* @param data The payload passed to the callback
*
* @return 0 on success, non-zero callback return value, or error code
*/
...
...
src/revwalk.c
View file @
5915a2a2
...
...
@@ -14,7 +14,7 @@
#include "git2/revparse.h"
#include "merge.h"
GIT__USE_OIDMAP
;
GIT__USE_OIDMAP
git_commit_list_node
*
git_revwalk__commit_lookup
(
git_revwalk
*
walk
,
const
git_oid
*
oid
)
...
...
src/transports/git.c
View file @
5915a2a2
...
...
@@ -50,6 +50,8 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
}
repo
=
delim
;
if
(
repo
[
1
]
==
'~'
)
++
repo
;
delim
=
strchr
(
url
,
':'
);
if
(
delim
==
NULL
)
...
...
src/transports/http.c
View file @
5915a2a2
...
...
@@ -255,7 +255,7 @@ static int on_header_ready(http_subtransport *t)
GITERR_CHECK_ALLOC
(
t
->
content_type
);
}
}
else
if
(
!
strcmp
(
"WWW-Authenticate"
,
git_buf_cstr
(
name
)))
{
else
if
(
!
strc
asec
mp
(
"WWW-Authenticate"
,
git_buf_cstr
(
name
)))
{
char
*
dup
=
git__strdup
(
git_buf_cstr
(
value
));
GITERR_CHECK_ALLOC
(
dup
);
...
...
src/transports/ssh.c
View file @
5915a2a2
...
...
@@ -66,6 +66,8 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
if
(
!
git__prefixcmp
(
url
,
prefix_ssh
))
{
url
=
url
+
strlen
(
prefix_ssh
);
repo
=
strchr
(
url
,
'/'
);
if
(
repo
&&
repo
[
1
]
==
'~'
)
++
repo
;
}
else
{
repo
=
strchr
(
url
,
':'
);
if
(
repo
)
repo
++
;
...
...
tests/core/filebuf.c
View file @
5915a2a2
...
...
@@ -124,3 +124,30 @@ void test_core_filebuf__umask(void)
cl_must_pass
(
p_unlink
(
test
));
}
void
test_core_filebuf__rename_error
(
void
)
{
git_filebuf
file
=
GIT_FILEBUF_INIT
;
char
*
dir
=
"subdir"
,
*
test
=
"subdir/test"
,
*
test_lock
=
"subdir/test.lock"
;
int
fd
;
#ifndef GIT_WIN32
cl_skip
();
#endif
cl_git_pass
(
p_mkdir
(
dir
,
0666
));
cl_git_mkfile
(
test
,
"dummy content"
);
fd
=
p_open
(
test
,
O_RDONLY
);
cl_assert
(
fd
>
0
);
cl_git_pass
(
git_filebuf_open
(
&
file
,
test
,
0
,
0666
));
cl_git_pass
(
git_filebuf_printf
(
&
file
,
"%s
\n
"
,
"libgit2 rocks"
));
cl_assert_equal_i
(
true
,
git_path_exists
(
test_lock
));
cl_git_fail
(
git_filebuf_commit
(
&
file
));
p_close
(
fd
);
git_filebuf_cleanup
(
&
file
);
cl_assert_equal_i
(
false
,
git_path_exists
(
test_lock
));
}
tests/index/bypath.c
View file @
5915a2a2
...
...
@@ -33,3 +33,16 @@ void test_index_bypath__add_submodule(void)
cl_git_pass
(
git_submodule_status
(
&
status
,
g_repo
,
sm_name
,
0
));
cl_assert_equal_i
(
0
,
status
&
GIT_SUBMODULE_STATUS_WD_MODIFIED
);
}
void
test_index_bypath__add_submodule_unregistered
(
void
)
{
const
char
*
sm_name
=
"not-submodule"
;
const
char
*
sm_head
=
"68e92c611b80ee1ed8f38314ff9577f0d15b2444"
;
const
git_index_entry
*
entry
;
cl_git_pass
(
git_index_add_bypath
(
g_idx
,
sm_name
));
cl_assert
(
entry
=
git_index_get_bypath
(
g_idx
,
sm_name
,
0
));
cl_assert_equal_s
(
sm_head
,
git_oid_tostr_s
(
&
entry
->
id
));
cl_assert_equal_s
(
sm_name
,
entry
->
path
);
}
tests/repo/iterator.c
View file @
5915a2a2
...
...
@@ -928,7 +928,7 @@ void test_repo_iterator__fs2(void)
git_iterator_free
(
i
);
}
void
test_repo_iterator__
fs_preserves_erro
r
(
void
)
void
test_repo_iterator__
unreadable_di
r
(
void
)
{
git_iterator
*
i
;
const
git_index_entry
*
e
;
...
...
@@ -951,10 +951,6 @@ void test_repo_iterator__fs_preserves_error(void)
cl_git_pass
(
git_iterator_advance
(
&
e
,
i
));
/* a */
cl_git_fail
(
git_iterator_advance
(
&
e
,
i
));
/* b */
cl_assert
(
giterr_last
());
cl_assert
(
giterr_last
()
->
message
!=
NULL
);
/* skip 'c/' empty directory */
cl_git_pass
(
git_iterator_advance
(
&
e
,
i
));
/* d */
cl_assert_equal_i
(
GIT_ITEROVER
,
git_iterator_advance
(
&
e
,
i
));
cl_must_pass
(
p_chmod
(
"empty_standard_repo/r/b"
,
0777
));
...
...
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