summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-03-03 15:05:26 +0100
committerVicent Marti <vicent@github.com>2014-03-03 15:05:26 +0100
commit0511b15c82a6af253d9bd18ddeed85f8afd28ddd (patch)
treec028e6881d07e43d21218d0150e71d81f9b4030a
parentbb3687c5a8180c39d12b437ca1822ac43482b26f (diff)
parentb43f35fde2fa977870280d685b6e96418b82752e (diff)
downloadlibgit2-0511b15c82a6af253d9bd18ddeed85f8afd28ddd.tar.gz
Merge pull request #2141 from ravselj/development
BUGFIX - Fetching twice from the same remote causes a segfault
-rw-r--r--CMakeLists.txt4
-rw-r--r--examples/add.c2
-rw-r--r--examples/blame.c3
-rw-r--r--examples/cat-file.c2
-rw-r--r--examples/common.c2
-rw-r--r--examples/network/clone.c2
-rw-r--r--src/fetch.c4
-rw-r--r--src/transports/smart_protocol.c4
-rw-r--r--src/transports/ssh.c3
9 files changed, 19 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d6b327503..cca2a120c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,6 +57,10 @@ IF(MSVC)
# By default, libgit2 is built with WinHTTP. To use the built-in
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
OPTION( WINHTTP "Use Win32 WinHTTP routines" ON )
+
+ ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
+ ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
+ ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
ENDIF()
# This variable will contain the libraries we need to put into
diff --git a/examples/add.c b/examples/add.c
index 336596bde..0c6076e81 100644
--- a/examples/add.c
+++ b/examples/add.c
@@ -78,7 +78,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
git_status_t status;
(void)matched_pathspec;
- if (git_status_file(&status, p.repo, path)) {
+ if (git_status_file((unsigned int*)(&status), p.repo, path)) {
return -1; //abort
}
diff --git a/examples/blame.c b/examples/blame.c
index 6bc0581ac..fda605bce 100644
--- a/examples/blame.c
+++ b/examples/blame.c
@@ -107,8 +107,9 @@ int main(int argc, char *argv[])
if (break_on_null_hunk && !hunk) break;
if (hunk) {
- break_on_null_hunk = 1;
char sig[128] = {0};
+ break_on_null_hunk = 1;
+
git_oid_tostr(oid, 10, &hunk->final_commit_id);
snprintf(sig, 30, "%s <%s>", hunk->final_signature->name, hunk->final_signature->email);
diff --git a/examples/cat-file.c b/examples/cat-file.c
index fa6add07b..52399fa8a 100644
--- a/examples/cat-file.c
+++ b/examples/cat-file.c
@@ -42,7 +42,7 @@ static void print_signature(const char *header, const git_signature *sig)
static void show_blob(const git_blob *blob)
{
/* ? Does this need crlf filtering? */
- fwrite(git_blob_rawcontent(blob), git_blob_rawsize(blob), 1, stdout);
+ fwrite(git_blob_rawcontent(blob), (size_t)git_blob_rawsize(blob), 1, stdout);
}
/** Show each entry with its type, id and attributes */
diff --git a/examples/common.c b/examples/common.c
index 12dbccf59..a066c153c 100644
--- a/examples/common.c
+++ b/examples/common.c
@@ -156,7 +156,7 @@ int diff_output(
const git_diff_line *l,
void *p)
{
- FILE *fp = p;
+ FILE *fp = (FILE*)p;
(void)d; (void)h;
diff --git a/examples/network/clone.c b/examples/network/clone.c
index 4df47eb7f..a982c13c2 100644
--- a/examples/network/clone.c
+++ b/examples/network/clone.c
@@ -22,7 +22,7 @@ static void print_progress(const progress_data *pd)
int index_percent = (100*pd->fetch_progress.indexed_objects) / pd->fetch_progress.total_objects;
int checkout_percent = pd->total_steps > 0
? (100 * pd->completed_steps) / pd->total_steps
- : 0.f;
+ : 0;
int kbytes = pd->fetch_progress.received_bytes / 1024;
if (pd->fetch_progress.received_objects == pd->fetch_progress.total_objects) {
diff --git a/src/fetch.c b/src/fetch.c
index 5bf2b93c1..c7d2c83a1 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -42,8 +42,10 @@ static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, g
return 0;
/* If we have the object, mark it so we don't ask for it */
- if (git_odb_exists(odb, &head->oid))
+ if (git_odb_exists(odb, &head->oid)) {
head->local = 1;
+ remote->need_pack = 0;
+ }
else
remote->need_pack = 1;
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index dd9b5e0ed..7e8fcdd92 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -579,6 +579,10 @@ int git_smart__download_pack(
done:
if (writepack)
writepack->free(writepack);
+ if (progress_cb) {
+ t->packetsize_cb = NULL;
+ t->packetsize_payload = NULL;
+ }
return error;
}
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 37f17080a..bece0b45d 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -53,6 +53,7 @@ static void ssh_error(LIBSSH2_SESSION *session, const char *errmsg)
static int gen_proto(git_buf *request, const char *cmd, const char *url)
{
char *repo;
+ int len;
if (!git__prefixcmp(url, prefix_ssh)) {
url = url + strlen(prefix_ssh);
@@ -67,7 +68,7 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
return -1;
}
- int len = strlen(cmd) + 1 /* Space */ + 1 /* Quote */ + strlen(repo) + 1 /* Quote */ + 1;
+ len = strlen(cmd) + 1 /* Space */ + 1 /* Quote */ + strlen(repo) + 1 /* Quote */ + 1;
git_buf_grow(request, len);
git_buf_printf(request, "%s '%s'", cmd, repo);