rugged 0.27.7 → 0.27.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/CMakeLists.txt +6 -2
  4. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +29 -0
  5. data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +96 -0
  6. data/vendor/libgit2/cmake/Modules/FindIconv.cmake +11 -6
  7. data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -2
  8. data/vendor/libgit2/include/git2.h +0 -1
  9. data/vendor/libgit2/include/git2/attr.h +7 -18
  10. data/vendor/libgit2/include/git2/blame.h +22 -39
  11. data/vendor/libgit2/include/git2/blob.h +1 -1
  12. data/vendor/libgit2/include/git2/branch.h +1 -1
  13. data/vendor/libgit2/include/git2/buffer.h +2 -14
  14. data/vendor/libgit2/include/git2/checkout.h +12 -13
  15. data/vendor/libgit2/include/git2/cherrypick.h +4 -6
  16. data/vendor/libgit2/include/git2/clone.h +6 -8
  17. data/vendor/libgit2/include/git2/commit.h +0 -28
  18. data/vendor/libgit2/include/git2/common.h +0 -27
  19. data/vendor/libgit2/include/git2/config.h +0 -1
  20. data/vendor/libgit2/include/git2/describe.h +7 -30
  21. data/vendor/libgit2/include/git2/diff.h +22 -32
  22. data/vendor/libgit2/include/git2/errors.h +0 -1
  23. data/vendor/libgit2/include/git2/ignore.h +2 -2
  24. data/vendor/libgit2/include/git2/merge.h +8 -10
  25. data/vendor/libgit2/include/git2/proxy.h +5 -9
  26. data/vendor/libgit2/include/git2/rebase.h +4 -7
  27. data/vendor/libgit2/include/git2/refs.h +1 -1
  28. data/vendor/libgit2/include/git2/refspec.h +0 -17
  29. data/vendor/libgit2/include/git2/remote.h +10 -12
  30. data/vendor/libgit2/include/git2/repository.h +5 -7
  31. data/vendor/libgit2/include/git2/revert.h +3 -5
  32. data/vendor/libgit2/include/git2/stash.h +8 -11
  33. data/vendor/libgit2/include/git2/status.h +3 -7
  34. data/vendor/libgit2/include/git2/submodule.h +7 -8
  35. data/vendor/libgit2/include/git2/sys/index.h +0 -3
  36. data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
  37. data/vendor/libgit2/include/git2/sys/merge.h +1 -6
  38. data/vendor/libgit2/include/git2/transaction.h +0 -1
  39. data/vendor/libgit2/include/git2/types.h +5 -8
  40. data/vendor/libgit2/include/git2/version.h +2 -2
  41. data/vendor/libgit2/include/git2/worktree.h +11 -46
  42. data/vendor/libgit2/src/CMakeLists.txt +28 -91
  43. data/vendor/libgit2/src/annotated_commit.c +4 -4
  44. data/vendor/libgit2/src/apply.c +6 -5
  45. data/vendor/libgit2/src/attr.c +4 -4
  46. data/vendor/libgit2/src/attr_file.c +5 -5
  47. data/vendor/libgit2/src/attrcache.c +2 -2
  48. data/vendor/libgit2/src/blame.c +4 -11
  49. data/vendor/libgit2/src/blame.h +0 -1
  50. data/vendor/libgit2/src/blame_git.c +5 -8
  51. data/vendor/libgit2/src/blob.c +5 -5
  52. data/vendor/libgit2/src/branch.c +20 -20
  53. data/vendor/libgit2/src/buffer.c +4 -9
  54. data/vendor/libgit2/src/buffer.h +1 -1
  55. data/vendor/libgit2/src/checkout.c +24 -33
  56. data/vendor/libgit2/src/cherrypick.c +3 -3
  57. data/vendor/libgit2/src/clone.c +13 -13
  58. data/vendor/libgit2/src/commit.c +5 -18
  59. data/vendor/libgit2/src/commit_list.c +9 -3
  60. data/vendor/libgit2/src/common.h +1 -3
  61. data/vendor/libgit2/src/config.c +15 -6
  62. data/vendor/libgit2/src/config_file.c +249 -193
  63. data/vendor/libgit2/src/config_parse.c +66 -89
  64. data/vendor/libgit2/src/config_parse.h +2 -2
  65. data/vendor/libgit2/src/crlf.c +3 -9
  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 +3 -4
  70. data/vendor/libgit2/src/diff_print.c +8 -8
  71. data/vendor/libgit2/src/diff_tform.c +4 -2
  72. data/vendor/libgit2/src/diff_xdiff.c +0 -12
  73. data/vendor/libgit2/src/features.h.in +0 -2
  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 +9 -3
  79. data/vendor/libgit2/src/global.c +12 -17
  80. data/vendor/libgit2/src/hash.h +0 -2
  81. data/vendor/libgit2/src/ignore.c +5 -5
  82. data/vendor/libgit2/src/index.c +40 -80
  83. data/vendor/libgit2/src/index.h +0 -10
  84. data/vendor/libgit2/src/indexer.c +9 -9
  85. data/vendor/libgit2/src/iterator.c +8 -8
  86. data/vendor/libgit2/src/khash.h +1 -3
  87. data/vendor/libgit2/src/merge.c +7 -7
  88. data/vendor/libgit2/src/netops.c +5 -5
  89. data/vendor/libgit2/src/notes.c +2 -2
  90. data/vendor/libgit2/src/odb.c +9 -9
  91. data/vendor/libgit2/src/odb_loose.c +22 -18
  92. data/vendor/libgit2/src/odb_pack.c +3 -3
  93. data/vendor/libgit2/src/pack-objects.c +3 -3
  94. data/vendor/libgit2/src/pack.c +5 -5
  95. data/vendor/libgit2/src/pack.h +1 -1
  96. data/vendor/libgit2/src/parse.c +7 -4
  97. data/vendor/libgit2/src/patch.c +1 -1
  98. data/vendor/libgit2/src/patch_generate.c +2 -2
  99. data/vendor/libgit2/src/patch_parse.c +4 -24
  100. data/vendor/libgit2/src/path.c +140 -39
  101. data/vendor/libgit2/src/path.h +84 -2
  102. data/vendor/libgit2/src/pathspec.c +1 -1
  103. data/vendor/libgit2/src/push.c +2 -2
  104. data/vendor/libgit2/src/rebase.c +23 -20
  105. data/vendor/libgit2/src/refdb_fs.c +34 -65
  106. data/vendor/libgit2/src/refs.c +16 -13
  107. data/vendor/libgit2/src/refspec.c +5 -30
  108. data/vendor/libgit2/src/refspec.h +1 -1
  109. data/vendor/libgit2/src/remote.c +43 -43
  110. data/vendor/libgit2/src/repository.c +56 -56
  111. data/vendor/libgit2/src/reset.c +1 -1
  112. data/vendor/libgit2/src/revert.c +3 -3
  113. data/vendor/libgit2/src/revparse.c +7 -6
  114. data/vendor/libgit2/src/revwalk.c +20 -48
  115. data/vendor/libgit2/src/revwalk.h +1 -2
  116. data/vendor/libgit2/src/settings.c +1 -25
  117. data/vendor/libgit2/src/signature.c +4 -2
  118. data/vendor/libgit2/src/stash.c +34 -80
  119. data/vendor/libgit2/src/status.c +1 -1
  120. data/vendor/libgit2/src/streams/curl.c +1 -1
  121. data/vendor/libgit2/src/streams/openssl.c +34 -132
  122. data/vendor/libgit2/src/streams/openssl.h +107 -0
  123. data/vendor/libgit2/src/streams/tls.c +0 -3
  124. data/vendor/libgit2/src/submodule.c +83 -118
  125. data/vendor/libgit2/src/sysdir.c +4 -4
  126. data/vendor/libgit2/src/tag.c +12 -12
  127. data/vendor/libgit2/src/trace.h +1 -1
  128. data/vendor/libgit2/src/trailer.c +6 -6
  129. data/vendor/libgit2/src/transport.c +2 -2
  130. data/vendor/libgit2/src/transports/auth.c +1 -1
  131. data/vendor/libgit2/src/transports/auth_negotiate.c +2 -2
  132. data/vendor/libgit2/src/transports/git.c +1 -1
  133. data/vendor/libgit2/src/transports/http.c +15 -12
  134. data/vendor/libgit2/src/transports/local.c +7 -7
  135. data/vendor/libgit2/src/transports/smart.c +15 -20
  136. data/vendor/libgit2/src/transports/smart.h +5 -5
  137. data/vendor/libgit2/src/transports/smart_pkt.c +131 -123
  138. data/vendor/libgit2/src/transports/smart_protocol.c +38 -48
  139. data/vendor/libgit2/src/transports/ssh.c +1 -1
  140. data/vendor/libgit2/src/transports/winhttp.c +26 -21
  141. data/vendor/libgit2/src/tree-cache.c +2 -2
  142. data/vendor/libgit2/src/tree.c +69 -23
  143. data/vendor/libgit2/src/tree.h +12 -0
  144. data/vendor/libgit2/src/util.c +99 -52
  145. data/vendor/libgit2/src/util.h +138 -14
  146. data/vendor/libgit2/src/vector.c +13 -8
  147. data/vendor/libgit2/src/win32/findfile.c +2 -2
  148. data/vendor/libgit2/src/win32/posix_w32.c +1 -1
  149. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -94
  150. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +75 -28
  151. data/vendor/libgit2/src/worktree.c +44 -65
  152. data/vendor/libgit2/src/worktree.h +0 -2
  153. data/vendor/libgit2/src/xdiff/xdiffi.c +1 -3
  154. metadata +5 -17
  155. data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +0 -93
  156. data/vendor/libgit2/include/git2/mailmap.h +0 -115
  157. data/vendor/libgit2/include/git2/sys/alloc.h +0 -101
  158. data/vendor/libgit2/include/git2/sys/path.h +0 -55
  159. data/vendor/libgit2/src/alloc.c +0 -47
  160. data/vendor/libgit2/src/alloc.h +0 -40
  161. data/vendor/libgit2/src/hash/hash_mbedtls.c +0 -38
  162. data/vendor/libgit2/src/hash/hash_mbedtls.h +0 -20
  163. data/vendor/libgit2/src/mailmap.c +0 -485
  164. data/vendor/libgit2/src/mailmap.h +0 -35
  165. data/vendor/libgit2/src/stdalloc.c +0 -120
  166. data/vendor/libgit2/src/stdalloc.h +0 -17
  167. data/vendor/libgit2/src/streams/mbedtls.c +0 -463
  168. data/vendor/libgit2/src/streams/mbedtls.h +0 -20
@@ -17,4 +17,111 @@ extern int git_openssl_stream_new(git_stream **out, const char *host, const char
17
17
 
18
18
  extern int git_openssl__set_cert_location(const char *file, const char *path);
19
19
 
20
+ /*
21
+ * OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it
22
+ * which do not exist in previous versions. We define these inline functions so
23
+ * we can program against the interface instead of littering the implementation
24
+ * with ifdefs.
25
+ */
26
+ #ifdef GIT_OPENSSL
27
+ # include <openssl/ssl.h>
28
+ # include <openssl/err.h>
29
+ # include <openssl/x509v3.h>
30
+ # include <openssl/bio.h>
31
+
32
+
33
+
34
+ # if OPENSSL_VERSION_NUMBER < 0x10100000L || \
35
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
36
+
37
+ GIT_INLINE(BIO_METHOD*) BIO_meth_new(int type, const char *name)
38
+ {
39
+ BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD));
40
+ if (!meth) {
41
+ return NULL;
42
+ }
43
+
44
+ meth->type = type;
45
+ meth->name = name;
46
+
47
+ return meth;
48
+ }
49
+
50
+ GIT_INLINE(void) BIO_meth_free(BIO_METHOD *biom)
51
+ {
52
+ git__free(biom);
53
+ }
54
+
55
+ GIT_INLINE(int) BIO_meth_set_write(BIO_METHOD *biom, int (*write) (BIO *, const char *, int))
56
+ {
57
+ biom->bwrite = write;
58
+ return 1;
59
+ }
60
+
61
+ GIT_INLINE(int) BIO_meth_set_read(BIO_METHOD *biom, int (*read) (BIO *, char *, int))
62
+ {
63
+ biom->bread = read;
64
+ return 1;
65
+ }
66
+
67
+ GIT_INLINE(int) BIO_meth_set_puts(BIO_METHOD *biom, int (*puts) (BIO *, const char *))
68
+ {
69
+ biom->bputs = puts;
70
+ return 1;
71
+ }
72
+
73
+ GIT_INLINE(int) BIO_meth_set_gets(BIO_METHOD *biom, int (*gets) (BIO *, char *, int))
74
+
75
+ {
76
+ biom->bgets = gets;
77
+ return 1;
78
+ }
79
+
80
+ GIT_INLINE(int) BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *))
81
+ {
82
+ biom->ctrl = ctrl;
83
+ return 1;
84
+ }
85
+
86
+ GIT_INLINE(int) BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *))
87
+ {
88
+ biom->create = create;
89
+ return 1;
90
+ }
91
+
92
+ GIT_INLINE(int) BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *))
93
+ {
94
+ biom->destroy = destroy;
95
+ return 1;
96
+ }
97
+
98
+ GIT_INLINE(int) BIO_get_new_index(void)
99
+ {
100
+ /* This exists as of 1.1 so before we'd just have 0 */
101
+ return 0;
102
+ }
103
+
104
+ GIT_INLINE(void) BIO_set_init(BIO *b, int init)
105
+ {
106
+ b->init = init;
107
+ }
108
+
109
+ GIT_INLINE(void) BIO_set_data(BIO *a, void *ptr)
110
+ {
111
+ a->ptr = ptr;
112
+ }
113
+
114
+ GIT_INLINE(void*) BIO_get_data(BIO *a)
115
+ {
116
+ return a->ptr;
117
+ }
118
+
119
+ GIT_INLINE(const unsigned char *) ASN1_STRING_get0_data(const ASN1_STRING *x)
120
+ {
121
+ return ASN1_STRING_data((ASN1_STRING *)x);
122
+ }
123
+
124
+ # endif // OpenSSL < 1.1
125
+ #endif // GIT_OPENSSL
126
+
20
127
  #endif
@@ -9,7 +9,6 @@
9
9
 
10
10
  #include "git2/errors.h"
11
11
 
12
- #include "streams/mbedtls.h"
13
12
  #include "streams/openssl.h"
14
13
  #include "streams/stransport.h"
15
14
 
@@ -32,8 +31,6 @@ int git_tls_stream_new(git_stream **out, const char *host, const char *port)
32
31
  return git_stransport_stream_new(out, host, port);
33
32
  #elif defined(GIT_OPENSSL)
34
33
  return git_openssl_stream_new(out, host, port);
35
- #elif defined(GIT_MBEDTLS)
36
- return git_mbedtls_stream_new(out, host, port);
37
34
  #else
38
35
  GIT_UNUSED(out);
39
36
  GIT_UNUSED(host);
@@ -149,66 +149,18 @@ static int find_by_path(const git_config_entry *entry, void *payload)
149
149
  return 0;
150
150
  }
151
151
 
152
- /*
153
- * Checks to see if the submodule shares its name with a file or directory that
154
- * already exists on the index. If so, the submodule cannot be added.
155
- */
156
- static int is_path_occupied(bool *occupied, git_repository *repo, const char *path)
157
- {
158
- int error = 0;
159
- git_index *index;
160
- git_buf dir = GIT_BUF_INIT;
161
- *occupied = false;
162
-
163
- if ((error = git_repository_index__weakptr(&index, repo)) < 0)
164
- goto out;
165
-
166
- if ((error = git_index_find(NULL, index, path)) != GIT_ENOTFOUND) {
167
- if (!error) {
168
- giterr_set(GITERR_SUBMODULE,
169
- "File '%s' already exists in the index", path);
170
- *occupied = true;
171
- }
172
- goto out;
173
- }
174
-
175
- if ((error = git_buf_sets(&dir, path)) < 0)
176
- goto out;
177
-
178
- if ((error = git_path_to_dir(&dir)) < 0)
179
- goto out;
180
-
181
- if ((error = git_index_find_prefix(NULL, index, dir.ptr)) != GIT_ENOTFOUND) {
182
- if (!error) {
183
- giterr_set(GITERR_SUBMODULE,
184
- "Directory '%s' already exists in the index", path);
185
- *occupied = true;
186
- }
187
- goto out;
188
- }
189
-
190
- error = 0;
191
-
192
- out:
193
- git_buf_dispose(&dir);
194
- return error;
195
- }
196
-
197
152
  /**
198
153
  * Release the name map returned by 'load_submodule_names'.
199
154
  */
200
155
  static void free_submodule_names(git_strmap *names)
201
156
  {
202
- git_buf *name;
203
-
157
+ git_buf *name = 0;
204
158
  if (names == NULL)
205
159
  return;
206
-
207
160
  git_strmap_foreach_value(names, name, {
208
161
  git__free(name);
209
162
  });
210
163
  git_strmap_free(names);
211
-
212
164
  return;
213
165
  }
214
166
 
@@ -217,30 +169,24 @@ static void free_submodule_names(git_strmap *names)
217
169
  * TODO: for some use-cases, this might need case-folding on a
218
170
  * case-insensitive filesystem
219
171
  */
220
- static int load_submodule_names(git_strmap **out, git_repository *repo, git_config *cfg)
172
+ static int load_submodule_names(git_strmap *out, git_repository *repo, git_config *cfg)
221
173
  {
222
174
  const char *key = "submodule\\..*\\.path";
223
- git_config_iterator *iter = NULL;
175
+ git_config_iterator *iter;
224
176
  git_config_entry *entry;
225
177
  git_buf buf = GIT_BUF_INIT;
226
- git_strmap *names;
227
178
  int rval, isvalid;
228
179
  int error = 0;
229
180
 
230
- *out = NULL;
231
-
232
- if ((error = git_strmap_alloc(&names)) < 0)
233
- goto out;
234
-
235
181
  if ((error = git_config_iterator_glob_new(&iter, cfg, key)) < 0)
236
- goto out;
182
+ return error;
237
183
 
238
- while (git_config_next(&entry, iter) == 0) {
184
+ while ((error = git_config_next(&entry, iter)) == 0) {
239
185
  const char *fdot, *ldot;
240
186
  fdot = strchr(entry->name, '.');
241
187
  ldot = strrchr(entry->name, '.');
242
188
 
243
- if (git_strmap_exists(names, entry->value)) {
189
+ if (git_strmap_exists(out, entry->value)) {
244
190
  giterr_set(GITERR_SUBMODULE,
245
191
  "duplicated submodule path '%s'", entry->value);
246
192
  error = -1;
@@ -257,7 +203,7 @@ static int load_submodule_names(git_strmap **out, git_repository *repo, git_conf
257
203
  if (!isvalid)
258
204
  continue;
259
205
 
260
- git_strmap_insert(names, entry->value, git_buf_detach(&buf), &rval);
206
+ git_strmap_insert(out, entry->value, git_buf_detach(&buf), &rval);
261
207
  if (rval < 0) {
262
208
  giterr_set(GITERR_NOMEMORY, "error inserting submodule into hash table");
263
209
  return -1;
@@ -266,12 +212,8 @@ static int load_submodule_names(git_strmap **out, git_repository *repo, git_conf
266
212
  if (error == GIT_ITEROVER)
267
213
  error = 0;
268
214
 
269
- *out = names;
270
- names = NULL;
271
-
272
215
  out:
273
- free_submodule_names(names);
274
- git_buf_dispose(&buf);
216
+ git_buf_free(&buf);
275
217
  git_config_iterator_free(iter);
276
218
  return error;
277
219
  }
@@ -338,7 +280,7 @@ int git_submodule_lookup(
338
280
 
339
281
  if (error < 0) {
340
282
  git_submodule_free(sm);
341
- git_buf_dispose(&path);
283
+ git_buf_free(&path);
342
284
  return error;
343
285
  }
344
286
 
@@ -354,7 +296,7 @@ int git_submodule_lookup(
354
296
  }
355
297
  }
356
298
 
357
- git_buf_dispose(&path);
299
+ git_buf_free(&path);
358
300
  }
359
301
 
360
302
  if ((error = git_submodule_location(&location, sm)) < 0) {
@@ -377,7 +319,7 @@ int git_submodule_lookup(
377
319
  if (git_path_exists(path.ptr))
378
320
  error = GIT_EEXISTS;
379
321
 
380
- git_buf_dispose(&path);
322
+ git_buf_free(&path);
381
323
  }
382
324
 
383
325
  submodule_set_lookup_error(error, name);
@@ -409,7 +351,7 @@ int git_submodule_name_is_valid(git_repository *repo, const char *name, int flag
409
351
  }
410
352
 
411
353
  isvalid = git_path_isvalid(repo, buf.ptr, 0, flags);
412
- git_buf_dispose(&buf);
354
+ git_buf_free(&buf);
413
355
 
414
356
  return isvalid;
415
357
  }
@@ -456,9 +398,10 @@ static int submodules_from_index(git_strmap *map, git_index *idx, git_config *cf
456
398
  int error;
457
399
  git_iterator *i = NULL;
458
400
  const git_index_entry *entry;
459
- git_strmap *names;
401
+ git_strmap *names = 0;
460
402
 
461
- if ((error = load_submodule_names(&names, git_index_owner(idx), cfg)))
403
+ git_strmap_alloc(&names);
404
+ if ((error = load_submodule_names(names, git_index_owner(idx), cfg)))
462
405
  goto done;
463
406
 
464
407
  if ((error = git_iterator_for_index(&i, git_index_owner(idx), idx, NULL)) < 0)
@@ -508,9 +451,9 @@ static int submodules_from_head(git_strmap *map, git_tree *head, git_config *cfg
508
451
  int error;
509
452
  git_iterator *i = NULL;
510
453
  const git_index_entry *entry;
511
- git_strmap *names;
512
-
513
- if ((error = load_submodule_names(&names, git_tree_owner(head), cfg)))
454
+ git_strmap *names = 0;
455
+ git_strmap_alloc(&names);
456
+ if ((error = load_submodule_names(names, git_tree_owner(head), cfg)))
514
457
  goto done;
515
458
 
516
459
  if ((error = git_iterator_for_tree(&i, head, NULL)) < 0)
@@ -572,6 +515,7 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
572
515
  git_buf path = GIT_BUF_INIT;
573
516
  git_submodule *sm;
574
517
  git_config *mods = NULL;
518
+ uint32_t mask;
575
519
 
576
520
  assert(repo && map);
577
521
 
@@ -585,6 +529,22 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
585
529
  if (wd && (error = git_buf_joinpath(&path, wd, GIT_MODULES_FILE)) < 0)
586
530
  goto cleanup;
587
531
 
532
+ /* clear submodule flags that are to be refreshed */
533
+ mask = 0;
534
+ mask |= GIT_SUBMODULE_STATUS_IN_INDEX |
535
+ GIT_SUBMODULE_STATUS__INDEX_FLAGS |
536
+ GIT_SUBMODULE_STATUS__INDEX_OID_VALID |
537
+ GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES;
538
+
539
+ mask |= GIT_SUBMODULE_STATUS_IN_HEAD |
540
+ GIT_SUBMODULE_STATUS__HEAD_OID_VALID;
541
+ mask |= GIT_SUBMODULE_STATUS_IN_CONFIG;
542
+ if (mask != 0)
543
+ mask |= GIT_SUBMODULE_STATUS_IN_WD |
544
+ GIT_SUBMODULE_STATUS__WD_SCANNED |
545
+ GIT_SUBMODULE_STATUS__WD_FLAGS |
546
+ GIT_SUBMODULE_STATUS__WD_OID_VALID;
547
+
588
548
  /* add submodule information from .gitmodules */
589
549
  if (wd) {
590
550
  lfc_data data = { 0 };
@@ -613,7 +573,7 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
613
573
  goto cleanup;
614
574
  }
615
575
  /* shallow scan submodules in work tree as needed */
616
- if (wd) {
576
+ if (wd && mask != 0) {
617
577
  git_strmap_foreach_value(map, sm, {
618
578
  submodule_load_from_wd_lite(sm);
619
579
  });
@@ -624,7 +584,7 @@ cleanup:
624
584
  /* TODO: if we got an error, mark submodule config as invalid? */
625
585
  git_index_free(idx);
626
586
  git_tree_free(head);
627
- git_buf_dispose(&path);
587
+ git_buf_free(&path);
628
588
  return error;
629
589
  }
630
590
 
@@ -729,8 +689,8 @@ static int submodule_repo_init(
729
689
  error = git_repository_init_ext(&subrepo, workdir.ptr, &initopt);
730
690
 
731
691
  cleanup:
732
- git_buf_dispose(&workdir);
733
- git_buf_dispose(&repodir);
692
+ git_buf_free(&workdir);
693
+ git_buf_free(&repodir);
734
694
 
735
695
  *out = subrepo;
736
696
 
@@ -749,7 +709,6 @@ int git_submodule_add_setup(
749
709
  git_submodule *sm = NULL;
750
710
  git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT;
751
711
  git_repository *subrepo = NULL;
752
- bool path_occupied;
753
712
 
754
713
  assert(repo && url && path);
755
714
 
@@ -774,14 +733,6 @@ int git_submodule_add_setup(
774
733
  goto cleanup;
775
734
  }
776
735
 
777
- if ((error = is_path_occupied(&path_occupied, repo, path)) < 0)
778
- goto cleanup;
779
-
780
- if (path_occupied) {
781
- error = GIT_EEXISTS;
782
- goto cleanup;
783
- }
784
-
785
736
  /* update .gitmodules */
786
737
 
787
738
  if (!(mods = open_gitmodules(repo, GITMODULES_CREATE))) {
@@ -835,8 +786,8 @@ cleanup:
835
786
 
836
787
  git_config_file_free(mods);
837
788
  git_repository_free(subrepo);
838
- git_buf_dispose(&real_url);
839
- git_buf_dispose(&name);
789
+ git_buf_free(&real_url);
790
+ git_buf_free(&name);
840
791
 
841
792
  return error;
842
793
  }
@@ -865,7 +816,7 @@ int git_submodule_repo_init(
865
816
 
866
817
  done:
867
818
  git_config_free(cfg);
868
- git_buf_dispose(&buf);
819
+ git_buf_free(&buf);
869
820
  return error;
870
821
  }
871
822
 
@@ -949,7 +900,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
949
900
 
950
901
  cleanup:
951
902
  git_repository_free(sm_repo);
952
- git_buf_dispose(&path);
903
+ git_buf_free(&path);
953
904
  return error;
954
905
  }
955
906
 
@@ -1014,7 +965,7 @@ int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *ur
1014
965
  error = -1;
1015
966
  }
1016
967
 
1017
- git_buf_dispose(&normalized);
968
+ git_buf_free(&normalized);
1018
969
  return error;
1019
970
  }
1020
971
 
@@ -1036,7 +987,7 @@ static int write_var(git_repository *repo, const char *name, const char *var, co
1036
987
  else
1037
988
  error = git_config_file_delete(mods, key.ptr);
1038
989
 
1039
- git_buf_dispose(&key);
990
+ git_buf_free(&key);
1040
991
 
1041
992
  cleanup:
1042
993
  git_config_file_free(mods);
@@ -1201,8 +1152,8 @@ static int submodule_repo_create(
1201
1152
  error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt);
1202
1153
 
1203
1154
  cleanup:
1204
- git_buf_dispose(&workdir);
1205
- git_buf_dispose(&repodir);
1155
+ git_buf_free(&workdir);
1156
+ git_buf_free(&repodir);
1206
1157
 
1207
1158
  *out = subrepo;
1208
1159
 
@@ -1355,7 +1306,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
1355
1306
  }
1356
1307
 
1357
1308
  done:
1358
- git_buf_dispose(&buf);
1309
+ git_buf_free(&buf);
1359
1310
  git_config_free(config);
1360
1311
  git_object_free(target_commit);
1361
1312
  git_remote_free(remote);
@@ -1402,8 +1353,8 @@ int git_submodule_init(git_submodule *sm, int overwrite)
1402
1353
 
1403
1354
  cleanup:
1404
1355
  git_config_free(cfg);
1405
- git_buf_dispose(&key);
1406
- git_buf_dispose(&effective_submodule_url);
1356
+ git_buf_free(&key);
1357
+ git_buf_free(&effective_submodule_url);
1407
1358
 
1408
1359
  return error;
1409
1360
  }
@@ -1443,7 +1394,7 @@ int git_submodule_sync(git_submodule *sm)
1443
1394
  } else {
1444
1395
  error = git_buf_join3(
1445
1396
  &key, '.', "remote", remote_name.ptr, "url");
1446
- git_buf_dispose(&remote_name);
1397
+ git_buf_free(&remote_name);
1447
1398
  }
1448
1399
 
1449
1400
  if (!error)
@@ -1452,7 +1403,7 @@ int git_submodule_sync(git_submodule *sm)
1452
1403
  git_repository_free(smrepo);
1453
1404
  }
1454
1405
 
1455
- git_buf_dispose(&key);
1406
+ git_buf_free(&key);
1456
1407
 
1457
1408
  return error;
1458
1409
  }
@@ -1506,7 +1457,7 @@ static int git_submodule__open(
1506
1457
  sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED;
1507
1458
  }
1508
1459
 
1509
- git_buf_dispose(&path);
1460
+ git_buf_free(&path);
1510
1461
 
1511
1462
  return error;
1512
1463
  }
@@ -1862,6 +1813,14 @@ static int get_value(const char **out, git_config *cfg, git_buf *buf, const char
1862
1813
  return error;
1863
1814
  }
1864
1815
 
1816
+ static bool looks_like_command_line_option(const char *s)
1817
+ {
1818
+ if (s && s[0] == '-')
1819
+ return true;
1820
+
1821
+ return false;
1822
+ }
1823
+
1865
1824
  static int submodule_read_config(git_submodule *sm, git_config *cfg)
1866
1825
  {
1867
1826
  git_buf key = GIT_BUF_INIT;
@@ -1875,24 +1834,31 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
1875
1834
 
1876
1835
  if ((error = get_value(&value, cfg, &key, sm->name, "path")) == 0) {
1877
1836
  in_config = 1;
1837
+ /* We would warn here if we had that API */
1838
+ if (!looks_like_command_line_option(value)) {
1878
1839
  /*
1879
1840
  * TODO: if case insensitive filesystem, then the following strcmp
1880
1841
  * should be strcasecmp
1881
1842
  */
1882
- if (strcmp(sm->name, value) != 0) {
1883
- if (sm->path != sm->name)
1884
- git__free(sm->path);
1885
- sm->path = git__strdup(value);
1886
- GITERR_CHECK_ALLOC(sm->path);
1843
+ if (strcmp(sm->name, value) != 0) {
1844
+ if (sm->path != sm->name)
1845
+ git__free(sm->path);
1846
+ sm->path = git__strdup(value);
1847
+ GITERR_CHECK_ALLOC(sm->path);
1848
+ }
1849
+
1887
1850
  }
1888
1851
  } else if (error != GIT_ENOTFOUND) {
1889
1852
  goto cleanup;
1890
1853
  }
1891
1854
 
1892
1855
  if ((error = get_value(&value, cfg, &key, sm->name, "url")) == 0) {
1893
- in_config = 1;
1894
- sm->url = git__strdup(value);
1895
- GITERR_CHECK_ALLOC(sm->url);
1856
+ /* We would warn here if we had that API */
1857
+ if (!looks_like_command_line_option(value)) {
1858
+ in_config = 1;
1859
+ sm->url = git__strdup(value);
1860
+ GITERR_CHECK_ALLOC(sm->url);
1861
+ }
1896
1862
  } else if (error != GIT_ENOTFOUND) {
1897
1863
  goto cleanup;
1898
1864
  }
@@ -1938,7 +1904,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
1938
1904
  error = 0;
1939
1905
 
1940
1906
  cleanup:
1941
- git_buf_dispose(&key);
1907
+ git_buf_free(&key);
1942
1908
  return error;
1943
1909
  }
1944
1910
 
@@ -2000,7 +1966,7 @@ static int submodule_load_each(const git_config_entry *entry, void *payload)
2000
1966
  error = 0;
2001
1967
 
2002
1968
  done:
2003
- git_buf_dispose(&name);
1969
+ git_buf_free(&name);
2004
1970
  return error;
2005
1971
  }
2006
1972
 
@@ -2017,7 +1983,7 @@ static int submodule_load_from_wd_lite(git_submodule *sm)
2017
1983
  if (git_path_contains(&path, DOT_GIT))
2018
1984
  sm->flags |= GIT_SUBMODULE_STATUS_IN_WD;
2019
1985
 
2020
- git_buf_dispose(&path);
1986
+ git_buf_free(&path);
2021
1987
  return 0;
2022
1988
  }
2023
1989
 
@@ -2041,7 +2007,6 @@ static int gitmodules_snapshot(git_config **snap, git_repository *repo)
2041
2007
 
2042
2008
  if ((error = git_config_open_ondisk(&mods, path.ptr)) < 0)
2043
2009
  goto cleanup;
2044
- git_buf_dispose(&path);
2045
2010
 
2046
2011
  if ((error = git_config_snapshot(snap, mods)) < 0)
2047
2012
  goto cleanup;
@@ -2051,7 +2016,7 @@ static int gitmodules_snapshot(git_config **snap, git_repository *repo)
2051
2016
  cleanup:
2052
2017
  if (mods)
2053
2018
  git_config_free(mods);
2054
- git_buf_dispose(&path);
2019
+ git_buf_free(&path);
2055
2020
 
2056
2021
  return error;
2057
2022
  }
@@ -2080,7 +2045,7 @@ static git_config_backend *open_gitmodules(
2080
2045
  }
2081
2046
  }
2082
2047
 
2083
- git_buf_dispose(&path);
2048
+ git_buf_free(&path);
2084
2049
 
2085
2050
  return mods;
2086
2051
  }
@@ -2120,7 +2085,7 @@ static int lookup_head_remote_key(git_buf *remote_name, git_repository *repo)
2120
2085
  goto done;
2121
2086
 
2122
2087
  done:
2123
- git_buf_dispose(&upstream_name);
2088
+ git_buf_free(&upstream_name);
2124
2089
  git_reference_free(head);
2125
2090
 
2126
2091
  return error;
@@ -2136,7 +2101,7 @@ static int lookup_head_remote(git_remote **remote, git_repository *repo)
2136
2101
  if (!(error = lookup_head_remote_key(&remote_name, repo)))
2137
2102
  error = git_remote_lookup(remote, repo, remote_name.ptr);
2138
2103
 
2139
- git_buf_dispose(&remote_name);
2104
+ git_buf_free(&remote_name);
2140
2105
 
2141
2106
  return error;
2142
2107
  }