rugged 0.27.5 → 0.27.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +2 -2
  4. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
  5. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
  6. data/vendor/libgit2/include/git2.h +1 -0
  7. data/vendor/libgit2/include/git2/attr.h +18 -7
  8. data/vendor/libgit2/include/git2/blame.h +39 -22
  9. data/vendor/libgit2/include/git2/blob.h +1 -1
  10. data/vendor/libgit2/include/git2/branch.h +1 -1
  11. data/vendor/libgit2/include/git2/buffer.h +14 -2
  12. data/vendor/libgit2/include/git2/checkout.h +13 -12
  13. data/vendor/libgit2/include/git2/cherrypick.h +6 -4
  14. data/vendor/libgit2/include/git2/clone.h +8 -6
  15. data/vendor/libgit2/include/git2/commit.h +28 -0
  16. data/vendor/libgit2/include/git2/common.h +27 -0
  17. data/vendor/libgit2/include/git2/config.h +1 -0
  18. data/vendor/libgit2/include/git2/describe.h +30 -7
  19. data/vendor/libgit2/include/git2/diff.h +32 -22
  20. data/vendor/libgit2/include/git2/errors.h +1 -0
  21. data/vendor/libgit2/include/git2/ignore.h +2 -2
  22. data/vendor/libgit2/include/git2/mailmap.h +115 -0
  23. data/vendor/libgit2/include/git2/merge.h +10 -8
  24. data/vendor/libgit2/include/git2/proxy.h +9 -5
  25. data/vendor/libgit2/include/git2/rebase.h +7 -4
  26. data/vendor/libgit2/include/git2/refspec.h +17 -0
  27. data/vendor/libgit2/include/git2/remote.h +12 -10
  28. data/vendor/libgit2/include/git2/repository.h +7 -5
  29. data/vendor/libgit2/include/git2/revert.h +5 -3
  30. data/vendor/libgit2/include/git2/stash.h +11 -8
  31. data/vendor/libgit2/include/git2/status.h +7 -3
  32. data/vendor/libgit2/include/git2/submodule.h +8 -7
  33. data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
  34. data/vendor/libgit2/include/git2/sys/index.h +3 -0
  35. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  36. data/vendor/libgit2/include/git2/sys/merge.h +6 -1
  37. data/vendor/libgit2/include/git2/sys/path.h +55 -0
  38. data/vendor/libgit2/include/git2/transaction.h +1 -0
  39. data/vendor/libgit2/include/git2/types.h +8 -5
  40. data/vendor/libgit2/include/git2/version.h +2 -2
  41. data/vendor/libgit2/include/git2/worktree.h +46 -11
  42. data/vendor/libgit2/src/CMakeLists.txt +87 -15
  43. data/vendor/libgit2/src/alloc.c +47 -0
  44. data/vendor/libgit2/src/alloc.h +40 -0
  45. data/vendor/libgit2/src/apply.c +4 -4
  46. data/vendor/libgit2/src/attr.c +4 -4
  47. data/vendor/libgit2/src/attr_file.c +8 -7
  48. data/vendor/libgit2/src/attrcache.c +2 -2
  49. data/vendor/libgit2/src/blame.c +11 -4
  50. data/vendor/libgit2/src/blame.h +1 -0
  51. data/vendor/libgit2/src/blame_git.c +8 -5
  52. data/vendor/libgit2/src/blob.c +5 -5
  53. data/vendor/libgit2/src/branch.c +20 -20
  54. data/vendor/libgit2/src/buffer.c +9 -4
  55. data/vendor/libgit2/src/buffer.h +1 -1
  56. data/vendor/libgit2/src/checkout.c +33 -24
  57. data/vendor/libgit2/src/cherrypick.c +3 -3
  58. data/vendor/libgit2/src/clone.c +13 -13
  59. data/vendor/libgit2/src/commit.c +16 -3
  60. data/vendor/libgit2/src/common.h +3 -1
  61. data/vendor/libgit2/src/config.c +3 -3
  62. data/vendor/libgit2/src/config_file.c +193 -241
  63. data/vendor/libgit2/src/config_parse.c +89 -66
  64. data/vendor/libgit2/src/config_parse.h +2 -2
  65. data/vendor/libgit2/src/crlf.c +9 -3
  66. data/vendor/libgit2/src/diff.c +2 -2
  67. data/vendor/libgit2/src/diff_driver.c +3 -3
  68. data/vendor/libgit2/src/diff_file.c +3 -3
  69. data/vendor/libgit2/src/diff_generate.c +4 -3
  70. data/vendor/libgit2/src/diff_print.c +8 -8
  71. data/vendor/libgit2/src/diff_tform.c +1 -1
  72. data/vendor/libgit2/src/diff_xdiff.c +12 -0
  73. data/vendor/libgit2/src/features.h.in +2 -0
  74. data/vendor/libgit2/src/fetch.c +2 -2
  75. data/vendor/libgit2/src/fetchhead.c +5 -5
  76. data/vendor/libgit2/src/filebuf.c +4 -4
  77. data/vendor/libgit2/src/fileops.c +10 -10
  78. data/vendor/libgit2/src/filter.c +3 -3
  79. data/vendor/libgit2/src/global.c +17 -12
  80. data/vendor/libgit2/src/hash.h +2 -0
  81. data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
  82. data/vendor/libgit2/src/hash/hash_mbedtls.h +20 -0
  83. data/vendor/libgit2/src/ignore.c +15 -20
  84. data/vendor/libgit2/src/index.c +77 -36
  85. data/vendor/libgit2/src/index.h +10 -0
  86. data/vendor/libgit2/src/indexer.c +9 -9
  87. data/vendor/libgit2/src/iterator.c +8 -8
  88. data/vendor/libgit2/src/khash.h +3 -1
  89. data/vendor/libgit2/src/mailmap.c +485 -0
  90. data/vendor/libgit2/src/mailmap.h +35 -0
  91. data/vendor/libgit2/src/merge.c +7 -7
  92. data/vendor/libgit2/src/netops.c +5 -5
  93. data/vendor/libgit2/src/notes.c +2 -2
  94. data/vendor/libgit2/src/odb.c +7 -7
  95. data/vendor/libgit2/src/odb_loose.c +13 -13
  96. data/vendor/libgit2/src/odb_pack.c +3 -3
  97. data/vendor/libgit2/src/pack-objects.c +2 -2
  98. data/vendor/libgit2/src/pack.c +5 -5
  99. data/vendor/libgit2/src/pack.h +1 -1
  100. data/vendor/libgit2/src/patch.c +1 -1
  101. data/vendor/libgit2/src/patch_generate.c +2 -2
  102. data/vendor/libgit2/src/patch_parse.c +11 -4
  103. data/vendor/libgit2/src/path.c +42 -66
  104. data/vendor/libgit2/src/path.h +2 -72
  105. data/vendor/libgit2/src/pathspec.c +1 -1
  106. data/vendor/libgit2/src/push.c +2 -2
  107. data/vendor/libgit2/src/rebase.c +19 -22
  108. data/vendor/libgit2/src/refdb_fs.c +65 -34
  109. data/vendor/libgit2/src/refs.c +6 -6
  110. data/vendor/libgit2/src/refspec.c +30 -5
  111. data/vendor/libgit2/src/refspec.h +1 -1
  112. data/vendor/libgit2/src/remote.c +40 -40
  113. data/vendor/libgit2/src/repository.c +63 -59
  114. data/vendor/libgit2/src/reset.c +1 -1
  115. data/vendor/libgit2/src/revert.c +3 -3
  116. data/vendor/libgit2/src/revparse.c +4 -4
  117. data/vendor/libgit2/src/revwalk.c +44 -10
  118. data/vendor/libgit2/src/revwalk.h +2 -1
  119. data/vendor/libgit2/src/settings.c +25 -1
  120. data/vendor/libgit2/src/signature.c +1 -1
  121. data/vendor/libgit2/src/stash.c +80 -34
  122. data/vendor/libgit2/src/status.c +1 -1
  123. data/vendor/libgit2/src/stdalloc.c +120 -0
  124. data/vendor/libgit2/src/stdalloc.h +17 -0
  125. data/vendor/libgit2/src/streams/mbedtls.c +463 -0
  126. data/vendor/libgit2/src/streams/mbedtls.h +20 -0
  127. data/vendor/libgit2/src/streams/openssl.c +132 -34
  128. data/vendor/libgit2/src/streams/openssl.h +0 -107
  129. data/vendor/libgit2/src/streams/tls.c +3 -0
  130. data/vendor/libgit2/src/submodule.c +117 -82
  131. data/vendor/libgit2/src/sysdir.c +4 -4
  132. data/vendor/libgit2/src/tag.c +7 -7
  133. data/vendor/libgit2/src/trace.h +1 -1
  134. data/vendor/libgit2/src/trailer.c +6 -6
  135. data/vendor/libgit2/src/transport.c +2 -2
  136. data/vendor/libgit2/src/transports/auth.c +1 -1
  137. data/vendor/libgit2/src/transports/auth_negotiate.c +2 -2
  138. data/vendor/libgit2/src/transports/git.c +1 -1
  139. data/vendor/libgit2/src/transports/http.c +12 -12
  140. data/vendor/libgit2/src/transports/local.c +7 -7
  141. data/vendor/libgit2/src/transports/smart.c +17 -8
  142. data/vendor/libgit2/src/transports/smart.h +5 -5
  143. data/vendor/libgit2/src/transports/smart_pkt.c +122 -130
  144. data/vendor/libgit2/src/transports/smart_protocol.c +48 -38
  145. data/vendor/libgit2/src/transports/ssh.c +1 -1
  146. data/vendor/libgit2/src/transports/winhttp.c +6 -6
  147. data/vendor/libgit2/src/tree.c +12 -53
  148. data/vendor/libgit2/src/tree.h +0 -12
  149. data/vendor/libgit2/src/util.c +16 -0
  150. data/vendor/libgit2/src/util.h +12 -135
  151. data/vendor/libgit2/src/win32/findfile.c +2 -2
  152. data/vendor/libgit2/src/win32/posix_w32.c +1 -1
  153. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +94 -0
  154. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
  155. data/vendor/libgit2/src/worktree.c +64 -43
  156. data/vendor/libgit2/src/worktree.h +2 -0
  157. data/vendor/libgit2/src/xdiff/xdiffi.c +3 -1
  158. metadata +16 -2
@@ -0,0 +1,55 @@
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
+
8
+ #ifndef INCLUDE_sys_git_path_h__
9
+ #define INCLUDE_sys_git_path_h__
10
+
11
+ #include "git2/common.h"
12
+
13
+ GIT_BEGIN_DECL
14
+
15
+ /*
16
+ * The order needs to stay the same to not break the `gitfiles`
17
+ * array in path.c
18
+ */
19
+ typedef enum {
20
+ GIT_PATH_GITFILE_GITIGNORE,
21
+ GIT_PATH_GITFILE_GITMODULES,
22
+ GIT_PATH_GITFILE_GITATTRIBUTES
23
+ } git_path_gitfile;
24
+
25
+ typedef enum {
26
+ /* Do both NTFS- and HFS-specific checks */
27
+ GIT_PATH_FS_GENERIC,
28
+ /* Do NTFS-specific checks only */
29
+ GIT_PATH_FS_NTFS,
30
+ /* Do HFS-specific checks only */
31
+ GIT_PATH_FS_HFS
32
+ } git_path_fs;
33
+
34
+ /**
35
+ * Check whether a path component corresponds to a .git$SUFFIX
36
+ * file.
37
+ *
38
+ * As some filesystems do special things to filenames when
39
+ * writing files to disk, you cannot always do a plain string
40
+ * comparison to verify whether a file name matches an expected
41
+ * path or not. This function can do the comparison for you,
42
+ * depending on the filesystem you're on.
43
+ *
44
+ * @param path the path component to check
45
+ * @param pathlen the length of `path` that is to be checked
46
+ * @param gitfile which file to check against
47
+ * @param fs which filesystem-specific checks to use
48
+ * @return 0 in case the file does not match, a positive value if
49
+ * it does; -1 in case of an error
50
+ */
51
+ extern int git_path_is_gitfile(const char *path, size_t pathlen, git_path_gitfile gitfile, git_path_fs fs);
52
+
53
+ GIT_END_DECL
54
+
55
+ #endif /* INCLUDE_sys_git_path */
@@ -8,6 +8,7 @@
8
8
  #define INCLUDE_git_transaction_h__
9
9
 
10
10
  #include "common.h"
11
+ #include "types.h"
11
12
 
12
13
  /**
13
14
  * @file git2/transaction.h
@@ -63,6 +63,9 @@ typedef int64_t git_time_t;
63
63
 
64
64
  #endif
65
65
 
66
+ #include "buffer.h"
67
+ #include "oid.h"
68
+
66
69
  /** Basic type (loose or packed) of any Git object. */
67
70
  typedef enum {
68
71
  GIT_OBJ_ANY = -2, /**< Object can be any of the following */
@@ -181,9 +184,6 @@ typedef struct git_transaction git_transaction;
181
184
  /** Annotated commits, the input to merge and rebase. */
182
185
  typedef struct git_annotated_commit git_annotated_commit;
183
186
 
184
- /** Merge result */
185
- typedef struct git_merge_result git_merge_result;
186
-
187
187
  /** Representation of a status collection */
188
188
  typedef struct git_status_list git_status_list;
189
189
 
@@ -215,7 +215,7 @@ typedef enum {
215
215
  GIT_FILEMODE_COMMIT = 0160000,
216
216
  } git_filemode_t;
217
217
 
218
- /*
218
+ /**
219
219
  * A refspec specifies the mapping between remote and local reference
220
220
  * names when fetch or pushing.
221
221
  */
@@ -425,15 +425,18 @@ typedef enum {
425
425
  GIT_SUBMODULE_RECURSE_ONDEMAND = 2,
426
426
  } git_submodule_recurse_t;
427
427
 
428
- /** A type to write in a streaming fashion, for example, for filters. */
429
428
  typedef struct git_writestream git_writestream;
430
429
 
430
+ /** A type to write in a streaming fashion, for example, for filters. */
431
431
  struct git_writestream {
432
432
  int (*write)(git_writestream *stream, const char *buffer, size_t len);
433
433
  int (*close)(git_writestream *stream);
434
434
  void (*free)(git_writestream *stream);
435
435
  };
436
436
 
437
+ /** Representation of .mailmap file state. */
438
+ typedef struct git_mailmap git_mailmap;
439
+
437
440
  /** @} */
438
441
  GIT_END_DECL
439
442
 
@@ -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.27.5"
10
+ #define LIBGIT2_VERSION "0.27.0"
11
11
  #define LIBGIT2_VER_MAJOR 0
12
12
  #define LIBGIT2_VER_MINOR 27
13
- #define LIBGIT2_VER_REVISION 5
13
+ #define LIBGIT2_VER_REVISION 0
14
14
  #define LIBGIT2_VER_PATCH 0
15
15
 
16
16
  #define LIBGIT2_SOVERSION 27
@@ -74,22 +74,31 @@ GIT_EXTERN(void) git_worktree_free(git_worktree *wt);
74
74
  */
75
75
  GIT_EXTERN(int) git_worktree_validate(const git_worktree *wt);
76
76
 
77
+ /**
78
+ * Worktree add options structure
79
+ *
80
+ * Initialize with `GIT_WORKTREE_ADD_OPTIONS_INIT`. Alternatively, you can
81
+ * use `git_worktree_add_init_options`.
82
+ *
83
+ */
77
84
  typedef struct git_worktree_add_options {
78
85
  unsigned int version;
79
86
 
80
87
  int lock; /**< lock newly created worktree */
88
+ git_reference *ref; /**< reference to use for the new worktree HEAD */
81
89
  } git_worktree_add_options;
82
90
 
83
91
  #define GIT_WORKTREE_ADD_OPTIONS_VERSION 1
84
- #define GIT_WORKTREE_ADD_OPTIONS_INIT {GIT_WORKTREE_ADD_OPTIONS_VERSION,0}
92
+ #define GIT_WORKTREE_ADD_OPTIONS_INIT {GIT_WORKTREE_ADD_OPTIONS_VERSION,0,NULL}
85
93
 
86
94
  /**
87
- * Initializes a `git_worktree_add_options` with default vaules.
88
- * Equivalent to creating an instance with
89
- * GIT_WORKTREE_ADD_OPTIONS_INIT.
95
+ * Initialize git_worktree_add_options structure
96
+ *
97
+ * Initializes a `git_worktree_add_options` with default values. Equivalent to
98
+ * creating an instance with `GIT_WORKTREE_ADD_OPTIONS_INIT`.
90
99
  *
91
- * @param opts the struct to initialize
92
- * @param version Verison of struct; pass `GIT_WORKTREE_ADD_OPTIONS_VERSION`
100
+ * @param opts The `git_worktree_add_options` struct to initialize.
101
+ * @param version The struct version; pass `GIT_WORKTREE_ADD_OPTIONS_VERSION`.
93
102
  * @return Zero on success; -1 on failure.
94
103
  */
95
104
  int git_worktree_add_init_options(git_worktree_add_options *opts,
@@ -148,6 +157,24 @@ GIT_EXTERN(int) git_worktree_unlock(git_worktree *wt);
148
157
  */
149
158
  GIT_EXTERN(int) git_worktree_is_locked(git_buf *reason, const git_worktree *wt);
150
159
 
160
+ /**
161
+ * Retrieve the name of the worktree
162
+ *
163
+ * @param wt Worktree to get the name for
164
+ * @return The worktree's name. The pointer returned is valid for the
165
+ * lifetime of the git_worktree
166
+ */
167
+ GIT_EXTERN(const char *) git_worktree_name(const git_worktree *wt);
168
+
169
+ /**
170
+ * Retrieve the filesystem path for the worktree
171
+ *
172
+ * @param wt Worktree to get the path for
173
+ * @return The worktree's filesystem path. The pointer returned
174
+ * is valid for the lifetime of the git_worktree.
175
+ */
176
+ GIT_EXTERN(const char *) git_worktree_path(const git_worktree *wt);
177
+
151
178
  /**
152
179
  * Flags which can be passed to git_worktree_prune to alter its
153
180
  * behavior.
@@ -161,6 +188,13 @@ typedef enum {
161
188
  GIT_WORKTREE_PRUNE_WORKING_TREE = 1u << 2,
162
189
  } git_worktree_prune_t;
163
190
 
191
+ /**
192
+ * Worktree prune options structure
193
+ *
194
+ * Initialize with `GIT_WORKTREE_PRUNE_OPTIONS_INIT`. Alternatively, you can
195
+ * use `git_worktree_prune_init_options`.
196
+ *
197
+ */
164
198
  typedef struct git_worktree_prune_options {
165
199
  unsigned int version;
166
200
 
@@ -171,12 +205,13 @@ typedef struct git_worktree_prune_options {
171
205
  #define GIT_WORKTREE_PRUNE_OPTIONS_INIT {GIT_WORKTREE_PRUNE_OPTIONS_VERSION,0}
172
206
 
173
207
  /**
174
- * Initializes a `git_worktree_prune_options` with default vaules.
175
- * Equivalent to creating an instance with
176
- * GIT_WORKTREE_PRUNE_OPTIONS_INIT.
208
+ * Initialize git_worktree_prune_options structure
209
+ *
210
+ * Initializes a `git_worktree_prune_options` with default values. Equivalent to
211
+ * creating an instance with `GIT_WORKTREE_PRUNE_OPTIONS_INIT`.
177
212
  *
178
- * @param opts the struct to initialize
179
- * @param version Verison of struct; pass `GIT_WORKTREE_PRUNE_OPTIONS_VERSION`
213
+ * @param opts The `git_worktree_prune_options` struct to initialize.
214
+ * @param version The struct version; pass `GIT_WORKTREE_PRUNE_OPTIONS_VERSION`.
180
215
  * @return Zero on success; -1 on failure.
181
216
  */
182
217
  GIT_EXTERN(int) git_worktree_prune_init_options(
@@ -16,6 +16,7 @@ SET(LIBGIT2_INCLUDES
16
16
  "${CMAKE_CURRENT_BINARY_DIR}"
17
17
  "${libgit2_SOURCE_DIR}/src"
18
18
  "${libgit2_SOURCE_DIR}/include")
19
+ SET(LIBGIT2_SYSTEM_INCLUDES "")
19
20
  SET(LIBGIT2_LIBS "")
20
21
 
21
22
  # Installation paths
@@ -94,7 +95,7 @@ ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
94
95
 
95
96
  IF (WIN32 AND EMBED_SSH_PATH)
96
97
  FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
97
- LIST(APPEND LIBGIT2_INCLUDES "${EMBED_SSH_PATH}/include")
98
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include")
98
99
  FILE(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
99
100
  SET(GIT_SSH 1)
100
101
  ENDIF()
@@ -107,7 +108,7 @@ IF (WIN32 AND WINHTTP)
107
108
  IF (MINGW)
108
109
  ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
109
110
  LIST(APPEND LIBGIT2_LIBS winhttp)
110
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
111
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
111
112
  ELSE()
112
113
  LIST(APPEND LIBGIT2_LIBS "winhttp")
113
114
  LIST(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
@@ -121,7 +122,7 @@ ELSE ()
121
122
  ENDIF ()
122
123
  IF (CURL_FOUND)
123
124
  SET(GIT_CURL 1)
124
- LIST(APPEND LIBGIT2_INCLUDES ${CURL_INCLUDE_DIRS})
125
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${CURL_INCLUDE_DIRS})
125
126
  LIST(APPEND LIBGIT2_LIBS ${CURL_LIBRARIES})
126
127
  LIST(APPEND LIBGIT2_PC_LIBS ${CURL_LDFLAGS})
127
128
  ENDIF()
@@ -129,6 +130,9 @@ ELSE ()
129
130
  ENDIF()
130
131
 
131
132
  IF (USE_HTTPS)
133
+ # We try to find any packages our backends might use
134
+ FIND_PACKAGE(OpenSSL)
135
+ FIND_PACKAGE(mbedTLS)
132
136
  IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
133
137
  FIND_PACKAGE(Security)
134
138
  FIND_PACKAGE(CoreFoundation)
@@ -145,8 +149,13 @@ IF (USE_HTTPS)
145
149
  ENDIF()
146
150
  ELSEIF (WINHTTP)
147
151
  SET(HTTPS_BACKEND "WinHTTP")
148
- ELSE()
152
+ ELSEIF(OPENSSL_FOUND)
149
153
  SET(HTTPS_BACKEND "OpenSSL")
154
+ ELSEIF(MBEDTLS_FOUND)
155
+ SET(HTTPS_BACKEND "mbedTLS")
156
+ ELSE()
157
+ MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
158
+ "Please pass the backend name explicitly (-DUSE_HTTPS=backend)")
150
159
  ENDIF()
151
160
  ELSE()
152
161
  # Backend was explicitly set
@@ -166,21 +175,68 @@ IF (USE_HTTPS)
166
175
  ENDIF()
167
176
 
168
177
  SET(GIT_SECURE_TRANSPORT 1)
169
- LIST(APPEND LIBGIT2_INCLUDES ${SECURITY_INCLUDE_DIR})
178
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
170
179
  LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LIBRARIES} ${SECURITY_LIBRARIES})
171
180
  LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
172
181
  ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
173
- FIND_PACKAGE(OpenSSL)
174
-
175
182
  IF (NOT OPENSSL_FOUND)
176
183
  MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
177
184
  ENDIF()
178
185
 
179
186
  SET(GIT_OPENSSL 1)
180
- LIST(APPEND LIBGIT2_INCLUDES ${OPENSSL_INCLUDE_DIR})
187
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
181
188
  LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES})
182
189
  LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
183
190
  LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
191
+ ELSEIF(HTTPS_BACKEND STREQUAL "mbedTLS")
192
+ IF (NOT MBEDTLS_FOUND)
193
+ MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
194
+ ENDIF()
195
+
196
+ IF(NOT CERT_LOCATION)
197
+ MESSAGE("Auto-detecting default certificates location")
198
+ IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
199
+ # Check for an Homebrew installation
200
+ SET(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
201
+ ELSE()
202
+ SET(OPENSSL_CMD "openssl")
203
+ ENDIF()
204
+ EXECUTE_PROCESS(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
205
+ IF(OPENSSL_DIR)
206
+ STRING(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${OPENSSL_DIR})
207
+
208
+ SET(OPENSSL_CA_LOCATIONS
209
+ "ca-bundle.pem" # OpenSUSE Leap 42.1
210
+ "cert.pem" # Ubuntu 14.04, FreeBSD
211
+ "certs/ca-certificates.crt" # Ubuntu 16.04
212
+ "certs/ca.pem" # Debian 7
213
+ )
214
+ FOREACH(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
215
+ SET(LOC "${OPENSSL_DIR}${SUFFIX}")
216
+ IF(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
217
+ SET(CERT_LOCATION ${LOC})
218
+ ENDIF()
219
+ ENDFOREACH()
220
+ ELSE()
221
+ MESSAGE("Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
222
+ ENDIF()
223
+ ENDIF()
224
+
225
+ IF(CERT_LOCATION)
226
+ IF(NOT EXISTS ${CERT_LOCATION})
227
+ MESSAGE(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
228
+ ENDIF()
229
+ ADD_FEATURE_INFO(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
230
+ ADD_DEFINITIONS(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
231
+ ENDIF()
232
+
233
+ SET(GIT_MBEDTLS 1)
234
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
235
+ LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
236
+ # mbedTLS has no pkgconfig file, hence we can't require it
237
+ # https://github.com/ARMmbed/mbedtls/issues/228
238
+ # For now, pass its link flags as our own
239
+ LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
184
240
  ELSEIF (HTTPS_BACKEND STREQUAL "WinHTTP")
185
241
  # WinHTTP setup was handled in the WinHTTP-specific block above
186
242
  ELSE()
@@ -226,6 +282,16 @@ ELSEIF(SHA1_BACKEND STREQUAL "Win32")
226
282
  ELSEIF(SHA1_BACKEND STREQUAL "CommonCrypto")
227
283
  ADD_FEATURE_INFO(SHA ON "using CommonCrypto")
228
284
  SET(GIT_SHA1_COMMON_CRYPTO 1)
285
+ ELSEIF (SHA1_BACKEND STREQUAL "mbedTLS")
286
+ ADD_FEATURE_INFO(SHA ON "using mbedTLS")
287
+ SET(GIT_SHA1_MBEDTLS 1)
288
+ FILE(GLOB SRC_SHA1 hash/hash_mbedtls.c)
289
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
290
+ LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
291
+ # mbedTLS has no pkgconfig file, hence we can't require it
292
+ # https://github.com/ARMmbed/mbedtls/issues/228
293
+ # For now, pass its link flags as our own
294
+ LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
229
295
  ELSE()
230
296
  MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend ${SHA1_BACKEND}")
231
297
  ENDIF()
@@ -233,21 +299,21 @@ ENDIF()
233
299
  # Include POSIX regex when it is required
234
300
  IF(WIN32 OR AMIGA OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
235
301
  ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/regex" "${libgit2_BINARY_DIR}/deps/regex")
236
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/regex")
302
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/regex")
237
303
  LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:regex>)
238
304
  ENDIF()
239
305
 
240
306
  # Optional external dependency: http-parser
241
307
  FIND_PACKAGE(HTTP_Parser)
242
308
  IF (USE_EXT_HTTP_PARSER AND HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
243
- LIST(APPEND LIBGIT2_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
309
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
244
310
  LIST(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES})
245
311
  LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
246
312
  ADD_FEATURE_INFO(http-parser ON "http-parser support")
247
313
  ELSE()
248
314
  MESSAGE(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
249
315
  ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser")
250
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
316
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
251
317
  LIST(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>")
252
318
  ADD_FEATURE_INFO(http-parser ON "http-parser support (bundled)")
253
319
  ENDIF()
@@ -256,7 +322,7 @@ ENDIF()
256
322
  IF(NOT USE_BUNDLED_ZLIB)
257
323
  FIND_PACKAGE(ZLIB)
258
324
  IF(ZLIB_FOUND)
259
- LIST(APPEND LIBGIT2_INCLUDES ${ZLIB_INCLUDE_DIRS})
325
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
260
326
  LIST(APPEND LIBGIT2_LIBS ${ZLIB_LIBRARIES})
261
327
  IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
262
328
  LIST(APPEND LIBGIT2_LIBS "z")
@@ -271,7 +337,7 @@ IF(NOT USE_BUNDLED_ZLIB)
271
337
  ENDIF()
272
338
  IF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
273
339
  ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
274
- LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
340
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
275
341
  LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
276
342
  ADD_FEATURE_INFO(zlib ON "using bundled zlib")
277
343
  ENDIF()
@@ -282,7 +348,7 @@ IF (USE_SSH)
282
348
  ENDIF()
283
349
  IF (LIBSSH2_FOUND)
284
350
  SET(GIT_SSH 1)
285
- LIST(APPEND LIBGIT2_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
351
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
286
352
  LIST(APPEND LIBGIT2_LIBS ${LIBSSH2_LIBRARIES})
287
353
  LIST(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
288
354
 
@@ -311,7 +377,7 @@ IF (USE_ICONV)
311
377
  ENDIF()
312
378
  IF (ICONV_FOUND)
313
379
  SET(GIT_USE_ICONV 1)
314
- LIST(APPEND LIBGIT2_INCLUDES ${ICONV_INCLUDE_DIR})
380
+ LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR})
315
381
  LIST(APPEND LIBGIT2_LIBS ${ICONV_LIBRARIES})
316
382
  LIST(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES})
317
383
  ENDIF()
@@ -384,19 +450,24 @@ CONFIGURE_FILE(features.h.in git2/sys/features.h)
384
450
  SET(LIBGIT2_SOURCES ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_SSH} ${SRC_SHA1})
385
451
 
386
452
  ADD_LIBRARY(git2internal OBJECT ${LIBGIT2_SOURCES})
453
+ SET_TARGET_PROPERTIES(git2internal PROPERTIES C_STANDARD 90)
387
454
  IDE_SPLIT_SOURCES(git2internal)
388
455
  LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
389
456
 
390
457
  IF (${CMAKE_VERSION} VERSION_LESS 2.8.12)
391
458
  INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
459
+ INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
392
460
  ELSE()
393
461
  TARGET_INCLUDE_DIRECTORIES(git2internal
394
462
  PRIVATE ${LIBGIT2_INCLUDES}
395
463
  PUBLIC ${libgit2_SOURCE_DIR}/include)
464
+ TARGET_INCLUDE_DIRECTORIES(git2internal
465
+ SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
396
466
  ENDIF()
397
467
 
398
468
  SET(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
399
469
  SET(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
470
+ SET(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
400
471
  SET(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
401
472
 
402
473
  IF(XCODE_VERSION)
@@ -410,6 +481,7 @@ ENDIF()
410
481
  ADD_LIBRARY(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
411
482
  TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS})
412
483
 
484
+ SET_TARGET_PROPERTIES(git2 PROPERTIES C_STANDARD 90)
413
485
  SET_TARGET_PROPERTIES(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
414
486
  SET_TARGET_PROPERTIES(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
415
487
  SET_TARGET_PROPERTIES(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})