rugged 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_commit.c +1 -1
  3. data/lib/rugged/commit.rb +16 -2
  4. data/lib/rugged/version.rb +1 -1
  5. data/vendor/libgit2/CMakeLists.txt +31 -69
  6. data/vendor/libgit2/cmake/{Modules/AddCFlagIfSupported.cmake → AddCFlagIfSupported.cmake} +0 -0
  7. data/vendor/libgit2/cmake/{Modules/EnableWarnings.cmake → EnableWarnings.cmake} +0 -0
  8. data/vendor/libgit2/cmake/{Modules/FindCoreFoundation.cmake → FindCoreFoundation.cmake} +0 -0
  9. data/vendor/libgit2/cmake/{Modules/FindGSSAPI.cmake → FindGSSAPI.cmake} +0 -0
  10. data/vendor/libgit2/cmake/{Modules/FindGSSFramework.cmake → FindGSSFramework.cmake} +0 -0
  11. data/vendor/libgit2/cmake/{Modules/FindHTTP_Parser.cmake → FindHTTP_Parser.cmake} +0 -0
  12. data/vendor/libgit2/cmake/{Modules/FindIconv.cmake → FindIconv.cmake} +0 -0
  13. data/vendor/libgit2/cmake/{Modules/FindPCRE.cmake → FindPCRE.cmake} +0 -0
  14. data/vendor/libgit2/cmake/{Modules/FindPCRE2.cmake → FindPCRE2.cmake} +0 -0
  15. data/vendor/libgit2/cmake/{Modules/FindPkgLibraries.cmake → FindPkgLibraries.cmake} +0 -0
  16. data/vendor/libgit2/cmake/{Modules/FindSecurity.cmake → FindSecurity.cmake} +0 -0
  17. data/vendor/libgit2/cmake/{Modules/FindStatNsec.cmake → FindStatNsec.cmake} +0 -0
  18. data/vendor/libgit2/cmake/{Modules/FindmbedTLS.cmake → FindmbedTLS.cmake} +0 -0
  19. data/vendor/libgit2/cmake/{Modules/IdeSplitSources.cmake → IdeSplitSources.cmake} +0 -0
  20. data/vendor/libgit2/cmake/{Modules/PkgBuildConfig.cmake → PkgBuildConfig.cmake} +0 -0
  21. data/vendor/libgit2/cmake/{Modules/SanitizeBool.cmake → SanitizeBool.cmake} +0 -0
  22. data/vendor/libgit2/cmake/{Modules/SelectGSSAPI.cmake → SelectGSSAPI.cmake} +18 -26
  23. data/vendor/libgit2/cmake/{Modules/SelectHTTPSBackend.cmake → SelectHTTPSBackend.cmake} +25 -32
  24. data/vendor/libgit2/cmake/{Modules/SelectHashes.cmake → SelectHashes.cmake} +20 -28
  25. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +4 -3
  26. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +6 -5
  27. data/vendor/libgit2/deps/ntlmclient/compat.h +8 -1
  28. data/vendor/libgit2/deps/ntlmclient/ntlm.c +8 -11
  29. data/vendor/libgit2/deps/pcre/LICENCE +93 -0
  30. data/vendor/libgit2/deps/pcre/pcre.h +2 -2
  31. data/vendor/libgit2/deps/pcre/pcre_compile.c +29 -17
  32. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +4 -4
  33. data/vendor/libgit2/deps/pcre/pcreposix.c +2 -3
  34. data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -5
  35. data/vendor/libgit2/deps/zlib/deflate.c +1 -0
  36. data/vendor/libgit2/include/git2/annotated_commit.h +1 -1
  37. data/vendor/libgit2/include/git2/blame.h +2 -0
  38. data/vendor/libgit2/include/git2/common.h +15 -3
  39. data/vendor/libgit2/include/git2/deprecated.h +42 -2
  40. data/vendor/libgit2/include/git2/errors.h +2 -1
  41. data/vendor/libgit2/include/git2/index.h +1 -2
  42. data/vendor/libgit2/include/git2/pack.h +1 -1
  43. data/vendor/libgit2/include/git2/strarray.h +6 -10
  44. data/vendor/libgit2/include/git2/version.h +4 -4
  45. data/vendor/libgit2/src/CMakeLists.txt +53 -41
  46. data/vendor/libgit2/src/apply.c +5 -1
  47. data/vendor/libgit2/src/assert_safe.h +58 -0
  48. data/vendor/libgit2/src/attr_file.c +8 -3
  49. data/vendor/libgit2/src/attrcache.c +2 -3
  50. data/vendor/libgit2/src/blame.c +2 -0
  51. data/vendor/libgit2/src/blame_git.c +6 -3
  52. data/vendor/libgit2/src/blob.c +2 -0
  53. data/vendor/libgit2/src/branch.c +19 -21
  54. data/vendor/libgit2/src/buffer.c +6 -3
  55. data/vendor/libgit2/src/cache.c +1 -22
  56. data/vendor/libgit2/src/checkout.c +49 -72
  57. data/vendor/libgit2/src/cherrypick.c +2 -0
  58. data/vendor/libgit2/src/clone.c +78 -18
  59. data/vendor/libgit2/src/common.h +1 -0
  60. data/vendor/libgit2/src/config.c +3 -7
  61. data/vendor/libgit2/src/config_entries.c +35 -27
  62. data/vendor/libgit2/src/config_parse.c +1 -1
  63. data/vendor/libgit2/src/config_snapshot.c +2 -1
  64. data/vendor/libgit2/src/describe.c +5 -1
  65. data/vendor/libgit2/src/diff.c +12 -11
  66. data/vendor/libgit2/src/diff_file.c +3 -1
  67. data/vendor/libgit2/src/diff_generate.c +10 -11
  68. data/vendor/libgit2/src/diff_parse.c +2 -3
  69. data/vendor/libgit2/src/diff_print.c +63 -60
  70. data/vendor/libgit2/src/diff_stats.c +12 -11
  71. data/vendor/libgit2/src/diff_tform.c +2 -3
  72. data/vendor/libgit2/src/errors.c +2 -0
  73. data/vendor/libgit2/src/fetch.c +2 -0
  74. data/vendor/libgit2/src/filter.c +3 -3
  75. data/vendor/libgit2/src/futils.c +3 -3
  76. data/vendor/libgit2/src/futils.h +3 -3
  77. data/vendor/libgit2/src/global.c +3 -1
  78. data/vendor/libgit2/src/idxmap.c +0 -22
  79. data/vendor/libgit2/src/index.c +12 -7
  80. data/vendor/libgit2/src/indexer.c +10 -4
  81. data/vendor/libgit2/src/iterator.c +4 -4
  82. data/vendor/libgit2/src/merge.c +13 -7
  83. data/vendor/libgit2/src/merge_file.c +4 -6
  84. data/vendor/libgit2/src/midx.c +418 -0
  85. data/vendor/libgit2/src/midx.h +83 -0
  86. data/vendor/libgit2/src/mwindow.c +124 -51
  87. data/vendor/libgit2/src/net.c +6 -1
  88. data/vendor/libgit2/src/object.c +2 -1
  89. data/vendor/libgit2/src/odb.c +9 -6
  90. data/vendor/libgit2/src/odb_loose.c +3 -3
  91. data/vendor/libgit2/src/odb_mempack.c +2 -0
  92. data/vendor/libgit2/src/oid.c +2 -0
  93. data/vendor/libgit2/src/pack-objects.c +29 -21
  94. data/vendor/libgit2/src/pack.c +47 -28
  95. data/vendor/libgit2/src/pack.h +19 -2
  96. data/vendor/libgit2/src/patch_generate.c +1 -3
  97. data/vendor/libgit2/src/patch_parse.c +4 -2
  98. data/vendor/libgit2/src/path.c +4 -4
  99. data/vendor/libgit2/src/pathspec.c +4 -3
  100. data/vendor/libgit2/src/pool.c +21 -15
  101. data/vendor/libgit2/src/pool.h +9 -1
  102. data/vendor/libgit2/src/proxy.c +2 -0
  103. data/vendor/libgit2/src/push.c +2 -0
  104. data/vendor/libgit2/src/rebase.c +2 -0
  105. data/vendor/libgit2/src/refdb.c +135 -0
  106. data/vendor/libgit2/src/refdb.h +69 -0
  107. data/vendor/libgit2/src/refdb_fs.c +19 -81
  108. data/vendor/libgit2/src/reflog.c +2 -6
  109. data/vendor/libgit2/src/refs.c +60 -188
  110. data/vendor/libgit2/src/refs.h +1 -19
  111. data/vendor/libgit2/src/regexp.c +2 -2
  112. data/vendor/libgit2/src/remote.c +32 -17
  113. data/vendor/libgit2/src/repository.c +168 -79
  114. data/vendor/libgit2/src/repository.h +10 -27
  115. data/vendor/libgit2/src/revert.c +2 -0
  116. data/vendor/libgit2/src/revparse.c +5 -4
  117. data/vendor/libgit2/src/revwalk.c +3 -5
  118. data/vendor/libgit2/src/settings.c +9 -0
  119. data/vendor/libgit2/src/sortedcache.c +2 -3
  120. data/vendor/libgit2/src/stash.c +2 -0
  121. data/vendor/libgit2/src/status.c +2 -0
  122. data/vendor/libgit2/src/strarray.c +63 -0
  123. data/vendor/libgit2/src/streams/openssl.c +12 -6
  124. data/vendor/libgit2/src/streams/registry.c +5 -3
  125. data/vendor/libgit2/src/submodule.c +6 -4
  126. data/vendor/libgit2/src/sysdir.c +4 -20
  127. data/vendor/libgit2/src/sysdir.h +0 -11
  128. data/vendor/libgit2/src/tag.c +2 -0
  129. data/vendor/libgit2/src/thread-utils.h +139 -21
  130. data/vendor/libgit2/src/transaction.c +2 -1
  131. data/vendor/libgit2/src/transports/credential.c +2 -0
  132. data/vendor/libgit2/src/transports/credential_helpers.c +2 -0
  133. data/vendor/libgit2/src/transports/httpclient.c +6 -8
  134. data/vendor/libgit2/src/transports/local.c +2 -2
  135. data/vendor/libgit2/src/transports/smart.c +2 -2
  136. data/vendor/libgit2/src/transports/winhttp.c +18 -7
  137. data/vendor/libgit2/src/unix/posix.h +13 -1
  138. data/vendor/libgit2/src/util.c +25 -58
  139. data/vendor/libgit2/src/util.h +2 -2
  140. data/vendor/libgit2/src/win32/git2.rc +18 -3
  141. data/vendor/libgit2/src/win32/path_w32.c +2 -2
  142. data/vendor/libgit2/src/worktree.c +4 -0
  143. metadata +27 -25
  144. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +0 -29
  145. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +0 -96
  146. data/vendor/libgit2/src/refdb_fs.h +0 -19
@@ -47,6 +47,8 @@ typedef enum {
47
47
  * to canonical real names and email addresses. The mailmap will be read
48
48
  * from the working directory, or HEAD in a bare repository. */
49
49
  GIT_BLAME_USE_MAILMAP = (1<<5),
50
+ /** Ignore whitespace differences */
51
+ GIT_BLAME_IGNORE_WHITESPACE = (1<<6),
50
52
  } git_blame_flag_t;
51
53
 
52
54
  /**
@@ -205,7 +205,9 @@ typedef enum {
205
205
  GIT_OPT_GET_PACK_MAX_OBJECTS,
206
206
  GIT_OPT_SET_PACK_MAX_OBJECTS,
207
207
  GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS,
208
- GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE
208
+ GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE,
209
+ GIT_OPT_GET_MWINDOW_FILE_LIMIT,
210
+ GIT_OPT_SET_MWINDOW_FILE_LIMIT
209
211
  } git_libgit2_opt_t;
210
212
 
211
213
  /**
@@ -227,8 +229,18 @@ typedef enum {
227
229
  *
228
230
  * * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
229
231
  *
230
- * >Set the maximum amount of memory that can be mapped at any time
231
- * by the library
232
+ * > Set the maximum amount of memory that can be mapped at any time
233
+ * > by the library
234
+ *
235
+ * * opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, size_t *):
236
+ *
237
+ * > Get the maximum number of files that will be mapped at any time by the
238
+ * > library
239
+ *
240
+ * * opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, size_t):
241
+ *
242
+ * > Set the maximum number of files that can be mapped at any time
243
+ * > by the library. The default (0) is unlimited.
232
244
  *
233
245
  * * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
234
246
  *
@@ -102,7 +102,11 @@ GIT_EXTERN(int) git_blob_create_fromstream_commit(
102
102
  GIT_EXTERN(int) git_blob_create_frombuffer(
103
103
  git_oid *id, git_repository *repo, const void *buffer, size_t len);
104
104
 
105
- /** Deprecated in favor of @see git_blob_filter */
105
+ /** Deprecated in favor of `git_blob_filter`.
106
+ *
107
+ * @deprecated Use git_blob_filter
108
+ * @see git_blob_filter
109
+ */
106
110
  GIT_EXTERN(int) git_blob_filtered_content(
107
111
  git_buf *out,
108
112
  git_blob *blob,
@@ -233,7 +237,7 @@ GIT_EXTERN(void) giterr_clear(void);
233
237
  GIT_EXTERN(void) giterr_set_str(int error_class, const char *string);
234
238
 
235
239
  /**
236
- * Indicates that an out-of-memory situation occured. This is an alias
240
+ * Indicates that an out-of-memory situation occurred. This is an alias
237
241
  * of `git_error_set_oom` and is preserved for backward compatibility.
238
242
  *
239
243
  * This function is deprecated, but there is no plan to remove this
@@ -524,6 +528,42 @@ typedef int GIT_CALLBACK(git_headlist_cb)(git_remote_head *rhead, void *payload)
524
528
 
525
529
  /**@}*/
526
530
 
531
+ /** @name Deprecated String Array Functions
532
+ *
533
+ * These types are retained for backward compatibility. The newer
534
+ * versions of these values should be preferred in all new code.
535
+ *
536
+ * There is no plan to remove these backward compatibility values at
537
+ * this time.
538
+ */
539
+ /**@{*/
540
+
541
+ /**
542
+ * Copy a string array object from source to target.
543
+ *
544
+ * This function is deprecated, but there is no plan to remove this
545
+ * function at this time.
546
+ *
547
+ * @param tgt target
548
+ * @param src source
549
+ * @return 0 on success, < 0 on allocation failure
550
+ */
551
+ GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
552
+
553
+ /**
554
+ * Free the memory referred to by the git_strarray. This is an alias of
555
+ * `git_strarray_dispose` and is preserved for backward compatibility.
556
+ *
557
+ * This function is deprecated, but there is no plan to remove this
558
+ * function at this time.
559
+ *
560
+ * @deprecated Use git_strarray_dispose
561
+ * @see git_strarray_dispose
562
+ */
563
+ GIT_EXTERN(void) git_strarray_free(git_strarray *array);
564
+
565
+ /**@}*/
566
+
527
567
  /** @name Deprecated Options Initialization Functions
528
568
  *
529
569
  * These functions are retained for backward compatibility. The newer
@@ -107,7 +107,8 @@ typedef enum {
107
107
  GIT_ERROR_PATCH,
108
108
  GIT_ERROR_WORKTREE,
109
109
  GIT_ERROR_SHA1,
110
- GIT_ERROR_HTTP
110
+ GIT_ERROR_HTTP,
111
+ GIT_ERROR_INTERNAL
111
112
  } git_error_t;
112
113
 
113
114
  /**
@@ -555,8 +555,7 @@ GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path);
555
555
  *
556
556
  * If a previous index entry exists that has the same path as the
557
557
  * given 'entry', it will be replaced. Otherwise, the 'entry' will be
558
- * added. The `id` and the `file_size` of the 'entry' are updated with the
559
- * real value of the blob.
558
+ * added.
560
559
  *
561
560
  * This forces the file to be added to the index, not looking
562
561
  * at gitignore rules. Those rules can be evaluated through
@@ -155,7 +155,7 @@ GIT_EXTERN(int) git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb);
155
155
  * Write the new pack and corresponding index file to path.
156
156
  *
157
157
  * @param pb The packbuilder
158
- * @param path to the directory where the packfile and index should be stored
158
+ * @param path Path to the directory where the packfile and index should be stored, or NULL for default location
159
159
  * @param mode permissions to use creating a packfile or 0 for defaults
160
160
  * @param progress_cb function to call with progress information from the indexer (optional)
161
161
  * @param progress_cb_payload payload for the progress callback (optional)
@@ -25,20 +25,16 @@ typedef struct git_strarray {
25
25
  } git_strarray;
26
26
 
27
27
  /**
28
- * Close a string array object
29
- *
30
- * This method should be called on `git_strarray` objects where the strings
31
- * array is allocated and contains allocated strings, such as what you
32
- * would get from `git_strarray_copy()`. Not doing so, will result in a
33
- * memory leak.
28
+ * Free the strings contained in a string array. This method should
29
+ * be called on `git_strarray` objects that were provided by the
30
+ * library. Not doing so, will result in a memory leak.
34
31
  *
35
32
  * This does not free the `git_strarray` itself, since the library will
36
- * never allocate that object directly itself (it is more commonly embedded
37
- * inside another struct or created on the stack).
33
+ * never allocate that object directly itself.
38
34
  *
39
- * @param array git_strarray from which to free string data
35
+ * @param array The git_strarray that contains strings to free
40
36
  */
41
- GIT_EXTERN(void) git_strarray_free(git_strarray *array);
37
+ GIT_EXTERN(void) git_strarray_dispose(git_strarray *array);
42
38
 
43
39
  /**
44
40
  * Copy a string array object from source to target.
@@ -7,12 +7,12 @@
7
7
  #ifndef INCLUDE_git_version_h__
8
8
  #define INCLUDE_git_version_h__
9
9
 
10
- #define LIBGIT2_VERSION "1.0.1"
10
+ #define LIBGIT2_VERSION "1.1.0"
11
11
  #define LIBGIT2_VER_MAJOR 1
12
- #define LIBGIT2_VER_MINOR 0
13
- #define LIBGIT2_VER_REVISION 1
12
+ #define LIBGIT2_VER_MINOR 1
13
+ #define LIBGIT2_VER_REVISION 0
14
14
  #define LIBGIT2_VER_PATCH 0
15
15
 
16
- #define LIBGIT2_SOVERSION "1.0"
16
+ #define LIBGIT2_SOVERSION "1.1"
17
17
 
18
18
  #endif
@@ -1,3 +1,6 @@
1
+ add_library(git2internal OBJECT)
2
+ set_target_properties(git2internal PROPERTIES C_STANDARD 90)
3
+
1
4
  IF(DEBUG_POOL)
2
5
  SET(GIT_DEBUG_POOL 1)
3
6
  ENDIF()
@@ -21,6 +24,8 @@ SET(LIBGIT2_INCLUDES
21
24
  SET(LIBGIT2_SYSTEM_INCLUDES "")
22
25
  SET(LIBGIT2_LIBS "")
23
26
 
27
+ enable_warnings(missing-declarations)
28
+
24
29
  # Enable tracing
25
30
  IF(ENABLE_TRACE)
26
31
  SET(GIT_TRACE 1)
@@ -36,19 +41,19 @@ CHECK_PROTOTYPE_DEFINITION(qsort_r
36
41
  "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))"
37
42
  "" "stdlib.h" HAVE_QSORT_R_BSD)
38
43
  IF (HAVE_QSORT_R_BSD)
39
- ADD_DEFINITIONS(-DHAVE_QSORT_R_BSD)
44
+ target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD)
40
45
  ENDIF()
41
46
 
42
47
  CHECK_PROTOTYPE_DEFINITION(qsort_r
43
48
  "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)"
44
49
  "" "stdlib.h" HAVE_QSORT_R_GNU)
45
50
  IF (HAVE_QSORT_R_GNU)
46
- ADD_DEFINITIONS(-DHAVE_QSORT_R_GNU)
51
+ target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU)
47
52
  ENDIF()
48
53
 
49
54
  CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S)
50
55
  IF (HAVE_QSORT_S)
51
- ADD_DEFINITIONS(-DHAVE_QSORT_S)
56
+ target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S)
52
57
  ENDIF ()
53
58
 
54
59
  # Find required dependencies
@@ -76,12 +81,15 @@ ENDIF()
76
81
  ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
77
82
 
78
83
 
79
- IF (WIN32 AND EMBED_SSH_PATH)
80
- FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
81
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
82
- FILE(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
83
- SET(GIT_SSH 1)
84
- ENDIF()
84
+ if(WIN32 AND EMBED_SSH_PATH)
85
+ file(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
86
+ list(SORT SRC_SSH)
87
+ target_sources(git2internal PRIVATE ${SRC_SSH})
88
+
89
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
90
+ file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
91
+ set(GIT_SSH 1)
92
+ endif()
85
93
 
86
94
  IF (WIN32 AND WINHTTP)
87
95
  SET(GIT_WINHTTP 1)
@@ -101,8 +109,9 @@ IF (WIN32 AND WINHTTP)
101
109
  LIST(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
102
110
  ENDIF()
103
111
 
104
- Include(SelectHTTPSBackend)
105
- Include(SelectHashes)
112
+ include(SelectHTTPSBackend)
113
+ include(SelectHashes)
114
+ target_sources(git2internal PRIVATE ${SRC_SHA1})
106
115
 
107
116
  # Specify regular expression implementation
108
117
  FIND_PACKAGE(PCRE)
@@ -264,36 +273,43 @@ ELSEIF (HAVE_STRUCT_STAT_ST_MTIME_NSEC)
264
273
  SET(GIT_USE_STAT_MTIME_NSEC 1)
265
274
  ENDIF()
266
275
 
267
- ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
276
+ target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64)
268
277
 
269
278
  # Collect sourcefiles
270
- FILE(GLOB SRC_H
279
+ file(GLOB SRC_H
271
280
  "${libgit2_SOURCE_DIR}/include/git2.h"
272
281
  "${libgit2_SOURCE_DIR}/include/git2/*.h"
273
282
  "${libgit2_SOURCE_DIR}/include/git2/sys/*.h")
283
+ list(SORT SRC_H)
284
+ target_sources(git2internal PRIVATE ${SRC_H})
274
285
 
275
286
  # On Windows use specific platform sources
276
- IF (WIN32 AND NOT CYGWIN)
277
- IF(MSVC)
278
- SET(WIN_RC "win32/git2.rc")
279
- ENDIF()
280
-
281
- FILE(GLOB SRC_OS win32/*.c win32/*.h)
282
- ELSEIF (AMIGA)
283
- ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP)
284
- ELSE()
285
- FILE(GLOB SRC_OS unix/*.c unix/*.h)
286
- ENDIF()
287
+ if(WIN32 AND NOT CYGWIN)
288
+ SET(WIN_RC "win32/git2.rc")
289
+
290
+ file(GLOB SRC_OS win32/*.c win32/*.h)
291
+ list(SORT SRC_OS)
292
+ target_sources(git2internal PRIVATE ${SRC_OS})
293
+ elseif(AMIGA)
294
+ target_compile_definitions(git2internal PRIVATE NO_ADDRINFO NO_READDIR_R NO_MMAP)
295
+ else()
296
+ file(GLOB SRC_OS unix/*.c unix/*.h)
297
+ list(SORT SRC_OS)
298
+ target_sources(git2internal PRIVATE ${SRC_OS})
299
+ endif()
287
300
 
288
301
  IF (USE_LEAK_CHECKER STREQUAL "valgrind")
289
- ADD_DEFINITIONS(-DVALGRIND)
302
+ target_compile_definitions(git2internal PRIVATE VALGRIND)
290
303
  ENDIF()
291
304
 
292
- FILE(GLOB SRC_GIT2 *.c *.h
305
+ file(GLOB SRC_GIT2 *.c *.h
293
306
  allocators/*.c allocators/*.h
294
307
  streams/*.c streams/*.h
295
308
  transports/*.c transports/*.h
296
309
  xdiff/*.c xdiff/*.h)
310
+ list(SORT SRC_GIT2)
311
+ target_sources(git2internal PRIVATE ${SRC_GIT2})
312
+
297
313
  IF(APPLE)
298
314
  # The old Secure Transport API has been deprecated in macOS 10.15.
299
315
  SET_SOURCE_FILES_PROPERTIES(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
@@ -319,10 +335,6 @@ ENDIF()
319
335
 
320
336
  CONFIGURE_FILE(features.h.in git2/sys/features.h)
321
337
 
322
- SET(LIBGIT2_SOURCES ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_SSH} ${SRC_SHA1})
323
-
324
- ADD_LIBRARY(git2internal OBJECT ${LIBGIT2_SOURCES})
325
- SET_TARGET_PROPERTIES(git2internal PROPERTIES C_STANDARD 90)
326
338
  IDE_SPLIT_SOURCES(git2internal)
327
339
  LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
328
340
 
@@ -358,19 +370,19 @@ ENDIF()
358
370
 
359
371
  IDE_SPLIT_SOURCES(git2)
360
372
 
361
- IF (SONAME)
362
- SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING})
363
- SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_SOVERSION})
364
- IF (LIBGIT2_FILENAME)
365
- ADD_DEFINITIONS(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
366
- SET_TARGET_PROPERTIES(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
367
- ELSEIF (DEFINED LIBGIT2_PREFIX)
368
- SET_TARGET_PROPERTIES(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
369
- ENDIF()
370
- ENDIF()
373
+ if(SONAME)
374
+ set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION})
375
+ set_target_properties(git2 PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
376
+ if(LIBGIT2_FILENAME)
377
+ target_compile_definitions(git2internal PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
378
+ set_target_properties(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
379
+ elseif(DEFINED LIBGIT2_PREFIX)
380
+ set_target_properties(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
381
+ endif()
382
+ endif()
371
383
 
372
384
  PKG_BUILD_CONFIG(NAME libgit2
373
- VERSION ${LIBGIT2_VERSION_STRING}
385
+ VERSION ${libgit2_VERSION}
374
386
  DESCRIPTION "The git library, take 2"
375
387
  LIBS_SELF git2
376
388
  PRIVATE_LIBS ${LIBGIT2_PC_LIBS}
@@ -63,7 +63,11 @@ static int patch_image_init_fromstr(
63
63
 
64
64
  memset(out, 0x0, sizeof(patch_image));
65
65
 
66
- git_pool_init(&out->pool, sizeof(git_diff_line));
66
+ if (git_pool_init(&out->pool, sizeof(git_diff_line)) < 0)
67
+ return -1;
68
+
69
+ if (!in_len)
70
+ return 0;
67
71
 
68
72
  for (start = in; start < in + in_len; start = end) {
69
73
  end = memchr(start, '\n', in_len - (start - in));
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
+ *
4
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
5
+ * a Linking Exception. For full terms see the included COPYING file.
6
+ */
7
+ #ifndef INCLUDE_assert_safe_h__
8
+ #define INCLUDE_assert_safe_h__
9
+
10
+ /*
11
+ * In a debug build, we'll assert(3) for aide in debugging. In release
12
+ * builds, we will provide macros that will set an error message that
13
+ * indicate a failure and return. Note that memory leaks can occur in
14
+ * a release-mode assertion failure -- it is impractical to provide
15
+ * safe clean up routines in these very extreme failures, but care
16
+ * should be taken to not leak very large objects.
17
+ */
18
+
19
+ #if (defined(_DEBUG) || defined(GIT_ASSERT_HARD)) && GIT_ASSERT_HARD != 0
20
+ # include <assert.h>
21
+
22
+ # define GIT_ASSERT(expr) assert(expr)
23
+ # define GIT_ASSERT_ARG(expr) assert(expr)
24
+
25
+ # define GIT_ASSERT_WITH_RETVAL(expr, fail) assert(expr)
26
+ # define GIT_ASSERT_ARG_WITH_RETVAL(expr, fail) assert(expr)
27
+ #else
28
+
29
+ /** Internal consistency check to stop the function. */
30
+ # define GIT_ASSERT(expr) GIT_ASSERT_WITH_RETVAL(expr, -1)
31
+
32
+ /**
33
+ * Assert that a consumer-provided argument is valid, setting an
34
+ * actionable error message and returning -1 if it is not.
35
+ */
36
+ # define GIT_ASSERT_ARG(expr) GIT_ASSERT_ARG_WITH_RETVAL(expr, -1)
37
+
38
+ /** Internal consistency check to return the `fail` param on failure. */
39
+ # define GIT_ASSERT_WITH_RETVAL(expr, fail) \
40
+ GIT_ASSERT__WITH_RETVAL(expr, GIT_ERROR_INTERNAL, "unrecoverable internal error", fail)
41
+
42
+ /**
43
+ * Assert that a consumer-provided argument is valid, setting an
44
+ * actionable error message and returning the `fail` param if not.
45
+ */
46
+ # define GIT_ASSERT_ARG_WITH_RETVAL(expr, fail) \
47
+ GIT_ASSERT__WITH_RETVAL(expr, GIT_ERROR_INVALID, "invalid argument", fail)
48
+
49
+ # define GIT_ASSERT__WITH_RETVAL(expr, code, msg, fail) do { \
50
+ if (!(expr)) { \
51
+ git_error_set(code, "%s: '%s'", msg, #expr); \
52
+ return fail; \
53
+ } \
54
+ } while(0)
55
+
56
+ #endif /* GIT_ASSERT_HARD */
57
+
58
+ #endif
@@ -41,16 +41,21 @@ int git_attr_file__new(
41
41
 
42
42
  if (git_mutex_init(&attrs->lock) < 0) {
43
43
  git_error_set(GIT_ERROR_OS, "failed to initialize lock");
44
- git__free(attrs);
45
- return -1;
44
+ goto on_error;
46
45
  }
47
46
 
48
- git_pool_init(&attrs->pool, 1);
47
+ if (git_pool_init(&attrs->pool, 1) < 0)
48
+ goto on_error;
49
+
49
50
  GIT_REFCOUNT_INC(attrs);
50
51
  attrs->entry = entry;
51
52
  attrs->source = source;
52
53
  *out = attrs;
53
54
  return 0;
55
+
56
+ on_error:
57
+ git__free(attrs);
58
+ return -1;
54
59
  }
55
60
 
56
61
  int git_attr_file__clear_rules(git_attr_file *file, bool need_lock)