Skip to content

Commit

Permalink
Update libgit2 source code (75db289)
Browse files Browse the repository at this point in the history
* Update libgit2 source code to commit
  75db289a041b1f1084768244e167b953ac7eeaa5

Signed-off-by: Stefan Widgren <stefan.widgren@gmail.com>
  • Loading branch information
stewid committed Dec 20, 2016
1 parent ce11117 commit be4a00e
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 25 deletions.
18 changes: 18 additions & 0 deletions src/libgit2/include/git2/common.h
Expand Up @@ -109,9 +109,27 @@ GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
* was compiled
*/
typedef enum {
/**
* If set, libgit2 was built thread-aware and can be safely used from multiple
* threads.
*/
GIT_FEATURE_THREADS = (1 << 0),
/**
* If set, libgit2 was built with and linked against a TLS implementation.
* Custom TLS streams may still be added by the user to support HTTPS
* regardless of this.
*/
GIT_FEATURE_HTTPS = (1 << 1),
/**
* If set, libgit2 was built with and linked against libssh2. A custom
* transport may still be added by the user to support libssh2 regardless of
* this.
*/
GIT_FEATURE_SSH = (1 << 2),
/**
* If set, libgit2 was built with support for sub-second resolution in file
* modification times.
*/
GIT_FEATURE_NSEC = (1 << 3),
} git_feature_t;

Expand Down
7 changes: 5 additions & 2 deletions src/libgit2/include/git2/describe.h
Expand Up @@ -44,8 +44,8 @@ typedef enum {
typedef struct git_describe_options {
unsigned int version;

unsigned int max_candidates_tags; /** default: 10 */
unsigned int describe_strategy; /** default: GIT_DESCRIBE_DEFAULT */
unsigned int max_candidates_tags; /**< default: 10 */
unsigned int describe_strategy; /**< default: GIT_DESCRIBE_DEFAULT */
const char *pattern;
/**
* When calculating the distance from the matching tag or
Expand Down Expand Up @@ -105,6 +105,9 @@ typedef struct {

GIT_EXTERN(int) git_describe_init_format_options(git_describe_format_options *opts, unsigned int version);

/**
* A struct that stores the result of a describe operation.
*/
typedef struct git_describe_result git_describe_result;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/libgit2/include/git2/remote.h
Expand Up @@ -26,8 +26,6 @@
*/
GIT_BEGIN_DECL

typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload);

/**
* Add a remote with the default fetch refspec to the repository's configuration.
*
Expand Down Expand Up @@ -360,6 +358,8 @@ typedef struct {
} git_push_update;

/**
* Callback used to inform of upcoming updates.
*
* @param updates an array containing the updates which will be sent
* as commands to the destination.
* @param len number of elements in `updates`
Expand Down Expand Up @@ -403,7 +403,7 @@ struct git_remote_callbacks {
* connection to proceed. Returns 1 to allow the connection, 0
* to disallow it or a negative value to indicate an error.
*/
git_transport_certificate_check_cb certificate_check;
git_transport_certificate_check_cb certificate_check;

/**
* During the download of new data, this will be regularly
Expand Down Expand Up @@ -569,7 +569,7 @@ typedef struct {
* Initializes a `git_fetch_options` with default values. Equivalent to
* creating an instance with GIT_FETCH_OPTIONS_INIT.
*
* @param opts the `git_push_options` instance to initialize.
* @param opts the `git_fetch_options` instance to initialize.
* @param version the version of the struct; you should pass
* `GIT_FETCH_OPTIONS_VERSION` here.
* @return Zero on success; -1 on failure.
Expand Down
9 changes: 9 additions & 0 deletions src/libgit2/include/git2/transaction.h
Expand Up @@ -8,6 +8,14 @@
#define INCLUDE_git_transaction_h__

#include "common.h"

/**
* @file git2/transaction.h
* @brief Git transactional reference routines
* @defgroup git_transaction Git transactional reference routines
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL

/**
Expand Down Expand Up @@ -107,5 +115,6 @@ GIT_EXTERN(int) git_transaction_commit(git_transaction *tx);
*/
GIT_EXTERN(void) git_transaction_free(git_transaction *tx);

/** @} */
GIT_END_DECL
#endif
6 changes: 6 additions & 0 deletions src/libgit2/src/global.h
Expand Up @@ -16,6 +16,12 @@ typedef struct {
git_error error_t;
git_buf error_buf;
char oid_fmt[GIT_OID_HEXSZ+1];

/* On Windows, this is the current child thread that was started by
* `git_thread_create`. This is used to set the thread's exit code
* when terminated by `git_thread_exit`. It is unused on POSIX.
*/
git_thread *current_thread;
} git_global_st;

#ifdef GIT_OPENSSL
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/src/graph.c
Expand Up @@ -59,7 +59,7 @@ static int mark_parents(git_revwalk *walk, git_commit_list_node *one,
/* as long as there are non-STALE commits */
while (interesting(&list, roots)) {
git_commit_list_node *commit = git_pqueue_pop(&list);
int flags;
unsigned int flags;

if (commit == NULL)
break;
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/src/odb_mempack.c
Expand Up @@ -24,7 +24,7 @@ struct memobject {
git_oid oid;
size_t len;
git_otype type;
char data[];
char data[GIT_FLEX_ARRAY];
};

struct memory_packer_db {
Expand Down
9 changes: 7 additions & 2 deletions src/libgit2/src/pack.c
Expand Up @@ -509,8 +509,10 @@ int git_packfile_resolve_header(
git_packfile_stream_free(&stream);
if (error < 0)
return error;
} else
} else {
*size_p = size;
base_offset = 0;
}

while (type == GIT_OBJ_OFS_DELTA || type == GIT_OBJ_REF_DELTA) {
curpos = base_offset;
Expand Down Expand Up @@ -757,8 +759,11 @@ int git_packfile_unpack(
}

cleanup:
if (error < 0)
if (error < 0) {
git__free(obj->data);
if (cached)
git_atomic_dec(&cached->refcount);
}

if (elem)
*obj_offset = curpos;
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/src/patch_generate.c
Expand Up @@ -284,7 +284,7 @@ static int create_binary(
size_t b_datalen)
{
git_buf deflate = GIT_BUF_INIT, delta = GIT_BUF_INIT;
size_t delta_data_len;
size_t delta_data_len = 0;
int error;

/* The git_delta function accepts unsigned long only */
Expand Down
1 change: 0 additions & 1 deletion src/libgit2/src/path.c
Expand Up @@ -1145,7 +1145,6 @@ int git_path_diriter_init(
unsigned int flags)
{
git_win32_path path_filter;
git_buf hack = {0};

static int is_win7_or_later = -1;
if (is_win7_or_later < 0)
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/src/rebase.c
Expand Up @@ -648,7 +648,7 @@ static int rebase_init_merge(
rebase->state_path = git_buf_detach(&state_path);
GITERR_CHECK_ALLOC(rebase->state_path);

if (branch->ref_name) {
if (branch->ref_name && strcmp(branch->ref_name, "HEAD")) {
rebase->orig_head_name = git__strdup(branch->ref_name);
GITERR_CHECK_ALLOC(rebase->orig_head_name);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/libgit2/src/refdb_fs.c
Expand Up @@ -729,8 +729,8 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
/* Remove a possibly existing empty directory hierarchy
* which name would collide with the reference name
*/
if (git_futils_rmdir_r(name, backend->path, GIT_RMDIR_SKIP_NONEMPTY) < 0)
return -1;
if ((error = git_futils_rmdir_r(name, backend->path, GIT_RMDIR_SKIP_NONEMPTY)) < 0)
return error;

if (git_buf_joinpath(&ref_path, backend->path, name) < 0)
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/src/revwalk.c
Expand Up @@ -290,7 +290,7 @@ static void mark_parents_uninteresting(git_commit_list_node *commit)


while (parents) {
git_commit_list_node *commit = git_commit_list_pop(&parents);
commit = git_commit_list_pop(&parents);

while (commit) {
if (commit->uninteresting)
Expand Down
2 changes: 2 additions & 0 deletions src/libgit2/src/settings.c
Expand Up @@ -29,7 +29,9 @@ int git_libgit2_features(void)
#ifdef GIT_THREADS
| GIT_FEATURE_THREADS
#endif
#if defined(GIT_OPENSSL) || defined(GIT_WINHTTP) || defined(GIT_SECURE_TRANSPORT)
| GIT_FEATURE_HTTPS
#endif
#if defined(GIT_SSH)
| GIT_FEATURE_SSH
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/src/signature.c
Expand Up @@ -251,7 +251,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
* only store timezone if it's not overflowing;
* see http://www.worldtimezone.com/faq.html
*/
if (hours < 14 && mins < 59) {
if (hours <= 14 && mins <= 59) {
sig->when.offset = (hours * 60) + mins;
if (tz_start[0] == '-')
sig->when.offset = -sig->when.offset;
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/src/sysdir.c
Expand Up @@ -171,7 +171,7 @@ int git_sysdir_set(git_sysdir_t which, const char *search_path)
expand_path = strstr(search_path, PATH_MAGIC);

/* reset the default if this path has been cleared */
if (!search_path || expand_path)
if (!search_path)
git_sysdir__dirs[which].guess(&git_sysdir__dirs[which].buf);

/* if $PATH is not referenced, then just set the path */
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/src/transports/http.c
Expand Up @@ -208,7 +208,7 @@ static int gen_request(

git_buf_printf(buf, "%s %s%s HTTP/1.1\r\n", s->verb, path, s->service_url);

git_buf_printf(buf, "User-Agent: git/1.0 (%s)\r\n", user_agent());
git_buf_printf(buf, "User-Agent: git/2.0 (%s)\r\n", user_agent());
git_buf_printf(buf, "Host: %s\r\n", t->connection_data.host);

if (s->chunked || content_length > 0) {
Expand Down
10 changes: 5 additions & 5 deletions src/libgit2/src/transports/smart_protocol.c
Expand Up @@ -412,12 +412,12 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c

if (i % 20 == 0 && t->rpc) {
git_pkt_ack *pkt;
unsigned int i;
unsigned int j;

if ((error = git_pkt_buffer_wants(wants, count, &t->caps, &data)) < 0)
goto on_error;

git_vector_foreach(&t->common, i, pkt) {
git_vector_foreach(&t->common, j, pkt) {
if ((error = git_pkt_buffer_have(&pkt->oid, &data)) < 0)
goto on_error;
}
Expand All @@ -432,12 +432,12 @@ int git_smart__negotiate_fetch(git_transport *transport, git_repository *repo, c
/* Tell the other end that we're done negotiating */
if (t->rpc && t->common.length > 0) {
git_pkt_ack *pkt;
unsigned int i;
unsigned int j;

if ((error = git_pkt_buffer_wants(wants, count, &t->caps, &data)) < 0)
goto on_error;

git_vector_foreach(&t->common, i, pkt) {
git_vector_foreach(&t->common, j, pkt) {
if ((error = git_pkt_buffer_have(&pkt->oid, &data)) < 0)
goto on_error;
}
Expand Down Expand Up @@ -737,7 +737,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
static int add_push_report_sideband_pkt(git_push *push, git_pkt_data *data_pkt, git_buf *data_pkt_buf)
{
git_pkt *pkt;
const char *line, *line_end;
const char *line, *line_end = NULL;
size_t line_len;
int error;
int reading_from_buf = data_pkt_buf->size > 0;
Expand Down
2 changes: 2 additions & 0 deletions src/libgit2/src/unix/pthread.h
Expand Up @@ -17,6 +17,8 @@ typedef struct {
pthread_create(&(git_thread_ptr)->thread, NULL, start_routine, arg)
#define git_thread_join(git_thread_ptr, status) \
pthread_join((git_thread_ptr)->thread, status)
#define git_thread_currentid() ((size_t)(pthread_self()))
#define git_thread_exit(retval) pthread_exit(retval)

/* Git Mutex */
#define git_mutex pthread_mutex_t
Expand Down
2 changes: 2 additions & 0 deletions src/libgit2/src/win32/thread.h
Expand Up @@ -41,6 +41,8 @@ int git_thread_create(git_thread *GIT_RESTRICT,
void *(*) (void *),
void *GIT_RESTRICT);
int git_thread_join(git_thread *, void **);
size_t git_thread_currentid(void);
void git_thread_exit(void *);

int git_mutex_init(git_mutex *GIT_RESTRICT mutex);
int git_mutex_free(git_mutex *);
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/src/win32/w32_util.h
Expand Up @@ -174,7 +174,7 @@ GIT_INLINE(int) git_win32__file_attribute_to_stat(
/* st_size gets the UTF-8 length of the target name, in bytes,
* not counting the NULL terminator */
if ((st->st_size = git__utf16_to_8(NULL, 0, target)) < 0) {
giterr_set(GITERR_OS, "Could not convert reparse point name for '%s'", path);
giterr_set(GITERR_OS, "Could not convert reparse point name for '%ls'", path);
return -1;
}
}
Expand Down

0 comments on commit be4a00e

Please sign in to comment.