Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2f2575c
Updating http parser to accept a `+` in the schema
cbargren Dec 22, 2015
ff8e3f0
Handle git+ssh:// and ssh+git:// protocols support
cbargren Dec 22, 2015
fa8b1a8
Adding spec coverage for ssh+git and git+ssh protocols
cbargren Dec 22, 2015
429155d
Updating change to http_parser to reflect PR for nodejs/http-parser
cbargren Dec 28, 2015
e44f658
Removing #define for SSH_PREFIX_COUNT and using ARRAY_SIZE instead
cbargren Dec 28, 2015
b8dc15f
Adding test cases that actually test the functionality of the new tra…
cbargren Dec 28, 2015
4a93a7f
Tabs
cbargren Dec 28, 2015
8ec3d88
Avoid subtraction overflow in git_indexer_commit
Dec 24, 2015
e3862c9
Buffer sideband packet data
chescock Jan 11, 2016
cdded63
Remove duplicated calls to git_mwindow_close
pmq20 Jan 13, 2016
eb09ead
odb: improved not found error messages
Mar 4, 2016
9ee498e
Only buffer if necessary.
chescock Mar 8, 2016
4ebf745
mwindow: free unused windows if we fail to mmap
carlosmn Mar 9, 2016
ffb1f41
describe: handle error code returned by git_pqueue_insert
pks-t Mar 1, 2016
e39ad74
config_file: handle missing quotation marks in section header
pks-t Mar 1, 2016
0370dae
Check for __CLANG_INTTYPES_H
pietbrauer Feb 25, 2016
faf823d
tests: transport: fix memory leaks with registering transports
pks-t Mar 11, 2016
fa4b93a
backport git_oid__cpy_prefix
Apr 11, 2016
d0780b8
object: avoid call of memset with ouf of bounds pointer
pks-t Mar 1, 2016
e114bba
index: assert required OID are non-NULL
pks-t Mar 1, 2016
1a16e8b
pack-objects: fix memory leak on overflow
pks-t Mar 1, 2016
d96c063
submodule: avoid passing NULL pointers to strncmp
pks-t Mar 1, 2016
851c51a
diff_tform: fix potential NULL pointer access
pks-t Mar 10, 2016
0b357e2
coverity: report errors when uploading tarball
pks-t Mar 2, 2016
8d3ee96
refdb_fs: fail if refcache returns NULL pointer
pks-t Mar 10, 2016
dd78d7d
blame_git: handle error returned by `git_commit_parent`
pks-t Mar 10, 2016
f17ed63
blame: handle error when resoling HEAD in normalize_options
pks-t Mar 10, 2016
18c4ae7
filebuf: handle write error in `lock_file`
pks-t Mar 10, 2016
89e7604
config_cache: check return value of `git_config__lookup_entry`
pks-t Mar 10, 2016
c1ec732
Setup better defaults for OpenSSL ciphers
dbussink Mar 14, 2016
4e91020
Start error string with lower case character
dbussink Mar 14, 2016
cdde081
Use general cl_git_fail because the error is generic
dbussink Mar 14, 2016
f587f38
CMake: do not overwrite but only append to CMAKE_C_FLAGS_DEBUG
mstrap Mar 15, 2016
9a668ab
Option "LIBGIT2_PREFIX" to set the CMAKE's TARGET_PROPERTIES PREFIX
mstrap Mar 15, 2016
d8fcafb
Split the page size from the mmap alignment
carlosmn Mar 16, 2016
e97d2d7
commit: fix extraction of single-line signatures
carlosmn Mar 17, 2016
a1cf264
win32: free thread-local data on thread exit
carlosmn Mar 18, 2016
c86a65b
config: don't special-case multivars that don't exist yet
carlosmn Mar 21, 2016
3ec0f2e
xdiff/xprepare: use the XDF_DIFF_ALG() macro to access flag bits
pks-t Mar 31, 2016
56da07c
xdiff/xprepare: fix a memory leak
pks-t Mar 31, 2016
fe1f477
Add a no-op size_t typedef for the doc parser
carlosmn Mar 31, 2016
ab062a3
tests: fix core/stream test when built with openssl off
andhe Apr 6, 2016
3e2e824
refs: provide a more general error message for dwim
carlosmn Apr 11, 2016
ba52879
reset: use real ids for the tests
carlosmn Apr 11, 2016
b6130fe
refs::create: strict object creation on by default
Apr 11, 2016
e8d5df9
config: show we write a spurious duplicated section header
carlosmn Mar 4, 2016
a13c1ec
config: don't write section header if we're in it
Mar 28, 2016
21d8832
config::write::repeated: init our buffer
Mar 28, 2016
1778908
ignore: don't use realpath to canonicalize path
carlosmn Apr 1, 2016
26f2cef
tree: re-use the id and filename in the odb object
carlosmn Mar 20, 2016
13ebf7b
tree: store the entries in a growable array
carlosmn Mar 20, 2016
af753ab
tree: drop the now-unnecessary entries vector
Mar 22, 2016
1d59c85
status: update test to include valid OID
Mar 17, 2016
5cc7a5c
tests: skip the unreadable file tests as root
Apr 11, 2016
2c1bc36
Plug a few leaks
carlosmn Mar 29, 2016
6a35e74
leaks: fix some leaks in the tests
Mar 30, 2016
ccfacb8
leaks: call `xdl_free_classifier`
Mar 31, 2016
8edadbf
index::racy: force racy entry
Mar 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ IF (MSVC)
# /MTd - Statically link the multithreaded debug version of the CRT
# /MDd - Dynamically link the multithreaded debug version of the CRT
# /RTC1 - Run time checks
SET(CMAKE_C_FLAGS_DEBUG "/Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")

# /DNDEBUG - Disables asserts
# /MT - Statically link the multithreaded release version of the CRT
Expand Down Expand Up @@ -464,7 +464,7 @@ ELSE ()
ENDIF()

IF (WIN32 AND NOT CYGWIN)
SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
ENDIF ()

IF (MINGW) # MinGW always does PIC and complains if we tell it to
Expand Down Expand Up @@ -608,6 +608,8 @@ IF (SONAME)
IF (LIBGIT2_FILENAME)
ADD_DEFINITIONS(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
SET_TARGET_PROPERTIES(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
ELSEIF (DEFINED LIBGIT2_PREFIX)
SET_TARGET_PROPERTIES(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
ENDIF()
ENDIF()
STRING(REPLACE ";" " " LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS}")
Expand Down
7 changes: 5 additions & 2 deletions deps/http-parser/http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ do { \
FOR##_mark = NULL; \
} \
} while (0)

/* Run the data callback FOR and consume the current byte */
#define CALLBACK_DATA(FOR) \
CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1)
Expand Down Expand Up @@ -444,14 +444,17 @@ parse_url_char(enum state s, const char ch)
return s_req_path;
}

/* The schema must start with an alpha character. After that, it may
* consist of digits, '+', '-' or '.', followed by a ':'.
*/
if (IS_ALPHA(ch)) {
return s_req_schema;
}

break;

case s_req_schema:
if (IS_ALPHA(ch)) {
if (IS_ALPHANUM(ch) || ch == '+' || ch == '-' || ch == '.') {
return s;
}

Expand Down
17 changes: 16 additions & 1 deletion include/git2/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@
GIT_BEGIN_DECL
# include "inttypes.h"
GIT_END_DECL
#else
/** This check is needed for importing this file in an iOS/OS X framework throws an error in Xcode otherwise.*/
#elif !defined(__CLANG_INTTYPES_H)
# include <inttypes.h>
#endif

#ifdef DOCURIUM
/*
* This is so clang's doc parser acknowledges comments on functions
* with size_t parameters.
*/
typedef size_t size_t;
#endif

/** Declare a public function exported for application use. */
#if __GNUC__ >= 4
# define GIT_EXTERN(type) extern \
Expand Down Expand Up @@ -148,6 +157,7 @@ typedef enum {
GIT_OPT_SET_SSL_CERT_LOCATIONS,
GIT_OPT_SET_USER_AGENT,
GIT_OPT_ENABLE_STRICT_OBJECT_CREATION,
GIT_OPT_SET_SSL_CIPHERS,
} git_libgit2_opt_t;

/**
Expand Down Expand Up @@ -259,6 +269,11 @@ typedef enum {
* > example, when this is enabled, the parent(s) and tree inputs
* > will be validated when creating a new commit. This defaults
* > to disabled.
* * opts(GIT_OPT_SET_SSL_CIPHERS, const char *ciphers)
*
* > Set the SSL ciphers use for HTTPS connections.
* >
* > - `ciphers` is the list of ciphers that are eanbled.
*
* @param option Option key
* @param ... value to set the option
Expand Down
18 changes: 16 additions & 2 deletions script/coverity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,24 @@ COVERITY_UNSUPPORTED=1 \
# Upload results
tar czf libgit2.tgz cov-int
SHA=$(git rev-parse --short HEAD)
curl \

HTML="$(curl \
--silent \
--write-out "\n%{http_code}" \
--form token="$COVERITY_TOKEN" \
--form [email protected] \
--form [email protected] \
--form version="$SHA" \
--form description="Travis build" \
https://scan.coverity.com/builds?project=libgit2
https://scan.coverity.com/builds?project=libgit2)"
# Body is everything up to the last line
BODY="$(echo "$HTML" | head -n-1)"
# Status code is the last line
STATUS_CODE="$(echo "$HTML" | tail -n1)"

echo "${BODY}"

if [ "${STATUS_CODE}" != "201" ]; then
echo "Received error code ${STATUS_CODE} from Coverity"
exit 1
fi
40 changes: 40 additions & 0 deletions src/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,44 @@ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)

#define git_array_valid_index(a, i) ((i) < (a).size)

#define git_array_foreach(a, i, element) \
for ((i) = 0; (i) < (a).size && ((element) = &(a).ptr[(i)]); (i)++)


GIT_INLINE(int) git_array__search(
size_t *out,
void *array_ptr,
size_t item_size,
size_t array_len,
int (*compare)(const void *, const void *),
const void *key)
{
size_t lim;
unsigned char *part, *array = array_ptr, *base = array_ptr;
int cmp;

for (lim = array_len; lim != 0; lim >>= 1) {
part = base + (lim >> 1) * item_size;
cmp = (*compare)(key, part);

if (cmp == 0) {
base = part;
break;
}
if (cmp > 0) { /* key > p; take right partition */
base = part + 1 * item_size;
lim--;
} /* else take left partition */
}

if (out)
*out = (base - array) / item_size;

return (cmp == 0) ? 0 : GIT_ENOTFOUND;
}

#define git_array_search(out, a, cmp, key) \
git_array__search(out, (a).ptr, sizeof(*(a).ptr), (a).size, \
(cmp), (key))

#endif
11 changes: 8 additions & 3 deletions src/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const git_blame_hunk *git_blame_get_hunk_byline(git_blame *blame, size_t lineno)
return NULL;
}

static void normalize_options(
static int normalize_options(
git_blame_options *out,
const git_blame_options *in,
git_repository *repo)
Expand All @@ -190,7 +190,9 @@ static void normalize_options(

/* No newest_commit => HEAD */
if (git_oid_iszero(&out->newest_commit)) {
git_reference_name_to_id(&out->newest_commit, repo, "HEAD");
if (git_reference_name_to_id(&out->newest_commit, repo, "HEAD") < 0) {
return -1;
}
}

/* min_line 0 really means 1 */
Expand All @@ -204,6 +206,8 @@ static void normalize_options(
out->flags |= GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES;
if (out->flags & GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES)
out->flags |= GIT_BLAME_TRACK_COPIES_SAME_FILE;

return 0;
}

static git_blame_hunk *split_hunk_in_vector(
Expand Down Expand Up @@ -362,7 +366,8 @@ int git_blame_file(
git_blame *blame = NULL;

assert(out && repo && path);
normalize_options(&normOptions, options, repo);
if ((error = normalize_options(&normOptions, options, repo)) < 0)
goto on_error;

blame = git_blame__alloc(repo, normOptions, path);
GITERR_CHECK_ALLOC(blame);
Expand Down
3 changes: 2 additions & 1 deletion src/blame_git.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
if (sg_origin[i])
continue;

git_commit_parent(&p, origin->commit, i);
if ((error = git_commit_parent(&p, origin->commit, i)) < 0)
goto finish;
porigin = find_origin(blame, p, origin);

if (!porigin)
Expand Down
2 changes: 1 addition & 1 deletion src/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r

buf = git_odb_object_data(obj);

while ((h = strchr(buf, '\n')) && h[1] != '\0' && h[1] != '\n') {
while ((h = strchr(buf, '\n')) && h[1] != '\0') {
h++;
if (git__prefixcmp(buf, field)) {
if (git_buf_put(signed_data, buf, h - buf) < 0)
Expand Down
3 changes: 2 additions & 1 deletion src/config_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar)
struct map_data *data = &_cvar_maps[(int)cvar];
git_config_entry *entry;

git_config__lookup_entry(&entry, config, data->cvar_name, false);
if ((error = git_config__lookup_entry(&entry, config, data->cvar_name, false)) < 0)
return error;

if (!entry)
*out = data->default_value;
Expand Down
34 changes: 14 additions & 20 deletions src/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,30 +553,15 @@ static int config_set_multivar(
git_config_backend *cfg, const char *name, const char *regexp, const char *value)
{
diskfile_backend *b = (diskfile_backend *)cfg;
refcounted_strmap *map;
git_strmap *values;
char *key;
regex_t preg;
int result;
khiter_t pos;

assert(regexp);

if ((result = git_config__normalize_name(name, &key)) < 0)
return result;

map = refcounted_strmap_take(&b->header);
values = b->header.values->values;

pos = git_strmap_lookup_index(values, key);
if (!git_strmap_valid_index(values, pos)) {
/* If we don't have it, behave like a normal set */
result = config_set(cfg, name, value);
refcounted_strmap_free(map);
git__free(key);
return result;
}

result = regcomp(&preg, regexp, REG_EXTENDED);
if (result != 0) {
giterr_set_regex(&preg, result);
Expand All @@ -591,7 +576,6 @@ static int config_set_multivar(
result = config_refresh(cfg);

out:
refcounted_strmap_free(map);
git__free(key);
regfree(&preg);

Expand Down Expand Up @@ -1032,6 +1016,11 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
*/

first_quote = strchr(line, '"');
if (first_quote == NULL) {
set_parse_error(reader, 0, "Missing quotation marks in section header");
return -1;
}

last_quote = strrchr(line, '"');
quoted_len = last_quote - first_quote;

Expand Down Expand Up @@ -1483,7 +1472,7 @@ static int config_parse(
int (*on_section)(struct reader **reader, const char *current_section, const char *line, size_t line_len, void *data),
int (*on_variable)(struct reader **reader, const char *current_section, char *var_name, char *var_value, const char *line, size_t line_len, void *data),
int (*on_comment)(struct reader **reader, const char *line, size_t line_len, void *data),
int (*on_eof)(struct reader **reader, void *data),
int (*on_eof)(struct reader **reader, const char *current_section, void *data),
void *data)
{
char *current_section = NULL, *var_name, *var_value, *line_start;
Expand Down Expand Up @@ -1534,7 +1523,7 @@ static int config_parse(
}

if (on_eof)
result = on_eof(&reader, data);
result = on_eof(&reader, current_section, data);

git__free(current_section);
return result;
Expand Down Expand Up @@ -1850,7 +1839,8 @@ static int write_on_comment(struct reader **reader, const char *line, size_t lin
return write_line_to(&write_data->buffered_comment, line, line_len);
}

static int write_on_eof(struct reader **reader, void *data)
static int write_on_eof(
struct reader **reader, const char *current_section, void *data)
{
struct write_data *write_data = (struct write_data *)data;
int result = 0;
Expand All @@ -1869,7 +1859,11 @@ static int write_on_eof(struct reader **reader, void *data)
* value.
*/
if ((!write_data->preg || !write_data->preg_replaced) && write_data->value) {
if ((result = write_section(write_data->buf, write_data->section)) == 0)
/* write the section header unless we're already in it */
if (!current_section || strcmp(current_section, write_data->section))
result = write_section(write_data->buf, write_data->section);

if (!result)
result = write_value(write_data);
}

Expand Down
3 changes: 2 additions & 1 deletion src/describe.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ static int describe(
best = (struct possible_tag *)git_vector_get(&all_matches, 0);

if (gave_up_on) {
git_pqueue_insert(&list, gave_up_on);
if ((error = git_pqueue_insert(&list, gave_up_on)) < 0)
goto cleanup;
seen_commits--;
}
if ((error = finish_depth_computation(
Expand Down
8 changes: 5 additions & 3 deletions src/diff_tform.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ static int normalize_find_opts(
if (!given ||
(given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG)
{
if (diff->repo) {
if (cfg) {
char *rule =
git_config__get_string_force(cfg, "diff.renames", "true");
int boolval;
Expand Down Expand Up @@ -318,8 +318,10 @@ static int normalize_find_opts(
#undef USE_DEFAULT

if (!opts->rename_limit) {
opts->rename_limit = git_config__get_int_force(
cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT);
if (cfg) {
opts->rename_limit = git_config__get_int_force(
cfg, "diff.renamelimit", DEFAULT_RENAME_LIMIT);
}

if (opts->rename_limit <= 0)
opts->rename_limit = DEFAULT_RENAME_LIMIT;
Expand Down
7 changes: 6 additions & 1 deletion src/filebuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
git_file source;
char buffer[FILEIO_BUFSIZE];
ssize_t read_bytes;
int error;

source = p_open(file->path_original, O_RDONLY);
if (source < 0) {
Expand All @@ -80,7 +81,8 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
}

while ((read_bytes = p_read(source, buffer, sizeof(buffer))) > 0) {
p_write(file->fd, buffer, read_bytes);
if ((error = p_write(file->fd, buffer, read_bytes)) < 0)
break;
if (file->compute_digest)
git_hash_update(&file->digest, buffer, read_bytes);
}
Expand All @@ -90,6 +92,9 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
if (read_bytes < 0) {
giterr_set(GITERR_OS, "Failed to read file '%s'", file->path_original);
return -1;
} else if (error < 0) {
giterr_set(GITERR_OS, "Failed to write file '%s'", file->path_lock);
return -1;
}
}

Expand Down
Loading