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

Skip to content

Commit c712203

Browse files
committed
Merge pull request libgit2#3409 from libgit2/update-v23
Maintenance backports for v23
2 parents d72914d + bad51c5 commit c712203

File tree

10 files changed

+117
-19
lines changed

10 files changed

+117
-19
lines changed

CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,18 @@ STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "$
152152
INCLUDE_DIRECTORIES(src include)
153153

154154
IF (SECURITY_FOUND)
155-
MESSAGE("-- Found Security ${SECURITY_DIRS}")
156-
LIST(APPEND LIBGIT2_PC_LIBS "-framework Security")
155+
# OS X 10.7 and older do not have some functions we use, fall back to OpenSSL there
156+
CHECK_LIBRARY_EXISTS("${SECURITY_DIRS}" SSLCreateContext "Security/SecureTransport.h" HAVE_NEWER_SECURITY)
157+
IF (HAVE_NEWER_SECURITY)
158+
MESSAGE("-- Found Security ${SECURITY_DIRS}")
159+
LIST(APPEND LIBGIT2_PC_LIBS "-framework Security")
160+
ELSE()
161+
MESSAGE("-- Security framework is too old, falling back to OpenSSL")
162+
SET(SECURITY_FOUND "NO")
163+
SET(SECURITY_DIRS "")
164+
SET(SECURITY_DIR "")
165+
SET(USE_OPENSSL "ON")
166+
ENDIF()
157167
ENDIF()
158168

159169
IF (COREFOUNDATION_FOUND)
@@ -286,7 +296,7 @@ IF (LIBSSH2_FOUND)
286296
#SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} ${LIBSSH2_LDFLAGS}")
287297
SET(SSH_LIBRARIES ${LIBSSH2_LIBRARIES})
288298

289-
CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
299+
CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
290300
IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS)
291301
ADD_DEFINITIONS(-DGIT_SSH_MEMORY_CREDENTIALS)
292302
ENDIF()

COPYING

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,52 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
407407
----------------------------------------------------------------------
408408

409409
The regex library (deps/regex/) is licensed under the GNU LGPL
410+
(available at the end of this file).
411+
412+
Definitions for data structures and routines for the regular
413+
expression library.
414+
415+
Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006,2008
416+
Free Software Foundation, Inc.
417+
This file is part of the GNU C Library.
418+
419+
The GNU C Library is free software; you can redistribute it and/or
420+
modify it under the terms of the GNU Lesser General Public
421+
License as published by the Free Software Foundation; either
422+
version 2.1 of the License, or (at your option) any later version.
423+
424+
The GNU C Library is distributed in the hope that it will be useful,
425+
but WITHOUT ANY WARRANTY; without even the implied warranty of
426+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
427+
Lesser General Public License for more details.
428+
429+
You should have received a copy of the GNU Lesser General Public
430+
License along with the GNU C Library; if not, write to the Free
431+
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
432+
02110-1301 USA.
433+
434+
----------------------------------------------------------------------
435+
436+
The bundled winhttp definition files (deps/winhttp/) are licensed under
437+
the GNU LGPL (available at the end of this file).
438+
439+
Copyright (C) 2007 Francois Gouget
440+
441+
This library is free software; you can redistribute it and/or
442+
modify it under the terms of the GNU Lesser General Public
443+
License as published by the Free Software Foundation; either
444+
version 2.1 of the License, or (at your option) any later version.
445+
446+
This library is distributed in the hope that it will be useful,
447+
but WITHOUT ANY WARRANTY; without even the implied warranty of
448+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
449+
Lesser General Public License for more details.
450+
451+
You should have received a copy of the GNU Lesser General Public
452+
License along with this library; if not, write to the Free Software
453+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
454+
455+
----------------------------------------------------------------------
410456

411457
GNU LESSER GENERAL PUBLIC LICENSE
412458
Version 2.1, February 1999

include/git2/config.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ GIT_EXTERN(int) git_config_new(git_config **out);
171171
* parsed; it's expected to be a native Git config file following
172172
* the default Git config syntax (see man git-config).
173173
*
174+
* If the file does not exist, the file will still be added and it
175+
* will be created the first time we write to it.
176+
*
174177
* Note that the configuration object will free the file
175178
* automatically.
176179
*
@@ -202,8 +205,7 @@ GIT_EXTERN(int) git_config_add_file_ondisk(
202205
*
203206
* @param out The configuration instance to create
204207
* @param path Path to the on-disk file to open
205-
* @return 0 on success, GIT_ENOTFOUND when the file doesn't exist
206-
* or an error code
208+
* @return 0 on success, or an error code
207209
*/
208210
GIT_EXTERN(int) git_config_open_ondisk(git_config **out, const char *path);
209211

include/git2/cred_helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct git_cred_userpass_payload {
3434
*
3535
* @param cred The newly created credential object.
3636
* @param url The resource for which we are demanding a credential.
37-
* @param user_from_url The username that was embedded in a "user@host"
37+
* @param user_from_url The username that was embedded in a "user\@host"
3838
* remote url, or NULL if not included.
3939
* @param allowed_types A bitmask stating which cred types are OK to return.
4040
* @param payload The payload provided when specifying this callback. (This is

src/curl_stream.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ int git_curl_stream_new(git_stream **out, const char *host, const char *port)
220220
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1);
221221
curl_easy_setopt(handle, CURLOPT_CERTINFO, 1);
222222
curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1);
223+
curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
223224

224225
/* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */
225226

src/diff_driver.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ static int diff_driver_add_patterns(
9797
for (scan = regex_str; scan; scan = end) {
9898
/* get pattern to fill in */
9999
if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) {
100-
error = -1;
101-
break;
100+
return -1;
102101
}
103102

104103
pat->flags = regex_flags;
@@ -117,18 +116,18 @@ static int diff_driver_add_patterns(
117116
break;
118117

119118
if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) != 0) {
120-
/* if regex fails to compile, warn? fail? */
121-
error = giterr_set_regex(&pat->re, error);
122-
regfree(&pat->re);
123-
break;
119+
/*
120+
* TODO: issue a warning
121+
*/
124122
}
125123
}
126124

127125
if (error && pat != NULL)
128126
(void)git_array_pop(drv->fn_patterns); /* release last item */
129127
git_buf_free(&buf);
130128

131-
return error;
129+
/* We want to ignore bad patterns, so return success regardless */
130+
return 0;
132131
}
133132

134133
static int diff_driver_xfuncname(const git_config_entry *entry, void *payload)

src/remote.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,11 +1325,13 @@ static int update_tips_for_spec(
13251325
for (; i < refs->length; ++i) {
13261326
head = git_vector_get(refs, i);
13271327
autotag = 0;
1328+
git_buf_clear(&refname);
13281329

13291330
/* Ignore malformed ref names (which also saves us from tag^{} */
13301331
if (!git_reference_is_valid_name(head->name))
13311332
continue;
13321333

1334+
/* If we have a tag, see if the auto-follow rules say to update it */
13331335
if (git_refspec_src_matches(&tagspec, head->name)) {
13341336
if (tagopt != GIT_REMOTE_DOWNLOAD_TAGS_NONE) {
13351337

@@ -1339,10 +1341,11 @@ static int update_tips_for_spec(
13391341
git_buf_clear(&refname);
13401342
if (git_buf_puts(&refname, head->name) < 0)
13411343
goto on_error;
1342-
} else {
1343-
continue;
13441344
}
1345-
} else if (git_refspec_src_matches(spec, head->name)) {
1345+
}
1346+
1347+
/* If we didn't want to auto-follow the tag, check if the refspec matches */
1348+
if (!autotag && git_refspec_src_matches(spec, head->name)) {
13461349
if (spec->dst) {
13471350
if (git_refspec_transform(&refname, spec, head->name) < 0)
13481351
goto on_error;
@@ -1356,7 +1359,10 @@ static int update_tips_for_spec(
13561359

13571360
continue;
13581361
}
1359-
} else {
1362+
}
1363+
1364+
/* If we still don't have a refname, we don't want it */
1365+
if (git_buf_len(&refname) == 0) {
13601366
continue;
13611367
}
13621368

src/transports/http.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static const char *post_verb = "POST";
3636

3737
#define PARSE_ERROR_GENERIC -1
3838
#define PARSE_ERROR_REPLAY -2
39+
/** Look at the user field */
40+
#define PARSE_ERROR_EXT -3
3941

4042
#define CHUNK_SIZE 4096
4143

@@ -78,6 +80,7 @@ typedef struct {
7880
git_vector www_authenticate;
7981
enum last_cb last_cb;
8082
int parse_error;
83+
int error;
8184
unsigned parse_finished : 1;
8285

8386
/* Authentication */
@@ -351,7 +354,8 @@ static int on_headers_complete(http_parser *parser)
351354
if (error == GIT_PASSTHROUGH) {
352355
no_callback = 1;
353356
} else if (error < 0) {
354-
return PARSE_ERROR_GENERIC;
357+
t->error = error;
358+
return t->parse_error = PARSE_ERROR_EXT;
355359
} else {
356360
assert(t->cred);
357361

@@ -712,6 +716,10 @@ static int http_stream_read(
712716
goto replay;
713717
}
714718

719+
if (t->parse_error == PARSE_ERROR_EXT) {
720+
return t->error;
721+
}
722+
715723
if (t->parse_error < 0)
716724
return -1;
717725

src/transports/smart_protocol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ int git_smart__push(git_transport *transport, git_push *push, const git_remote_c
957957

958958
packbuilder_payload.pb = push->pb;
959959

960-
if (cbs && cbs->transfer_progress) {
960+
if (cbs && cbs->push_transfer_progress) {
961961
packbuilder_payload.cb = cbs->push_transfer_progress;
962962
packbuilder_payload.cb_payload = cbs->payload;
963963
}

tests/diff/drivers.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,29 @@ void test_diff_drivers__builtins(void)
250250
git_buf_free(&expected);
251251
git_vector_free(&files);
252252
}
253+
254+
void test_diff_drivers__invalid_pattern(void)
255+
{
256+
git_config *cfg;
257+
git_index *idx;
258+
git_diff *diff;
259+
git_patch *patch;
260+
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
261+
262+
g_repo = cl_git_sandbox_init("userdiff");
263+
cl_git_mkfile("userdiff/.gitattributes", "*.storyboard diff=storyboard\n");
264+
265+
cl_git_pass(git_repository_config__weakptr(&cfg, g_repo));
266+
cl_git_pass(git_config_set_string(cfg, "diff.storyboard.xfuncname", "<!--(.*?)-->"));
267+
268+
cl_git_mkfile("userdiff/dummy.storyboard", "");
269+
cl_git_pass(git_repository_index__weakptr(&idx, g_repo));
270+
cl_git_pass(git_index_add_bypath(idx, "dummy.storyboard"));
271+
cl_git_mkfile("userdiff/dummy.storyboard", "some content\n");
272+
273+
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
274+
cl_git_pass(git_patch_from_diff(&patch, diff, 0));
275+
276+
git_patch_free(patch);
277+
git_diff_free(diff);
278+
}

0 commit comments

Comments
 (0)