summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml3
-rw-r--r--PROJECTS.md8
-rw-r--r--THREADING.md4
-rw-r--r--include/git2/patch.h2
-rwxr-xr-xscript/coverity.sh15
-rw-r--r--src/openssl_stream.c2
-rw-r--r--src/pack.c10
-rw-r--r--src/pqueue.c5
-rw-r--r--tests/core/pqueue.c22
-rw-r--r--tests/core/vector.c2
-rw-r--r--tests/online/fetchhead.c2
11 files changed, 49 insertions, 26 deletions
diff --git a/.travis.yml b/.travis.yml
index bfc0fac48..af38252ce 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -47,9 +47,6 @@ matrix:
os: linux
allow_failures:
- env: COVERITY=1
- - env:
- - VALGRIND=1
- OPTIONS="-DBUILD_CLAR=ON -DBUILD_EXAMPLES=OFF -DDEBUG_POOL=ON -DCMAKE_BUILD_TYPE=Debug"
install:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then ./script/install-deps-${TRAVIS_OS_NAME}.sh; fi
diff --git a/PROJECTS.md b/PROJECTS.md
index 87ce78f02..f53a2e120 100644
--- a/PROJECTS.md
+++ b/PROJECTS.md
@@ -5,7 +5,7 @@ So, you want to start helping out with `libgit2`? That's fantastic! We
welcome contributions and we promise we'll try to be nice.
This is a list of libgit2 related projects that new contributors can take
-on. It includes a number of good starter projects and well as some larger
+on. It includes a number of good starter projects as well as some larger
ideas that no one is actively working on.
## Before You Start
@@ -70,11 +70,11 @@ some incremental steps listed towards the larger goal. Those steps
might make good smaller projects by themselves.
* Port part of the Git test suite to run against the command line emulation
- in examples/
- * Pick a Git command that is emulated in our examples/ area
+ in `examples/`
+ * Pick a Git command that is emulated in our `examples/` area
* Extract the Git tests that exercise that command
* Convert the tests to call our emulation
- * These tests could go in examples/tests/...
+ * These tests could go in `examples/tests/`...
* Add hooks API to enumerate and manage hooks (not run them at this point)
* Enumeration of available hooks
* Lookup API to see which hooks have a script and get the script
diff --git a/THREADING.md b/THREADING.md
index 0b9e50286..e9be8b99f 100644
--- a/THREADING.md
+++ b/THREADING.md
@@ -88,7 +88,7 @@ of libssh2 as described above, `git_openssl_set_locking()` is a no-op.
If your programming language offers a package/bindings for OpenSSL,
you should very strongly prefer to use that in order to set up
-locking, as they provide a level of coördination which is impossible
+locking, as they provide a level of coordination which is impossible
when using this function.
See the
@@ -102,7 +102,7 @@ if there are alternatives provided by the system.
libssh2 may be linked against OpenSSL or libgcrypt. If it uses OpenSSL,
see the above paragraphs. If it uses libgcrypt, then you need to
set up its locking before using it multi-threaded. libgit2 has no
-direct connection to libgcrypt and thus has not convenience functions for
+direct connection to libgcrypt and thus has no convenience functions for
it (but libgcrypt has macros). Read libgcrypt's
[threading documentation for more information](http://www.gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html)
diff --git a/include/git2/patch.h b/include/git2/patch.h
index 790cb74fc..4eb9f0263 100644
--- a/include/git2/patch.h
+++ b/include/git2/patch.h
@@ -191,7 +191,7 @@ GIT_EXTERN(int) git_patch_get_hunk(
*
* @param patch The git_patch object
* @param hunk_idx Index of the hunk
- * @return Number of lines in hunk or -1 if invalid hunk index
+ * @return Number of lines in hunk or GIT_ENOTFOUND if invalid hunk index
*/
GIT_EXTERN(int) git_patch_num_lines_in_hunk(
const git_patch *patch,
diff --git a/script/coverity.sh b/script/coverity.sh
index 7fe9eb4c7..5fe16c031 100755
--- a/script/coverity.sh
+++ b/script/coverity.sh
@@ -1,23 +1,22 @@
#!/bin/bash
set -e
-# Environment check
-[ -z "$COVERITY_TOKEN" ] && echo "Need to set a coverity token" && exit 1
-
# Only run this on our branches
-echo "Pull request: $TRAVIS_PULL_REQUEST | Slug: $TRAVIS_REPO_SLUG"
-if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "libgit2/libgit2" ];
+echo "Branch: $TRAVIS_BRANCH | Pull request: $TRAVIS_PULL_REQUEST | Slug: $TRAVIS_REPO_SLUG"
+if [ "$TRAVIS_BRANCH" != "master" -o "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "libgit2/libgit2" ];
then
- echo "Only analyzing 'development' on the main repo."
+ echo "Only analyzing the 'master' brach of the main repository."
exit 0
fi
-COV_VERSION=6.6.1
+# Environment check
+[ -z "$COVERITY_TOKEN" ] && echo "Need to set a coverity token" && exit 1
+
case $(uname -m) in
i?86) BITS=32 ;;
amd64|x86_64) BITS=64 ;;
esac
-SCAN_TOOL=https://scan.coverity.com/download/linux-${BITS}
+SCAN_TOOL=https://scan.coverity.com/download/cxx/linux${BITS}
TOOL_BASE=$(pwd)/_coverity-scan
# Install coverity tools
diff --git a/src/openssl_stream.c b/src/openssl_stream.c
index 826c0a537..ddb9c4ab9 100644
--- a/src/openssl_stream.c
+++ b/src/openssl_stream.c
@@ -164,7 +164,7 @@ int git_openssl_set_locking(void)
git__on_shutdown(shutdown_ssl_locking);
return 0;
#else
- giterr_set(GITERR_THREAD, "libgit2 as not built with threads");
+ giterr_set(GITERR_THREAD, "libgit2 was not built with threads");
return -1;
#endif
}
diff --git a/src/pack.c b/src/pack.c
index 310f00fa3..2ee0c60e4 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -1268,8 +1268,8 @@ static int pack_entry_find_offset(
const git_oid *short_oid,
size_t len)
{
- const uint32_t *level1_ofs = p->index_map.data;
- const unsigned char *index = p->index_map.data;
+ const uint32_t *level1_ofs;
+ const unsigned char *index;
unsigned hi, lo, stride;
int pos, found = 0;
git_off_t offset;
@@ -1283,11 +1283,11 @@ static int pack_entry_find_offset(
if ((error = pack_index_open(p)) < 0)
return error;
assert(p->index_map.data);
-
- index = p->index_map.data;
- level1_ofs = p->index_map.data;
}
+ index = p->index_map.data;
+ level1_ofs = p->index_map.data;
+
if (p->index_version > 1) {
level1_ofs += 2;
index += 8;
diff --git a/src/pqueue.c b/src/pqueue.c
index 8cfc4390f..9341d1af3 100644
--- a/src/pqueue.c
+++ b/src/pqueue.c
@@ -86,8 +86,9 @@ int git_pqueue_insert(git_pqueue *pq, void *item)
if ((pq->flags & GIT_PQUEUE_FIXED_SIZE) != 0 &&
pq->length >= pq->_alloc_size)
{
- /* skip this item if below min item in heap */
- if (pq->_cmp(item, git_vector_get(pq, 0)) <= 0)
+ /* skip this item if below min item in heap or if
+ * we do not have a comparison function */
+ if (!pq->_cmp || pq->_cmp(item, git_vector_get(pq, 0)) <= 0)
return 0;
/* otherwise remove the min item before inserting new */
(void)git_pqueue_pop(pq);
diff --git a/tests/core/pqueue.c b/tests/core/pqueue.c
index bcd4eea9f..2b90f4172 100644
--- a/tests/core/pqueue.c
+++ b/tests/core/pqueue.c
@@ -93,7 +93,29 @@ void test_core_pqueue__max_heap_size(void)
cl_assert_equal_i(0, git_pqueue_size(&pq));
git_pqueue_free(&pq);
+}
+
+void test_core_pqueue__max_heap_size_without_comparison(void)
+{
+ git_pqueue pq;
+ int i, vals[100] = { 0 };
+
+ cl_git_pass(git_pqueue_init(&pq, GIT_PQUEUE_FIXED_SIZE, 50, NULL));
+
+ for (i = 0; i < 100; ++i)
+ cl_git_pass(git_pqueue_insert(&pq, &vals[i]));
+ cl_assert_equal_i(50, git_pqueue_size(&pq));
+
+ /* As we have no comparison function, we cannot make any
+ * actual assumptions about which entries are part of the
+ * pqueue */
+ for (i = 0; i < 50; ++i)
+ cl_assert(git_pqueue_pop(&pq));
+
+ cl_assert_equal_i(0, git_pqueue_size(&pq));
+
+ git_pqueue_free(&pq);
}
static int cmp_ints_like_commit_time(const void *a, const void *b)
diff --git a/tests/core/vector.c b/tests/core/vector.c
index 336254cce..c2e5d3f34 100644
--- a/tests/core/vector.c
+++ b/tests/core/vector.c
@@ -404,4 +404,6 @@ void test_core_vector__reverse(void)
for (i = 0; i < 5; i++)
cl_assert_equal_p(out2[i], git_vector_get(&v, i));
+
+ git_vector_free(&v);
}
diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c
index 9aaad253c..c1ac06dbe 100644
--- a/tests/online/fetchhead.c
+++ b/tests/online/fetchhead.c
@@ -126,6 +126,8 @@ void test_online_fetchhead__explicit_dst_refspec_creates_branch(void)
cl_git_pass(git_branch_lookup(&ref, g_repo, "explicit-refspec", GIT_BRANCH_ALL));
cl_assert_equal_i(refs + 1, count_references());
+
+ git_reference_free(ref);
}
void test_online_fetchhead__empty_dst_refspec_creates_no_branch(void)