rugged 0.21.4 → 0.22.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -5
  3. data/ext/rugged/extconf.rb +9 -9
  4. data/ext/rugged/rugged.c +4 -2
  5. data/ext/rugged/rugged.h +3 -7
  6. data/ext/rugged/rugged_blob.c +57 -0
  7. data/ext/rugged/rugged_cred.c +23 -0
  8. data/ext/rugged/rugged_index.c +6 -2
  9. data/ext/rugged/rugged_remote.c +65 -52
  10. data/ext/rugged/rugged_remote_collection.c +59 -10
  11. data/ext/rugged/rugged_repo.c +345 -11
  12. data/ext/rugged/rugged_revwalk.c +10 -0
  13. data/ext/rugged/rugged_submodule.c +1042 -0
  14. data/ext/rugged/rugged_submodule_collection.c +236 -0
  15. data/ext/rugged/rugged_tag_collection.c +70 -2
  16. data/ext/rugged/rugged_tree.c +29 -10
  17. data/lib/rugged.rb +3 -0
  18. data/lib/rugged/attributes.rb +41 -0
  19. data/lib/rugged/blob.rb +28 -0
  20. data/lib/rugged/diff.rb +0 -1
  21. data/lib/rugged/diff/line.rb +1 -3
  22. data/lib/rugged/patch.rb +12 -2
  23. data/lib/rugged/repository.rb +7 -0
  24. data/lib/rugged/submodule_collection.rb +48 -0
  25. data/lib/rugged/version.rb +1 -1
  26. data/vendor/libgit2/CMakeLists.txt +27 -3
  27. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +324 -0
  28. data/vendor/libgit2/deps/http-parser/http_parser.h +2 -0
  29. data/vendor/libgit2/deps/zlib/adler32.c +39 -29
  30. data/vendor/libgit2/deps/zlib/crc32.c +33 -50
  31. data/vendor/libgit2/deps/zlib/crc32.h +1 -1
  32. data/vendor/libgit2/deps/zlib/deflate.c +198 -65
  33. data/vendor/libgit2/deps/zlib/deflate.h +8 -4
  34. data/vendor/libgit2/deps/zlib/infback.c +640 -0
  35. data/vendor/libgit2/deps/zlib/inffast.c +3 -3
  36. data/vendor/libgit2/deps/zlib/inffixed.h +3 -3
  37. data/vendor/libgit2/deps/zlib/inflate.c +84 -52
  38. data/vendor/libgit2/deps/zlib/inftrees.c +15 -39
  39. data/vendor/libgit2/deps/zlib/trees.c +18 -36
  40. data/vendor/libgit2/deps/zlib/zconf.h +4 -0
  41. data/vendor/libgit2/deps/zlib/zlib.h +250 -95
  42. data/vendor/libgit2/deps/zlib/zutil.c +13 -10
  43. data/vendor/libgit2/deps/zlib/zutil.h +41 -62
  44. data/vendor/libgit2/include/git2.h +4 -0
  45. data/vendor/libgit2/include/git2/annotated_commit.h +99 -0
  46. data/vendor/libgit2/include/git2/attr.h +16 -13
  47. data/vendor/libgit2/include/git2/branch.h +11 -0
  48. data/vendor/libgit2/include/git2/buffer.h +16 -0
  49. data/vendor/libgit2/include/git2/checkout.h +12 -12
  50. data/vendor/libgit2/include/git2/cherrypick.h +15 -15
  51. data/vendor/libgit2/include/git2/clone.h +77 -69
  52. data/vendor/libgit2/include/git2/common.h +13 -1
  53. data/vendor/libgit2/include/git2/config.h +0 -14
  54. data/vendor/libgit2/include/git2/describe.h +162 -0
  55. data/vendor/libgit2/include/git2/diff.h +13 -8
  56. data/vendor/libgit2/include/git2/errors.h +5 -0
  57. data/vendor/libgit2/include/git2/global.h +38 -0
  58. data/vendor/libgit2/include/git2/merge.h +38 -64
  59. data/vendor/libgit2/include/git2/net.h +2 -2
  60. data/vendor/libgit2/include/git2/notes.h +17 -0
  61. data/vendor/libgit2/include/git2/oid.h +8 -4
  62. data/vendor/libgit2/include/git2/oidarray.h +40 -0
  63. data/vendor/libgit2/include/git2/rebase.h +261 -0
  64. data/vendor/libgit2/include/git2/reflog.h +1 -1
  65. data/vendor/libgit2/include/git2/remote.h +25 -47
  66. data/vendor/libgit2/include/git2/repository.h +4 -1
  67. data/vendor/libgit2/include/git2/reset.h +10 -1
  68. data/vendor/libgit2/include/git2/revert.h +1 -1
  69. data/vendor/libgit2/include/git2/revwalk.h +28 -23
  70. data/vendor/libgit2/include/git2/status.h +19 -15
  71. data/vendor/libgit2/include/git2/submodule.h +18 -0
  72. data/vendor/libgit2/include/git2/sys/config.h +0 -1
  73. data/vendor/libgit2/{src → include/git2/sys}/hashsig.h +11 -7
  74. data/vendor/libgit2/include/git2/sys/refdb_backend.h +13 -0
  75. data/vendor/libgit2/include/git2/sys/refs.h +0 -11
  76. data/vendor/libgit2/include/git2/sys/repository.h +13 -0
  77. data/vendor/libgit2/include/git2/sys/transport.h +352 -0
  78. data/vendor/libgit2/include/git2/threads.h +10 -20
  79. data/vendor/libgit2/include/git2/transaction.h +111 -0
  80. data/vendor/libgit2/include/git2/transport.h +79 -313
  81. data/vendor/libgit2/include/git2/tree.h +4 -2
  82. data/vendor/libgit2/include/git2/types.h +77 -8
  83. data/vendor/libgit2/include/git2/version.h +2 -2
  84. data/vendor/libgit2/src/annotated_commit.c +121 -0
  85. data/vendor/libgit2/src/annotated_commit.h +22 -0
  86. data/vendor/libgit2/src/attr.c +8 -4
  87. data/vendor/libgit2/src/attr_file.c +24 -2
  88. data/vendor/libgit2/src/blame.c +0 -1
  89. data/vendor/libgit2/src/branch.c +32 -3
  90. data/vendor/libgit2/src/buf_text.c +9 -5
  91. data/vendor/libgit2/src/buf_text.h +3 -2
  92. data/vendor/libgit2/src/buffer.c +67 -10
  93. data/vendor/libgit2/src/buffer.h +4 -2
  94. data/vendor/libgit2/src/cache.c +9 -9
  95. data/vendor/libgit2/src/cache.h +1 -1
  96. data/vendor/libgit2/src/cc-compat.h +2 -0
  97. data/vendor/libgit2/src/checkout.c +263 -82
  98. data/vendor/libgit2/src/checkout.h +1 -0
  99. data/vendor/libgit2/src/cherrypick.c +41 -44
  100. data/vendor/libgit2/src/clone.c +96 -58
  101. data/vendor/libgit2/src/commit.c +5 -31
  102. data/vendor/libgit2/src/commit_list.h +3 -1
  103. data/vendor/libgit2/src/config.c +0 -17
  104. data/vendor/libgit2/src/config_cache.c +0 -2
  105. data/vendor/libgit2/src/config_file.c +12 -15
  106. data/vendor/libgit2/src/crlf.c +2 -1
  107. data/vendor/libgit2/src/describe.c +886 -0
  108. data/vendor/libgit2/src/diff.c +29 -3
  109. data/vendor/libgit2/src/diff_file.c +1 -0
  110. data/vendor/libgit2/src/diff_patch.c +2 -3
  111. data/vendor/libgit2/src/diff_print.c +11 -9
  112. data/vendor/libgit2/src/diff_tform.c +4 -4
  113. data/vendor/libgit2/src/errors.c +9 -7
  114. data/vendor/libgit2/src/fetch.c +6 -6
  115. data/vendor/libgit2/src/fetchhead.h +2 -4
  116. data/vendor/libgit2/src/filebuf.c +0 -2
  117. data/vendor/libgit2/src/filebuf.h +2 -3
  118. data/vendor/libgit2/src/fileops.c +9 -7
  119. data/vendor/libgit2/src/global.c +44 -35
  120. data/vendor/libgit2/src/global.h +2 -0
  121. data/vendor/libgit2/src/graph.c +2 -2
  122. data/vendor/libgit2/src/hash.h +3 -1
  123. data/vendor/libgit2/src/hash/hash_common_crypto.h +44 -0
  124. data/vendor/libgit2/src/hash/hash_win32.c +1 -1
  125. data/vendor/libgit2/src/hashsig.c +1 -1
  126. data/vendor/libgit2/src/ignore.c +5 -88
  127. data/vendor/libgit2/src/index.c +70 -57
  128. data/vendor/libgit2/src/index.h +1 -0
  129. data/vendor/libgit2/src/indexer.c +16 -5
  130. data/vendor/libgit2/src/iterator.c +70 -1
  131. data/vendor/libgit2/src/iterator.h +5 -1
  132. data/vendor/libgit2/src/map.h +0 -1
  133. data/vendor/libgit2/src/merge.c +203 -327
  134. data/vendor/libgit2/src/merge.h +3 -13
  135. data/vendor/libgit2/src/mwindow.c +119 -8
  136. data/vendor/libgit2/src/mwindow.h +9 -1
  137. data/vendor/libgit2/src/netops.c +7 -8
  138. data/vendor/libgit2/src/netops.h +6 -16
  139. data/vendor/libgit2/src/notes.c +31 -4
  140. data/vendor/libgit2/src/notes.h +3 -0
  141. data/vendor/libgit2/src/odb.c +23 -1
  142. data/vendor/libgit2/src/odb_loose.c +1 -1
  143. data/vendor/libgit2/src/odb_pack.c +6 -3
  144. data/vendor/libgit2/src/oid.c +9 -1
  145. data/vendor/libgit2/src/oid.h +11 -0
  146. data/vendor/libgit2/src/oidarray.c +21 -0
  147. data/vendor/libgit2/src/oidarray.h +18 -0
  148. data/vendor/libgit2/src/oidmap.h +16 -0
  149. data/vendor/libgit2/src/pack.c +20 -7
  150. data/vendor/libgit2/src/pack.h +3 -0
  151. data/vendor/libgit2/src/path.c +120 -293
  152. data/vendor/libgit2/src/path.h +21 -44
  153. data/vendor/libgit2/src/pathspec.c +1 -1
  154. data/vendor/libgit2/src/pool.c +5 -11
  155. data/vendor/libgit2/src/pool.h +0 -2
  156. data/vendor/libgit2/src/posix.c +6 -6
  157. data/vendor/libgit2/src/posix.h +48 -28
  158. data/vendor/libgit2/src/push.c +19 -48
  159. data/vendor/libgit2/src/push.h +2 -4
  160. data/vendor/libgit2/src/rebase.c +1125 -0
  161. data/vendor/libgit2/src/refdb.c +19 -0
  162. data/vendor/libgit2/src/refdb.h +2 -1
  163. data/vendor/libgit2/src/refdb_fs.c +101 -29
  164. data/vendor/libgit2/src/reflog.c +1 -1
  165. data/vendor/libgit2/src/refs.c +38 -3
  166. data/vendor/libgit2/src/refs.h +13 -2
  167. data/vendor/libgit2/src/refspec.c +20 -2
  168. data/vendor/libgit2/src/remote.c +288 -154
  169. data/vendor/libgit2/src/remote.h +5 -1
  170. data/vendor/libgit2/src/repository.c +75 -36
  171. data/vendor/libgit2/src/repository.h +3 -25
  172. data/vendor/libgit2/src/reset.c +5 -1
  173. data/vendor/libgit2/src/revert.c +4 -6
  174. data/vendor/libgit2/src/revparse.c +15 -18
  175. data/vendor/libgit2/src/revwalk.c +96 -22
  176. data/vendor/libgit2/src/revwalk.h +5 -4
  177. data/vendor/libgit2/src/settings.c +22 -0
  178. data/vendor/libgit2/src/signature.c +37 -2
  179. data/vendor/libgit2/src/signature.h +3 -0
  180. data/vendor/libgit2/src/stash.c +17 -12
  181. data/vendor/libgit2/src/status.c +13 -3
  182. data/vendor/libgit2/src/strnlen.h +2 -1
  183. data/vendor/libgit2/src/submodule.c +75 -35
  184. data/vendor/libgit2/src/thread-utils.h +4 -9
  185. data/vendor/libgit2/src/trace.h +9 -1
  186. data/vendor/libgit2/src/transaction.c +352 -0
  187. data/vendor/libgit2/src/transport.c +91 -97
  188. data/vendor/libgit2/src/transports/auth.c +71 -0
  189. data/vendor/libgit2/src/transports/auth.h +63 -0
  190. data/vendor/libgit2/src/transports/auth_negotiate.c +275 -0
  191. data/vendor/libgit2/src/transports/auth_negotiate.h +27 -0
  192. data/vendor/libgit2/src/transports/cred.c +58 -0
  193. data/vendor/libgit2/src/transports/cred.h +14 -0
  194. data/vendor/libgit2/src/transports/cred_helpers.c +3 -0
  195. data/vendor/libgit2/src/transports/git.c +1 -0
  196. data/vendor/libgit2/src/transports/http.c +208 -82
  197. data/vendor/libgit2/src/transports/local.c +2 -2
  198. data/vendor/libgit2/src/transports/smart.c +2 -0
  199. data/vendor/libgit2/src/transports/smart.h +2 -0
  200. data/vendor/libgit2/src/transports/smart_protocol.c +10 -10
  201. data/vendor/libgit2/src/transports/ssh.c +243 -57
  202. data/vendor/libgit2/src/transports/winhttp.c +139 -35
  203. data/vendor/libgit2/src/tree-cache.c +118 -31
  204. data/vendor/libgit2/src/tree-cache.h +12 -7
  205. data/vendor/libgit2/src/tree.c +83 -64
  206. data/vendor/libgit2/src/tree.h +2 -3
  207. data/vendor/libgit2/src/unix/map.c +8 -2
  208. data/vendor/libgit2/src/unix/posix.h +23 -9
  209. data/vendor/libgit2/src/unix/realpath.c +8 -7
  210. data/vendor/libgit2/src/userdiff.h +3 -3
  211. data/vendor/libgit2/src/util.c +2 -92
  212. data/vendor/libgit2/src/util.h +3 -15
  213. data/vendor/libgit2/src/win32/findfile.c +0 -1
  214. data/vendor/libgit2/src/win32/map.c +3 -2
  215. data/vendor/libgit2/src/win32/mingw-compat.h +5 -12
  216. data/vendor/libgit2/src/win32/msvc-compat.h +3 -32
  217. data/vendor/libgit2/src/win32/posix.h +20 -32
  218. data/vendor/libgit2/src/win32/posix_w32.c +103 -31
  219. data/vendor/libgit2/src/win32/utf-conv.c +6 -36
  220. data/vendor/libgit2/src/win32/utf-conv.h +39 -0
  221. data/vendor/libgit2/src/win32/w32_util.h +0 -1
  222. metadata +32 -7
  223. data/vendor/libgit2/src/win32/path_w32.c +0 -305
  224. data/vendor/libgit2/src/win32/path_w32.h +0 -82
@@ -32,12 +32,13 @@ struct git_revwalk {
32
32
  int (*enqueue)(git_revwalk *, git_commit_list_node *);
33
33
 
34
34
  unsigned walking:1,
35
- first_parent: 1;
35
+ first_parent: 1,
36
+ did_hide: 1,
37
+ did_push: 1;
36
38
  unsigned int sorting;
37
39
 
38
- /* merge base calculation */
39
- git_commit_list_node *one;
40
- git_vector twos;
40
+ /* the pushes and hides */
41
+ git_commit_list *user_input;
41
42
 
42
43
  /* hide callback */
43
44
  git_revwalk_hide_cb hide_cb;
@@ -5,10 +5,15 @@
5
5
  * a Linking Exception. For full terms see the included COPYING file.
6
6
  */
7
7
 
8
+ #ifdef GIT_SSL
9
+ # include <openssl/err.h>
10
+ #endif
11
+
8
12
  #include <git2.h>
9
13
  #include "common.h"
10
14
  #include "sysdir.h"
11
15
  #include "cache.h"
16
+ #include "global.h"
12
17
 
13
18
  void git_libgit2_version(int *major, int *minor, int *rev)
14
19
  {
@@ -131,6 +136,23 @@ int git_libgit2_opts(int key, ...)
131
136
  case GIT_OPT_SET_TEMPLATE_PATH:
132
137
  error = git_sysdir_set(GIT_SYSDIR_TEMPLATE, va_arg(ap, const char *));
133
138
  break;
139
+
140
+ case GIT_OPT_SET_SSL_CERT_LOCATIONS:
141
+ #ifdef GIT_SSL
142
+ {
143
+ const char *file = va_arg(ap, const char *);
144
+ const char *path = va_arg(ap, const char *);
145
+ if (!SSL_CTX_load_verify_locations(git__ssl_ctx, file, path)) {
146
+ giterr_set(GITERR_NET, "SSL error: %s",
147
+ ERR_error_string(ERR_get_error(), NULL));
148
+ error = -1;
149
+ }
150
+ }
151
+ #else
152
+ giterr_set(GITERR_NET, "Cannot set certificate locations: OpenSSL is not enabled");
153
+ error = -1;
154
+ #endif
155
+ break;
134
156
  }
135
157
 
136
158
  va_end(ap);
@@ -70,9 +70,9 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
70
70
  if (p->name == NULL || p->email == NULL)
71
71
  return -1; /* oom */
72
72
 
73
- if (p->name[0] == '\0') {
73
+ if (p->name[0] == '\0' || p->email[0] == '\0') {
74
74
  git_signature_free(p);
75
- return signature_error("Signature cannot have an empty name");
75
+ return signature_error("Signature cannot have an empty name or email");
76
76
  }
77
77
 
78
78
  p->when.time = time;
@@ -106,6 +106,30 @@ int git_signature_dup(git_signature **dest, const git_signature *source)
106
106
  return 0;
107
107
  }
108
108
 
109
+ int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool)
110
+ {
111
+ git_signature *signature;
112
+
113
+ if (source == NULL)
114
+ return 0;
115
+
116
+ signature = git_pool_mallocz(pool, sizeof(git_signature));
117
+ GITERR_CHECK_ALLOC(signature);
118
+
119
+ signature->name = git_pool_strdup(pool, source->name);
120
+ GITERR_CHECK_ALLOC(signature->name);
121
+
122
+ signature->email = git_pool_strdup(pool, source->email);
123
+ GITERR_CHECK_ALLOC(signature->email);
124
+
125
+ signature->when.time = source->when.time;
126
+ signature->when.offset = source->when.offset;
127
+
128
+ *dest = signature;
129
+
130
+ return 0;
131
+ }
132
+
109
133
  int git_signature_now(git_signature **sig_out, const char *name, const char *email)
110
134
  {
111
135
  time_t now;
@@ -246,3 +270,14 @@ void git_signature__writebuf(git_buf *buf, const char *header, const git_signatu
246
270
  (unsigned)sig->when.time, sign, hours, mins);
247
271
  }
248
272
 
273
+ bool git_signature__equal(const git_signature *one, const git_signature *two)
274
+ {
275
+ assert(one && two);
276
+
277
+ return
278
+ git__strcmp(one->name, two->name) == 0 &&
279
+ git__strcmp(one->email, two->email) == 0 &&
280
+ one->when.time == two->when.time &&
281
+ one->when.offset == two->when.offset;
282
+ }
283
+
@@ -14,5 +14,8 @@
14
14
 
15
15
  int git_signature__parse(git_signature *sig, const char **buffer_out, const char *buffer_end, const char *header, char ender);
16
16
  void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig);
17
+ bool git_signature__equal(const git_signature *one, const git_signature *two);
18
+
19
+ int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool);
17
20
 
18
21
  #endif
@@ -15,6 +15,7 @@
15
15
  #include "git2/status.h"
16
16
  #include "git2/checkout.h"
17
17
  #include "git2/index.h"
18
+ #include "git2/transaction.h"
18
19
  #include "signature.h"
19
20
 
20
21
  static int create_error(int error, const char *msg)
@@ -601,14 +602,21 @@ int git_stash_drop(
601
602
  git_repository *repo,
602
603
  size_t index)
603
604
  {
604
- git_reference *stash;
605
+ git_transaction *tx;
606
+ git_reference *stash = NULL;
605
607
  git_reflog *reflog = NULL;
606
608
  size_t max;
607
609
  int error;
608
610
 
609
- if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
611
+ if ((error = git_transaction_new(&tx, repo)) < 0)
610
612
  return error;
611
613
 
614
+ if ((error = git_transaction_lock_ref(tx, GIT_REFS_STASH_FILE)) < 0)
615
+ goto cleanup;
616
+
617
+ if ((error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE)) < 0)
618
+ goto cleanup;
619
+
612
620
  if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE)) < 0)
613
621
  goto cleanup;
614
622
 
@@ -623,28 +631,25 @@ int git_stash_drop(
623
631
  if ((error = git_reflog_drop(reflog, index, true)) < 0)
624
632
  goto cleanup;
625
633
 
626
- if ((error = git_reflog_write(reflog)) < 0)
634
+ if ((error = git_transaction_set_reflog(tx, GIT_REFS_STASH_FILE, reflog)) < 0)
627
635
  goto cleanup;
628
636
 
629
637
  if (max == 1) {
630
- error = git_reference_delete(stash);
631
- git_reference_free(stash);
632
- stash = NULL;
638
+ if ((error = git_transaction_remove(tx, GIT_REFS_STASH_FILE)) < 0)
639
+ goto cleanup;
633
640
  } else if (index == 0) {
634
641
  const git_reflog_entry *entry;
635
642
 
636
643
  entry = git_reflog_entry_byindex(reflog, 0);
637
-
638
- git_reference_free(stash);
639
- if ((error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, &entry->oid_cur, 1, NULL, NULL) < 0))
644
+ if ((error = git_transaction_set_target(tx, GIT_REFS_STASH_FILE, &entry->oid_cur, NULL, NULL)) < 0)
640
645
  goto cleanup;
641
-
642
- /* We need to undo the writing that we just did */
643
- error = git_reflog_write(reflog);
644
646
  }
645
647
 
648
+ error = git_transaction_commit(tx);
649
+
646
650
  cleanup:
647
651
  git_reference_free(stash);
652
+ git_transaction_free(tx);
648
653
  git_reflog_free(reflog);
649
654
  return error;
650
655
  }
@@ -62,6 +62,9 @@ static unsigned int workdir_delta2status(
62
62
  case GIT_DELTA_UNTRACKED:
63
63
  st = GIT_STATUS_WT_NEW;
64
64
  break;
65
+ case GIT_DELTA_UNREADABLE:
66
+ st = GIT_STATUS_WT_UNREADABLE;
67
+ break;
65
68
  case GIT_DELTA_DELETED:
66
69
  st = GIT_STATUS_WT_DELETED;
67
70
  break;
@@ -310,6 +313,10 @@ int git_status_list_new(
310
313
  diffopt.flags = diffopt.flags | GIT_DIFF_IGNORE_SUBMODULES;
311
314
  if ((flags & GIT_STATUS_OPT_UPDATE_INDEX) != 0)
312
315
  diffopt.flags = diffopt.flags | GIT_DIFF_UPDATE_INDEX;
316
+ if ((flags & GIT_STATUS_OPT_INCLUDE_UNREADABLE) != 0)
317
+ diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNREADABLE;
318
+ if ((flags & GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED) != 0)
319
+ diffopt.flags = diffopt.flags | GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED;
313
320
 
314
321
  if ((flags & GIT_STATUS_OPT_RENAMES_FROM_REWRITES) != 0)
315
322
  findopt.flags = findopt.flags |
@@ -329,8 +336,9 @@ int git_status_list_new(
329
336
 
330
337
  if (show != GIT_STATUS_SHOW_INDEX_ONLY) {
331
338
  if ((error = git_diff_index_to_workdir(
332
- &status->idx2wd, repo, index, &diffopt)) < 0)
339
+ &status->idx2wd, repo, index, &diffopt)) < 0) {
333
340
  goto done;
341
+ }
334
342
 
335
343
  if ((flags & GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR) != 0 &&
336
344
  (error = git_diff_find_similar(status->idx2wd, &findopt)) < 0)
@@ -407,8 +415,9 @@ int git_status_foreach_ext(
407
415
  size_t i;
408
416
  int error = 0;
409
417
 
410
- if ((error = git_status_list_new(&status, repo, opts)) < 0)
418
+ if ((error = git_status_list_new(&status, repo, opts)) < 0) {
411
419
  return error;
420
+ }
412
421
 
413
422
  git_vector_foreach(&status->paired, i, status_entry) {
414
423
  const char *path = status_entry->head_to_index ?
@@ -485,7 +494,8 @@ int git_status_file(
485
494
  GIT_STATUS_OPT_RECURSE_IGNORED_DIRS |
486
495
  GIT_STATUS_OPT_INCLUDE_UNTRACKED |
487
496
  GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS |
488
- GIT_STATUS_OPT_INCLUDE_UNMODIFIED;
497
+ GIT_STATUS_OPT_INCLUDE_UNMODIFIED |
498
+ GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH;
489
499
  opts.pathspec.count = 1;
490
500
  opts.pathspec.strings = &sfi.expected;
491
501
 
@@ -7,7 +7,8 @@
7
7
  #ifndef INCLUDE_strlen_h__
8
8
  #define INCLUDE_strlen_h__
9
9
 
10
- #if defined(__MINGW32__) || defined(__sun) || defined(__APPLE__) || defined(__MidnightBSD__)
10
+ #if defined(__MINGW32__) || defined(__sun) || defined(__APPLE__) || defined(__MidnightBSD__) ||\
11
+ (defined(_MSC_VER) && _MSC_VER < 1500)
11
12
  # define NO_STRNLEN
12
13
  #endif
13
14
 
@@ -306,6 +306,56 @@ void git_submodule_cache_free(git_repository *repo)
306
306
  submodule_cache_free(cache);
307
307
  }
308
308
 
309
+ static int submodule_repo_init(
310
+ git_repository **out,
311
+ git_repository *parent_repo,
312
+ const char *path,
313
+ const char *url,
314
+ bool use_gitlink)
315
+ {
316
+ int error = 0;
317
+ git_buf workdir = GIT_BUF_INIT, repodir = GIT_BUF_INIT;
318
+ git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT;
319
+ git_repository *subrepo = NULL;
320
+
321
+ error = git_buf_joinpath(&workdir, git_repository_workdir(parent_repo), path);
322
+ if (error < 0)
323
+ goto cleanup;
324
+
325
+ initopt.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_NO_REINIT;
326
+ initopt.origin_url = url;
327
+
328
+ /* init submodule repository and add origin remote as needed */
329
+
330
+ /* New style: sub-repo goes in <repo-dir>/modules/<name>/ with a
331
+ * gitlink in the sub-repo workdir directory to that repository
332
+ *
333
+ * Old style: sub-repo goes directly into repo/<name>/.git/
334
+ */
335
+ if (use_gitlink) {
336
+ error = git_buf_join3(
337
+ &repodir, '/', git_repository_path(parent_repo), "modules", path);
338
+ if (error < 0)
339
+ goto cleanup;
340
+
341
+ initopt.workdir_path = workdir.ptr;
342
+ initopt.flags |=
343
+ GIT_REPOSITORY_INIT_NO_DOTGIT_DIR |
344
+ GIT_REPOSITORY_INIT_RELATIVE_GITLINK;
345
+
346
+ error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt);
347
+ } else
348
+ error = git_repository_init_ext(&subrepo, workdir.ptr, &initopt);
349
+
350
+ cleanup:
351
+ git_buf_free(&workdir);
352
+ git_buf_free(&repodir);
353
+
354
+ *out = subrepo;
355
+
356
+ return error;
357
+ }
358
+
309
359
  int git_submodule_add_setup(
310
360
  git_submodule **out,
311
361
  git_repository *repo,
@@ -317,7 +367,6 @@ int git_submodule_add_setup(
317
367
  git_config_backend *mods = NULL;
318
368
  git_submodule *sm = NULL;
319
369
  git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT;
320
- git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT;
321
370
  git_repository *subrepo = NULL;
322
371
 
323
372
  assert(repo && url && path);
@@ -371,41 +420,14 @@ int git_submodule_add_setup(
371
420
  if (error < 0)
372
421
  goto cleanup;
373
422
 
374
- /* New style: sub-repo goes in <repo-dir>/modules/<name>/ with a
375
- * gitlink in the sub-repo workdir directory to that repository
376
- *
377
- * Old style: sub-repo goes directly into repo/<name>/.git/
423
+ /* if the repo does not already exist, then init a new repo and add it.
424
+ * Otherwise, just add the existing repo.
378
425
  */
379
-
380
- initopt.flags = GIT_REPOSITORY_INIT_MKPATH |
381
- GIT_REPOSITORY_INIT_NO_REINIT;
382
- initopt.origin_url = real_url.ptr;
383
-
384
- if (git_path_exists(name.ptr) &&
385
- git_path_contains(&name, DOT_GIT))
386
- {
387
- /* repo appears to already exist - reinit? */
388
- }
389
- else if (use_gitlink) {
390
- git_buf repodir = GIT_BUF_INIT;
391
-
392
- error = git_buf_join3(
393
- &repodir, '/', git_repository_path(repo), "modules", path);
394
- if (error < 0)
426
+ if (!(git_path_exists(name.ptr) &&
427
+ git_path_contains(&name, DOT_GIT))) {
428
+ if ((error = submodule_repo_init(&subrepo, repo, path, real_url.ptr, use_gitlink)) < 0)
395
429
  goto cleanup;
396
-
397
- initopt.workdir_path = name.ptr;
398
- initopt.flags |= GIT_REPOSITORY_INIT_NO_DOTGIT_DIR;
399
-
400
- error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt);
401
-
402
- git_buf_free(&repodir);
403
430
  }
404
- else {
405
- error = git_repository_init_ext(&subrepo, name.ptr, &initopt);
406
- }
407
- if (error < 0)
408
- goto cleanup;
409
431
 
410
432
  /* add submodule to hash and "reload" it */
411
433
 
@@ -437,6 +459,23 @@ cleanup:
437
459
  return error;
438
460
  }
439
461
 
462
+ int git_submodule_repo_init(
463
+ git_repository **out,
464
+ const git_submodule *sm,
465
+ int use_gitlink)
466
+ {
467
+ int error;
468
+ git_repository *sub_repo = NULL;
469
+
470
+ assert(out && sm);
471
+
472
+ error = submodule_repo_init(&sub_repo, sm->repo, sm->path, sm->url, use_gitlink);
473
+
474
+ *out = sub_repo;
475
+
476
+ return error;
477
+ }
478
+
440
479
  int git_submodule_add_finalize(git_submodule *sm)
441
480
  {
442
481
  int error;
@@ -1837,7 +1876,7 @@ static int lookup_head_remote(git_remote **remote, git_repository *repo)
1837
1876
 
1838
1877
  /* lookup remote of remote tracking branch name */
1839
1878
  if (!(error = lookup_head_remote_key(&remote_name, repo)))
1840
- error = git_remote_load(remote, repo, remote_name.ptr);
1879
+ error = git_remote_lookup(remote, repo, remote_name.ptr);
1841
1880
 
1842
1881
  git_buf_free(&remote_name);
1843
1882
 
@@ -1851,7 +1890,7 @@ static int lookup_default_remote(git_remote **remote, git_repository *repo)
1851
1890
 
1852
1891
  /* if that failed, use 'origin' instead */
1853
1892
  if (error == GIT_ENOTFOUND)
1854
- error = git_remote_load(remote, repo, "origin");
1893
+ error = git_remote_lookup(remote, repo, "origin");
1855
1894
 
1856
1895
  if (error == GIT_ENOTFOUND)
1857
1896
  giterr_set(
@@ -1897,6 +1936,7 @@ static void submodule_get_index_status(unsigned int *status, git_submodule *sm)
1897
1936
  *status |= GIT_SUBMODULE_STATUS_INDEX_MODIFIED;
1898
1937
  }
1899
1938
 
1939
+
1900
1940
  static void submodule_get_wd_status(
1901
1941
  unsigned int *status,
1902
1942
  git_submodule *sm,
@@ -53,12 +53,6 @@ typedef struct {
53
53
 
54
54
  #endif
55
55
 
56
- #if defined(GIT_WIN32)
57
- #define git_thread_yield() Sleep(0)
58
- #else
59
- #define git_thread_yield() sched_yield()
60
- #endif
61
-
62
56
  /* Pthreads Mutex */
63
57
  #define git_mutex pthread_mutex_t
64
58
  #define git_mutex_init(a) pthread_mutex_init(a, NULL)
@@ -186,12 +180,13 @@ GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
186
180
  #define git_thread unsigned int
187
181
  #define git_thread_create(thread, attr, start_routine, arg) 0
188
182
  #define git_thread_join(id, status) (void)0
189
- #define git_thread_yield() (void)0
190
183
 
191
184
  /* Pthreads Mutex */
192
185
  #define git_mutex unsigned int
193
- #define git_mutex_init(a) 0
194
- #define git_mutex_lock(a) 0
186
+ GIT_INLINE(int) git_mutex_init(git_mutex *mutex) \
187
+ { GIT_UNUSED(mutex); return 0; }
188
+ GIT_INLINE(int) git_mutex_lock(git_mutex *mutex) \
189
+ { GIT_UNUSED(mutex); return 0; }
195
190
  #define git_mutex_unlock(a) (void)0
196
191
  #define git_mutex_free(a) (void)0
197
192
 
@@ -46,8 +46,16 @@ GIT_INLINE(void) git_trace__write_fmt(
46
46
 
47
47
  #else
48
48
 
49
+ GIT_INLINE(void) git_trace__null(
50
+ git_trace_level_t level,
51
+ const char *fmt, ...)
52
+ {
53
+ GIT_UNUSED(level);
54
+ GIT_UNUSED(fmt);
55
+ }
56
+
49
57
  #define git_trace_level() ((void)0)
50
- #define git_trace(lvl, ...) ((void)0)
58
+ #define git_trace git_trace__null
51
59
 
52
60
  #endif
53
61