rugged 0.24.0 → 0.24.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +20 -9
  4. data/vendor/libgit2/deps/http-parser/http_parser.c +5 -2
  5. data/vendor/libgit2/include/git2/checkout.h +7 -0
  6. data/vendor/libgit2/include/git2/common.h +16 -1
  7. data/vendor/libgit2/include/git2/version.h +2 -2
  8. data/vendor/libgit2/src/array.h +40 -0
  9. data/vendor/libgit2/src/blame.c +8 -3
  10. data/vendor/libgit2/src/blame_git.c +20 -9
  11. data/vendor/libgit2/src/checkout.c +13 -5
  12. data/vendor/libgit2/src/commit.c +5 -4
  13. data/vendor/libgit2/src/common.h +1 -1
  14. data/vendor/libgit2/src/config_cache.c +2 -1
  15. data/vendor/libgit2/src/config_file.c +14 -20
  16. data/vendor/libgit2/src/delta-apply.c +36 -5
  17. data/vendor/libgit2/src/delta-apply.h +12 -0
  18. data/vendor/libgit2/src/describe.c +2 -1
  19. data/vendor/libgit2/src/diff_tform.c +5 -3
  20. data/vendor/libgit2/src/filebuf.c +6 -1
  21. data/vendor/libgit2/src/global.c +28 -8
  22. data/vendor/libgit2/src/global.h +1 -0
  23. data/vendor/libgit2/src/ignore.c +56 -19
  24. data/vendor/libgit2/src/index.c +27 -8
  25. data/vendor/libgit2/src/indexer.c +11 -7
  26. data/vendor/libgit2/src/iterator.c +2 -2
  27. data/vendor/libgit2/src/merge.c +1 -0
  28. data/vendor/libgit2/src/mwindow.c +20 -21
  29. data/vendor/libgit2/src/mwindow.h +1 -2
  30. data/vendor/libgit2/src/object.c +3 -6
  31. data/vendor/libgit2/src/odb.c +11 -15
  32. data/vendor/libgit2/src/odb.h +2 -1
  33. data/vendor/libgit2/src/odb_loose.c +13 -9
  34. data/vendor/libgit2/src/odb_pack.c +5 -6
  35. data/vendor/libgit2/src/oid.h +9 -0
  36. data/vendor/libgit2/src/openssl_stream.c +60 -27
  37. data/vendor/libgit2/src/openssl_stream.h +106 -0
  38. data/vendor/libgit2/src/pack-objects.c +4 -2
  39. data/vendor/libgit2/src/pack.c +10 -14
  40. data/vendor/libgit2/src/posix.c +7 -0
  41. data/vendor/libgit2/src/posix.h +1 -0
  42. data/vendor/libgit2/src/push.c +6 -6
  43. data/vendor/libgit2/src/refdb_fs.c +1 -0
  44. data/vendor/libgit2/src/refs.c +3 -0
  45. data/vendor/libgit2/src/refspec.c +4 -2
  46. data/vendor/libgit2/src/remote.c +15 -5
  47. data/vendor/libgit2/src/repository.c +29 -21
  48. data/vendor/libgit2/src/settings.c +23 -1
  49. data/vendor/libgit2/src/stransport_stream.c +15 -9
  50. data/vendor/libgit2/src/submodule.c +3 -2
  51. data/vendor/libgit2/src/sysdir.c +41 -47
  52. data/vendor/libgit2/src/sysdir.h +0 -5
  53. data/vendor/libgit2/src/tag.c +8 -2
  54. data/vendor/libgit2/src/thread-utils.h +5 -51
  55. data/vendor/libgit2/src/transport.c +2 -0
  56. data/vendor/libgit2/src/transports/http.c +2 -1
  57. data/vendor/libgit2/src/transports/smart_pkt.c +1 -0
  58. data/vendor/libgit2/src/transports/smart_protocol.c +72 -17
  59. data/vendor/libgit2/src/transports/ssh.c +32 -17
  60. data/vendor/libgit2/src/tree.c +83 -100
  61. data/vendor/libgit2/src/tree.h +4 -5
  62. data/vendor/libgit2/src/unix/map.c +5 -0
  63. data/vendor/libgit2/src/unix/pthread.h +54 -0
  64. data/vendor/libgit2/src/util.c +3 -3
  65. data/vendor/libgit2/src/win32/map.c +24 -5
  66. data/vendor/libgit2/src/win32/precompiled.h +1 -1
  67. data/vendor/libgit2/src/win32/{pthread.c → thread.c} +50 -80
  68. data/vendor/libgit2/src/win32/thread.h +62 -0
  69. data/vendor/libgit2/src/xdiff/xprepare.c +2 -1
  70. metadata +384 -394
  71. data/vendor/libgit2/src/win32/pthread.h +0 -92
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 73d29b4faaac41e9ef1e93c0192e1c8827eaa745
4
+ data.tar.gz: dbe2d750a922c46a144b0e17f93d6ee18d451c32
5
+ SHA512:
6
+ metadata.gz: fd5ebf3e609e2b749fc98938184a59eebaaeb6b6791763083d97e0044f1dec29e50835c4a448a52ad1349fa71b73ffd01e7af6042e3fe0cc5bf3a4dff8e99650
7
+ data.tar.gz: c52fb2d126fccd0cb438bf07e1c3c0729d6fa9b323949383d04a4dd57f1733582b4a104d66029e410350fd9182506310e14964798832be3734c4b37aa744e021
@@ -1,3 +1,3 @@
1
1
  module Rugged
2
- Version = VERSION = '0.24.0'
2
+ Version = VERSION = '0.24.5'
3
3
  end
@@ -40,7 +40,7 @@ OPTION( USE_ICONV "Link with and use iconv library" OFF )
40
40
  OPTION( USE_SSH "Link with libssh to enable SSH support" ON )
41
41
  OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
42
42
  OPTION( VALGRIND "Configure build for valgrind" OFF )
43
- OPTION( CURL "User curl for HTTP if available" ON)
43
+ OPTION( CURL "Use curl for HTTP if available" ON)
44
44
  OPTION( DEBUG_POOL "Enable debug pool allocator" OFF )
45
45
 
46
46
  IF(DEBUG_POOL)
@@ -151,6 +151,10 @@ FUNCTION(TARGET_OS_LIBRARIES target)
151
151
  TARGET_LINK_LIBRARIES(${target} socket nsl)
152
152
  LIST(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
153
153
  SET(LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
154
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Haiku")
155
+ TARGET_LINK_LIBRARIES(${target} network)
156
+ LIST(APPEND LIBGIT2_PC_LIBS "-lnetwork")
157
+ SET(LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
154
158
  ENDIF()
155
159
  CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
156
160
  IF(NEED_LIBRT)
@@ -161,6 +165,8 @@ FUNCTION(TARGET_OS_LIBRARIES target)
161
165
 
162
166
  IF(THREADSAFE)
163
167
  TARGET_LINK_LIBRARIES(${target} ${CMAKE_THREAD_LIBS_INIT})
168
+ LIST(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
169
+ SET(LIBGIT2_PC_LIBS ${LIBGIT2_PC_LIBS} PARENT_SCOPE)
164
170
  ENDIF()
165
171
  ENDFUNCTION()
166
172
 
@@ -280,6 +286,7 @@ ELSE ()
280
286
  IF (CURL_FOUND)
281
287
  ADD_DEFINITIONS(-DGIT_CURL)
282
288
  INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
289
+ LINK_DIRECTORIES(${CURL_LIBRARY_DIRS})
283
290
  LINK_LIBRARIES(${CURL_LIBRARIES})
284
291
  LIST(APPEND LIBGIT2_PC_LIBS ${CURL_LDFLAGS})
285
292
  ENDIF()
@@ -412,7 +419,7 @@ IF (MSVC)
412
419
  # /MTd - Statically link the multithreaded debug version of the CRT
413
420
  # /MDd - Dynamically link the multithreaded debug version of the CRT
414
421
  # /RTC1 - Run time checks
415
- SET(CMAKE_C_FLAGS_DEBUG "/Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
422
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
416
423
 
417
424
  # /DNDEBUG - Disables asserts
418
425
  # /MT - Statically link the multithreaded release version of the CRT
@@ -464,22 +471,24 @@ ELSE ()
464
471
  ENDIF()
465
472
 
466
473
  IF (WIN32 AND NOT CYGWIN)
467
- SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG")
474
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
468
475
  ENDIF ()
469
476
 
470
- IF (MINGW) # MinGW always does PIC and complains if we tell it to
477
+ IF (MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to
471
478
  STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
472
- # MinGW >= 3.14 uses the C99-style stdio functions
473
- # automatically, but forks like mingw-w64 still want
474
- # us to define this in order to use them
475
- ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
476
-
477
479
  ELSEIF (BUILD_SHARED_LIBS)
478
480
  ADD_C_FLAG_IF_SUPPORTED(-fvisibility=hidden)
479
481
 
480
482
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
481
483
  ENDIF ()
482
484
 
485
+ IF (MINGW)
486
+ # MinGW >= 3.14 uses the C99-style stdio functions
487
+ # automatically, but forks like mingw-w64 still want
488
+ # us to define this in order to use them
489
+ ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
490
+ ENDIF ()
491
+
483
492
  ADD_C_FLAG_IF_SUPPORTED(-Wdocumentation)
484
493
  ADD_C_FLAG_IF_SUPPORTED(-Wno-missing-field-initializers)
485
494
  ADD_C_FLAG_IF_SUPPORTED(-Wstrict-aliasing=2)
@@ -608,6 +617,8 @@ IF (SONAME)
608
617
  IF (LIBGIT2_FILENAME)
609
618
  ADD_DEFINITIONS(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
610
619
  SET_TARGET_PROPERTIES(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
620
+ ELSEIF (DEFINED LIBGIT2_PREFIX)
621
+ SET_TARGET_PROPERTIES(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
611
622
  ENDIF()
612
623
  ENDIF()
613
624
  STRING(REPLACE ";" " " LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS}")
@@ -99,7 +99,7 @@ do { \
99
99
  FOR##_mark = NULL; \
100
100
  } \
101
101
  } while (0)
102
-
102
+
103
103
  /* Run the data callback FOR and consume the current byte */
104
104
  #define CALLBACK_DATA(FOR) \
105
105
  CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1)
@@ -444,6 +444,9 @@ parse_url_char(enum state s, const char ch)
444
444
  return s_req_path;
445
445
  }
446
446
 
447
+ /* The schema must start with an alpha character. After that, it may
448
+ * consist of digits, '+', '-' or '.', followed by a ':'.
449
+ */
447
450
  if (IS_ALPHA(ch)) {
448
451
  return s_req_schema;
449
452
  }
@@ -451,7 +454,7 @@ parse_url_char(enum state s, const char ch)
451
454
  break;
452
455
 
453
456
  case s_req_schema:
454
- if (IS_ALPHA(ch)) {
457
+ if (IS_ALPHANUM(ch) || ch == '+' || ch == '-' || ch == '.') {
455
458
  return s;
456
459
  }
457
460
 
@@ -313,6 +313,13 @@ GIT_EXTERN(int) git_checkout_init_options(
313
313
  * Updates files in the index and the working tree to match the content of
314
314
  * the commit pointed at by HEAD.
315
315
  *
316
+ * Note that this is _not_ the correct mechanism used to switch branches;
317
+ * do not change your `HEAD` and then call this method, that would leave
318
+ * you with checkout conflicts since your working directory would then
319
+ * appear to be dirty. Instead, checkout the target of the branch and
320
+ * then update `HEAD` using `git_repository_set_head` to point to the
321
+ * branch you checked out.
322
+ *
316
323
  * @param repo repository to check out (must be non-bare)
317
324
  * @param opts specifies checkout options (may be NULL)
318
325
  * @return 0 on success, GIT_EUNBORNBRANCH if HEAD points to a non
@@ -24,10 +24,19 @@
24
24
  GIT_BEGIN_DECL
25
25
  # include "inttypes.h"
26
26
  GIT_END_DECL
27
- #else
27
+ /** This check is needed for importing this file in an iOS/OS X framework throws an error in Xcode otherwise.*/
28
+ #elif !defined(__CLANG_INTTYPES_H)
28
29
  # include <inttypes.h>
29
30
  #endif
30
31
 
32
+ #ifdef DOCURIUM
33
+ /*
34
+ * This is so clang's doc parser acknowledges comments on functions
35
+ * with size_t parameters.
36
+ */
37
+ typedef size_t size_t;
38
+ #endif
39
+
31
40
  /** Declare a public function exported for application use. */
32
41
  #if __GNUC__ >= 4
33
42
  # define GIT_EXTERN(type) extern \
@@ -148,6 +157,7 @@ typedef enum {
148
157
  GIT_OPT_SET_SSL_CERT_LOCATIONS,
149
158
  GIT_OPT_SET_USER_AGENT,
150
159
  GIT_OPT_ENABLE_STRICT_OBJECT_CREATION,
160
+ GIT_OPT_SET_SSL_CIPHERS,
151
161
  } git_libgit2_opt_t;
152
162
 
153
163
  /**
@@ -259,6 +269,11 @@ typedef enum {
259
269
  * > example, when this is enabled, the parent(s) and tree inputs
260
270
  * > will be validated when creating a new commit. This defaults
261
271
  * > to disabled.
272
+ * * opts(GIT_OPT_SET_SSL_CIPHERS, const char *ciphers)
273
+ *
274
+ * > Set the SSL ciphers use for HTTPS connections.
275
+ * >
276
+ * > - `ciphers` is the list of ciphers that are eanbled.
262
277
  *
263
278
  * @param option Option key
264
279
  * @param ... value to set the option
@@ -7,10 +7,10 @@
7
7
  #ifndef INCLUDE_git_version_h__
8
8
  #define INCLUDE_git_version_h__
9
9
 
10
- #define LIBGIT2_VERSION "0.24.0"
10
+ #define LIBGIT2_VERSION "0.24.5"
11
11
  #define LIBGIT2_VER_MAJOR 0
12
12
  #define LIBGIT2_VER_MINOR 24
13
- #define LIBGIT2_VER_REVISION 0
13
+ #define LIBGIT2_VER_REVISION 5
14
14
  #define LIBGIT2_VER_PATCH 0
15
15
 
16
16
  #define LIBGIT2_SOVERSION 24
@@ -82,4 +82,44 @@ on_oom:
82
82
 
83
83
  #define git_array_valid_index(a, i) ((i) < (a).size)
84
84
 
85
+ #define git_array_foreach(a, i, element) \
86
+ for ((i) = 0; (i) < (a).size && ((element) = &(a).ptr[(i)]); (i)++)
87
+
88
+
89
+ GIT_INLINE(int) git_array__search(
90
+ size_t *out,
91
+ void *array_ptr,
92
+ size_t item_size,
93
+ size_t array_len,
94
+ int (*compare)(const void *, const void *),
95
+ const void *key)
96
+ {
97
+ size_t lim;
98
+ unsigned char *part, *array = array_ptr, *base = array_ptr;
99
+ int cmp = -1;
100
+
101
+ for (lim = array_len; lim != 0; lim >>= 1) {
102
+ part = base + (lim >> 1) * item_size;
103
+ cmp = (*compare)(key, part);
104
+
105
+ if (cmp == 0) {
106
+ base = part;
107
+ break;
108
+ }
109
+ if (cmp > 0) { /* key > p; take right partition */
110
+ base = part + 1 * item_size;
111
+ lim--;
112
+ } /* else take left partition */
113
+ }
114
+
115
+ if (out)
116
+ *out = (base - array) / item_size;
117
+
118
+ return (cmp == 0) ? 0 : GIT_ENOTFOUND;
119
+ }
120
+
121
+ #define git_array_search(out, a, cmp, key) \
122
+ git_array__search(out, (a).ptr, sizeof(*(a).ptr), (a).size, \
123
+ (cmp), (key))
124
+
85
125
  #endif
@@ -178,7 +178,7 @@ const git_blame_hunk *git_blame_get_hunk_byline(git_blame *blame, size_t lineno)
178
178
  return NULL;
179
179
  }
180
180
 
181
- static void normalize_options(
181
+ static int normalize_options(
182
182
  git_blame_options *out,
183
183
  const git_blame_options *in,
184
184
  git_repository *repo)
@@ -190,7 +190,9 @@ static void normalize_options(
190
190
 
191
191
  /* No newest_commit => HEAD */
192
192
  if (git_oid_iszero(&out->newest_commit)) {
193
- git_reference_name_to_id(&out->newest_commit, repo, "HEAD");
193
+ if (git_reference_name_to_id(&out->newest_commit, repo, "HEAD") < 0) {
194
+ return -1;
195
+ }
194
196
  }
195
197
 
196
198
  /* min_line 0 really means 1 */
@@ -204,6 +206,8 @@ static void normalize_options(
204
206
  out->flags |= GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES;
205
207
  if (out->flags & GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES)
206
208
  out->flags |= GIT_BLAME_TRACK_COPIES_SAME_FILE;
209
+
210
+ return 0;
207
211
  }
208
212
 
209
213
  static git_blame_hunk *split_hunk_in_vector(
@@ -362,7 +366,8 @@ int git_blame_file(
362
366
  git_blame *blame = NULL;
363
367
 
364
368
  assert(out && repo && path);
365
- normalize_options(&normOptions, options, repo);
369
+ if ((error = normalize_options(&normOptions, options, repo)) < 0)
370
+ goto on_error;
366
371
 
367
372
  blame = git_blame__alloc(repo, normOptions, path);
368
373
  GITERR_CHECK_ALLOC(blame);
@@ -37,25 +37,27 @@ static void origin_decref(git_blame__origin *o)
37
37
  static int make_origin(git_blame__origin **out, git_commit *commit, const char *path)
38
38
  {
39
39
  git_blame__origin *o;
40
+ git_object *blob;
40
41
  size_t path_len = strlen(path), alloc_len;
41
42
  int error = 0;
42
43
 
44
+ if ((error = git_object_lookup_bypath(&blob, (git_object*)commit,
45
+ path, GIT_OBJ_BLOB)) < 0)
46
+ return error;
47
+
43
48
  GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(*o), path_len);
44
49
  GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1);
45
50
  o = git__calloc(1, alloc_len);
46
51
  GITERR_CHECK_ALLOC(o);
47
52
 
48
53
  o->commit = commit;
54
+ o->blob = (git_blob *) blob;
49
55
  o->refcnt = 1;
50
56
  strcpy(o->path, path);
51
57
 
52
- if (!(error = git_object_lookup_bypath((git_object**)&o->blob, (git_object*)commit,
53
- path, GIT_OBJ_BLOB))) {
54
- *out = o;
55
- } else {
56
- origin_decref(o);
57
- }
58
- return error;
58
+ *out = o;
59
+
60
+ return 0;
59
61
  }
60
62
 
61
63
  /* Locate an existing origin or create a new one. */
@@ -525,11 +527,20 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
525
527
  if (sg_origin[i])
526
528
  continue;
527
529
 
528
- git_commit_parent(&p, origin->commit, i);
530
+ if ((error = git_commit_parent(&p, origin->commit, i)) < 0)
531
+ goto finish;
529
532
  porigin = find_origin(blame, p, origin);
530
533
 
531
- if (!porigin)
534
+ if (!porigin) {
535
+ /*
536
+ * We only have to decrement the parent's
537
+ * reference count when no porigin has
538
+ * been created, as otherwise the commit
539
+ * is assigned to the created object.
540
+ */
541
+ git_commit_free(p);
532
542
  continue;
543
+ }
533
544
  if (porigin->blob && origin->blob &&
534
545
  !git_oid_cmp(git_blob_id(porigin->blob), git_blob_id(origin->blob))) {
535
546
  pass_whole_blame(blame, origin, porigin);
@@ -464,7 +464,8 @@ static int checkout_action_with_wd(
464
464
  *action = CHECKOUT_ACTION_IF(SAFE, REMOVE, NONE);
465
465
  break;
466
466
  case GIT_DELTA_MODIFIED: /* case 16, 17, 18 (or 36 but not really) */
467
- if (checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
467
+ if (wd->mode != GIT_FILEMODE_COMMIT &&
468
+ checkout_is_workdir_modified(data, &delta->old_file, &delta->new_file, wd))
468
469
  *action = CHECKOUT_ACTION_IF(FORCE, UPDATE_BLOB, CONFLICT);
469
470
  else
470
471
  *action = CHECKOUT_ACTION_IF(SAFE, UPDATE_BLOB, NONE);
@@ -1342,9 +1343,11 @@ fail:
1342
1343
 
1343
1344
  static bool should_remove_existing(checkout_data *data)
1344
1345
  {
1345
- int ignorecase = 0;
1346
+ int ignorecase;
1346
1347
 
1347
- git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE);
1348
+ if (git_repository__cvar(&ignorecase, data->repo, GIT_CVAR_IGNORECASE) < 0) {
1349
+ ignorecase = 0;
1350
+ }
1348
1351
 
1349
1352
  return (ignorecase &&
1350
1353
  (data->strategy & GIT_CHECKOUT_DONT_REMOVE_EXISTING) == 0);
@@ -2405,8 +2408,13 @@ static int checkout_data_init(
2405
2408
 
2406
2409
  if (!data->opts.baseline && !data->opts.baseline_index) {
2407
2410
  data->opts_free_baseline = true;
2411
+ error = 0;
2408
2412
 
2409
- error = checkout_lookup_head_tree(&data->opts.baseline, repo);
2413
+ /* if we don't have an index, this is an initial checkout and
2414
+ * should be against an empty baseline
2415
+ */
2416
+ if (data->index->on_disk)
2417
+ error = checkout_lookup_head_tree(&data->opts.baseline, repo);
2410
2418
 
2411
2419
  if (error == GIT_EUNBORNBRANCH) {
2412
2420
  error = 0;
@@ -2691,7 +2699,7 @@ int git_checkout_tree(
2691
2699
  if ((error = git_repository_index(&index, repo)) < 0)
2692
2700
  return error;
2693
2701
 
2694
- if ((opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2702
+ if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
2695
2703
  iter_opts.pathlist.count = opts->paths.count;
2696
2704
  iter_opts.pathlist.strings = opts->paths.strings;
2697
2705
  }
@@ -410,10 +410,11 @@ int git_commit__parse(void *_commit, git_odb_object *odb_obj)
410
410
  buffer = buffer_start + header_len + 1;
411
411
 
412
412
  /* extract commit message */
413
- if (buffer <= buffer_end) {
413
+ if (buffer <= buffer_end)
414
414
  commit->raw_message = git__strndup(buffer, buffer_end - buffer);
415
- GITERR_CHECK_ALLOC(commit->raw_message);
416
- }
415
+ else
416
+ commit->raw_message = git__strdup("");
417
+ GITERR_CHECK_ALLOC(commit->raw_message);
417
418
 
418
419
  return 0;
419
420
 
@@ -676,7 +677,7 @@ int git_commit_extract_signature(git_buf *signature, git_buf *signed_data, git_r
676
677
 
677
678
  buf = git_odb_object_data(obj);
678
679
 
679
- while ((h = strchr(buf, '\n')) && h[1] != '\0' && h[1] != '\n') {
680
+ while ((h = strchr(buf, '\n')) && h[1] != '\0') {
680
681
  h++;
681
682
  if (git__prefixcmp(buf, field)) {
682
683
  if (git_buf_put(signed_data, buf, h - buf) < 0)
@@ -45,7 +45,7 @@
45
45
  # include "win32/error.h"
46
46
  # include "win32/version.h"
47
47
  # ifdef GIT_THREADS
48
- # include "win32/pthread.h"
48
+ # include "win32/thread.h"
49
49
  # endif
50
50
  # if defined(GIT_MSVC_CRTDBG)
51
51
  # include "win32/w32_stack.h"
@@ -86,7 +86,8 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar)
86
86
  struct map_data *data = &_cvar_maps[(int)cvar];
87
87
  git_config_entry *entry;
88
88
 
89
- git_config__lookup_entry(&entry, config, data->cvar_name, false);
89
+ if ((error = git_config__lookup_entry(&entry, config, data->cvar_name, false)) < 0)
90
+ return error;
90
91
 
91
92
  if (!entry)
92
93
  *out = data->default_value;
@@ -553,30 +553,15 @@ static int config_set_multivar(
553
553
  git_config_backend *cfg, const char *name, const char *regexp, const char *value)
554
554
  {
555
555
  diskfile_backend *b = (diskfile_backend *)cfg;
556
- refcounted_strmap *map;
557
- git_strmap *values;
558
556
  char *key;
559
557
  regex_t preg;
560
558
  int result;
561
- khiter_t pos;
562
559
 
563
560
  assert(regexp);
564
561
 
565
562
  if ((result = git_config__normalize_name(name, &key)) < 0)
566
563
  return result;
567
564
 
568
- map = refcounted_strmap_take(&b->header);
569
- values = b->header.values->values;
570
-
571
- pos = git_strmap_lookup_index(values, key);
572
- if (!git_strmap_valid_index(values, pos)) {
573
- /* If we don't have it, behave like a normal set */
574
- result = config_set(cfg, name, value);
575
- refcounted_strmap_free(map);
576
- git__free(key);
577
- return result;
578
- }
579
-
580
565
  result = regcomp(&preg, regexp, REG_EXTENDED);
581
566
  if (result != 0) {
582
567
  giterr_set_regex(&preg, result);
@@ -591,7 +576,6 @@ static int config_set_multivar(
591
576
  result = config_refresh(cfg);
592
577
 
593
578
  out:
594
- refcounted_strmap_free(map);
595
579
  git__free(key);
596
580
  regfree(&preg);
597
581
 
@@ -1032,6 +1016,11 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
1032
1016
  */
1033
1017
 
1034
1018
  first_quote = strchr(line, '"');
1019
+ if (first_quote == NULL) {
1020
+ set_parse_error(reader, 0, "Missing quotation marks in section header");
1021
+ return -1;
1022
+ }
1023
+
1035
1024
  last_quote = strrchr(line, '"');
1036
1025
  quoted_len = last_quote - first_quote;
1037
1026
 
@@ -1483,7 +1472,7 @@ static int config_parse(
1483
1472
  int (*on_section)(struct reader **reader, const char *current_section, const char *line, size_t line_len, void *data),
1484
1473
  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),
1485
1474
  int (*on_comment)(struct reader **reader, const char *line, size_t line_len, void *data),
1486
- int (*on_eof)(struct reader **reader, void *data),
1475
+ int (*on_eof)(struct reader **reader, const char *current_section, void *data),
1487
1476
  void *data)
1488
1477
  {
1489
1478
  char *current_section = NULL, *var_name, *var_value, *line_start;
@@ -1534,7 +1523,7 @@ static int config_parse(
1534
1523
  }
1535
1524
 
1536
1525
  if (on_eof)
1537
- result = on_eof(&reader, data);
1526
+ result = on_eof(&reader, current_section, data);
1538
1527
 
1539
1528
  git__free(current_section);
1540
1529
  return result;
@@ -1850,7 +1839,8 @@ static int write_on_comment(struct reader **reader, const char *line, size_t lin
1850
1839
  return write_line_to(&write_data->buffered_comment, line, line_len);
1851
1840
  }
1852
1841
 
1853
- static int write_on_eof(struct reader **reader, void *data)
1842
+ static int write_on_eof(
1843
+ struct reader **reader, const char *current_section, void *data)
1854
1844
  {
1855
1845
  struct write_data *write_data = (struct write_data *)data;
1856
1846
  int result = 0;
@@ -1869,7 +1859,11 @@ static int write_on_eof(struct reader **reader, void *data)
1869
1859
  * value.
1870
1860
  */
1871
1861
  if ((!write_data->preg || !write_data->preg_replaced) && write_data->value) {
1872
- if ((result = write_section(write_data->buf, write_data->section)) == 0)
1862
+ /* write the section header unless we're already in it */
1863
+ if (!current_section || strcmp(current_section, write_data->section))
1864
+ result = write_section(write_data->buf, write_data->section);
1865
+
1866
+ if (!result)
1873
1867
  result = write_value(write_data);
1874
1868
  }
1875
1869