Commit c7122033 by Edward Thomson

Merge pull request #3409 from libgit2/update-v23

Maintenance backports for v23
parents d72914db bad51c51
...@@ -152,8 +152,18 @@ STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "$ ...@@ -152,8 +152,18 @@ STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "$
INCLUDE_DIRECTORIES(src include) INCLUDE_DIRECTORIES(src include)
IF (SECURITY_FOUND) IF (SECURITY_FOUND)
# OS X 10.7 and older do not have some functions we use, fall back to OpenSSL there
CHECK_LIBRARY_EXISTS("${SECURITY_DIRS}" SSLCreateContext "Security/SecureTransport.h" HAVE_NEWER_SECURITY)
IF (HAVE_NEWER_SECURITY)
MESSAGE("-- Found Security ${SECURITY_DIRS}") MESSAGE("-- Found Security ${SECURITY_DIRS}")
LIST(APPEND LIBGIT2_PC_LIBS "-framework Security") LIST(APPEND LIBGIT2_PC_LIBS "-framework Security")
ELSE()
MESSAGE("-- Security framework is too old, falling back to OpenSSL")
SET(SECURITY_FOUND "NO")
SET(SECURITY_DIRS "")
SET(SECURITY_DIR "")
SET(USE_OPENSSL "ON")
ENDIF()
ENDIF() ENDIF()
IF (COREFOUNDATION_FOUND) IF (COREFOUNDATION_FOUND)
...@@ -286,7 +296,7 @@ IF (LIBSSH2_FOUND) ...@@ -286,7 +296,7 @@ IF (LIBSSH2_FOUND)
#SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} ${LIBSSH2_LDFLAGS}") #SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} ${LIBSSH2_LDFLAGS}")
SET(SSH_LIBRARIES ${LIBSSH2_LIBRARIES}) SET(SSH_LIBRARIES ${LIBSSH2_LIBRARIES})
CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "" HAVE_LIBSSH2_MEMORY_CREDENTIALS) CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS) IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS)
ADD_DEFINITIONS(-DGIT_SSH_MEMORY_CREDENTIALS) ADD_DEFINITIONS(-DGIT_SSH_MEMORY_CREDENTIALS)
ENDIF() ENDIF()
......
...@@ -407,6 +407,52 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -407,6 +407,52 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
The regex library (deps/regex/) is licensed under the GNU LGPL The regex library (deps/regex/) is licensed under the GNU LGPL
(available at the end of this file).
Definitions for data structures and routines for the regular
expression library.
Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006,2008
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
----------------------------------------------------------------------
The bundled winhttp definition files (deps/winhttp/) are licensed under
the GNU LGPL (available at the end of this file).
Copyright (C) 2007 Francois Gouget
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
----------------------------------------------------------------------
GNU LESSER GENERAL PUBLIC LICENSE GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999 Version 2.1, February 1999
......
...@@ -171,6 +171,9 @@ GIT_EXTERN(int) git_config_new(git_config **out); ...@@ -171,6 +171,9 @@ GIT_EXTERN(int) git_config_new(git_config **out);
* parsed; it's expected to be a native Git config file following * parsed; it's expected to be a native Git config file following
* the default Git config syntax (see man git-config). * the default Git config syntax (see man git-config).
* *
* If the file does not exist, the file will still be added and it
* will be created the first time we write to it.
*
* Note that the configuration object will free the file * Note that the configuration object will free the file
* automatically. * automatically.
* *
...@@ -202,8 +205,7 @@ GIT_EXTERN(int) git_config_add_file_ondisk( ...@@ -202,8 +205,7 @@ GIT_EXTERN(int) git_config_add_file_ondisk(
* *
* @param out The configuration instance to create * @param out The configuration instance to create
* @param path Path to the on-disk file to open * @param path Path to the on-disk file to open
* @return 0 on success, GIT_ENOTFOUND when the file doesn't exist * @return 0 on success, or an error code
* or an error code
*/ */
GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path); GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path);
......
...@@ -34,7 +34,7 @@ typedef struct git_cred_userpass_payload { ...@@ -34,7 +34,7 @@ typedef struct git_cred_userpass_payload {
* *
* @param cred The newly created credential object. * @param cred The newly created credential object.
* @param url The resource for which we are demanding a credential. * @param url The resource for which we are demanding a credential.
* @param user_from_url The username that was embedded in a "user@host" * @param user_from_url The username that was embedded in a "user\@host"
* remote url, or NULL if not included. * remote url, or NULL if not included.
* @param allowed_types A bitmask stating which cred types are OK to return. * @param allowed_types A bitmask stating which cred types are OK to return.
* @param payload The payload provided when specifying this callback. (This is * @param payload The payload provided when specifying this callback. (This is
......
...@@ -220,6 +220,7 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port) ...@@ -220,6 +220,7 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port)
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1); curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1);
curl_easy_setopt(handle, CURLOPT_CERTINFO, 1); curl_easy_setopt(handle, CURLOPT_CERTINFO, 1);
curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1); curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
/* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */ /* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */
......
...@@ -97,8 +97,7 @@ static int diff_driver_add_patterns( ...@@ -97,8 +97,7 @@ static int diff_driver_add_patterns(
for (scan = regex_str; scan; scan = end) { for (scan = regex_str; scan; scan = end) {
/* get pattern to fill in */ /* get pattern to fill in */
if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) { if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) {
error = -1; return -1;
break;
} }
pat->flags = regex_flags; pat->flags = regex_flags;
...@@ -117,10 +116,9 @@ static int diff_driver_add_patterns( ...@@ -117,10 +116,9 @@ static int diff_driver_add_patterns(
break; break;
if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) != 0) { if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) != 0) {
/* if regex fails to compile, warn? fail? */ /*
error = giterr_set_regex(&pat->re, error); * TODO: issue a warning
regfree(&pat->re); */
break;
} }
} }
...@@ -128,7 +126,8 @@ static int diff_driver_add_patterns( ...@@ -128,7 +126,8 @@ static int diff_driver_add_patterns(
(void)git_array_pop(drv->fn_patterns); /* release last item */ (void)git_array_pop(drv->fn_patterns); /* release last item */
git_buf_free(&buf); git_buf_free(&buf);
return error; /* We want to ignore bad patterns, so return success regardless */
return 0;
} }
static int diff_driver_xfuncname(const git_config_entry *entry, void *payload) static int diff_driver_xfuncname(const git_config_entry *entry, void *payload)
......
...@@ -1325,11 +1325,13 @@ static int update_tips_for_spec( ...@@ -1325,11 +1325,13 @@ static int update_tips_for_spec(
for (; i < refs->length; ++i) { for (; i < refs->length; ++i) {
head = git_vector_get(refs, i); head = git_vector_get(refs, i);
autotag = 0; autotag = 0;
git_buf_clear(&refname);
/* Ignore malformed ref names (which also saves us from tag^{} */ /* Ignore malformed ref names (which also saves us from tag^{} */
if (!git_reference_is_valid_name(head->name)) if (!git_reference_is_valid_name(head->name))
continue; continue;
/* If we have a tag, see if the auto-follow rules say to update it */
if (git_refspec_src_matches(&tagspec, head->name)) { if (git_refspec_src_matches(&tagspec, head->name)) {
if (tagopt != GIT_REMOTE_DOWNLOAD_TAGS_NONE) { if (tagopt != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
...@@ -1339,10 +1341,11 @@ static int update_tips_for_spec( ...@@ -1339,10 +1341,11 @@ static int update_tips_for_spec(
git_buf_clear(&refname); git_buf_clear(&refname);
if (git_buf_puts(&refname, head->name) < 0) if (git_buf_puts(&refname, head->name) < 0)
goto on_error; goto on_error;
} else {
continue;
} }
} else if (git_refspec_src_matches(spec, head->name)) { }
/* If we didn't want to auto-follow the tag, check if the refspec matches */
if (!autotag && git_refspec_src_matches(spec, head->name)) {
if (spec->dst) { if (spec->dst) {
if (git_refspec_transform(&refname, spec, head->name) < 0) if (git_refspec_transform(&refname, spec, head->name) < 0)
goto on_error; goto on_error;
...@@ -1356,7 +1359,10 @@ static int update_tips_for_spec( ...@@ -1356,7 +1359,10 @@ static int update_tips_for_spec(
continue; continue;
} }
} else { }
/* If we still don't have a refname, we don't want it */
if (git_buf_len(&refname) == 0) {
continue; continue;
} }
......
...@@ -36,6 +36,8 @@ static const char *post_verb = "POST"; ...@@ -36,6 +36,8 @@ static const char *post_verb = "POST";
#define PARSE_ERROR_GENERIC -1 #define PARSE_ERROR_GENERIC -1
#define PARSE_ERROR_REPLAY -2 #define PARSE_ERROR_REPLAY -2
/** Look at the user field */
#define PARSE_ERROR_EXT -3
#define CHUNK_SIZE 4096 #define CHUNK_SIZE 4096
...@@ -78,6 +80,7 @@ typedef struct { ...@@ -78,6 +80,7 @@ typedef struct {
git_vector www_authenticate; git_vector www_authenticate;
enum last_cb last_cb; enum last_cb last_cb;
int parse_error; int parse_error;
int error;
unsigned parse_finished : 1; unsigned parse_finished : 1;
/* Authentication */ /* Authentication */
...@@ -351,7 +354,8 @@ static int on_headers_complete(http_parser *parser) ...@@ -351,7 +354,8 @@ static int on_headers_complete(http_parser *parser)
if (error == GIT_PASSTHROUGH) { if (error == GIT_PASSTHROUGH) {
no_callback = 1; no_callback = 1;
} else if (error < 0) { } else if (error < 0) {
return PARSE_ERROR_GENERIC; t->error = error;
return t->parse_error = PARSE_ERROR_EXT;
} else { } else {
assert(t->cred); assert(t->cred);
...@@ -712,6 +716,10 @@ replay: ...@@ -712,6 +716,10 @@ replay:
goto replay; goto replay;
} }
if (t->parse_error == PARSE_ERROR_EXT) {
return t->error;
}
if (t->parse_error < 0) if (t->parse_error < 0)
return -1; return -1;
......
...@@ -957,7 +957,7 @@ int git_smart__push(git_transport *transport, git_push *push, const git_remote_c ...@@ -957,7 +957,7 @@ int git_smart__push(git_transport *transport, git_push *push, const git_remote_c
packbuilder_payload.pb = push->pb; packbuilder_payload.pb = push->pb;
if (cbs && cbs->transfer_progress) { if (cbs && cbs->push_transfer_progress) {
packbuilder_payload.cb = cbs->push_transfer_progress; packbuilder_payload.cb = cbs->push_transfer_progress;
packbuilder_payload.cb_payload = cbs->payload; packbuilder_payload.cb_payload = cbs->payload;
} }
......
...@@ -250,3 +250,29 @@ void test_diff_drivers__builtins(void) ...@@ -250,3 +250,29 @@ void test_diff_drivers__builtins(void)
git_buf_free(&expected); git_buf_free(&expected);
git_vector_free(&files); git_vector_free(&files);
} }
void test_diff_drivers__invalid_pattern(void)
{
git_config *cfg;
git_index *idx;
git_diff *diff;
git_patch *patch;
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
g_repo = cl_git_sandbox_init("userdiff");
cl_git_mkfile("userdiff/.gitattributes", "*.storyboard diff=storyboard\n");
cl_git_pass(git_repository_config__weakptr(&cfg, g_repo));
cl_git_pass(git_config_set_string(cfg, "diff.storyboard.xfuncname", "<!--(.*?)-->"));
cl_git_mkfile("userdiff/dummy.storyboard", "");
cl_git_pass(git_repository_index__weakptr(&idx, g_repo));
cl_git_pass(git_index_add_bypath(idx, "dummy.storyboard"));
cl_git_mkfile("userdiff/dummy.storyboard", "some content\n");
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
cl_git_pass(git_patch_from_diff(&patch, diff, 0));
git_patch_free(patch);
git_diff_free(diff);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment