rugged 0.17.0.b7 → 0.18.0.b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +88 -32
  3. data/ext/rugged/extconf.rb +4 -2
  4. data/ext/rugged/rugged.c +72 -10
  5. data/ext/rugged/rugged.h +14 -10
  6. data/ext/rugged/rugged_blob.c +8 -10
  7. data/ext/rugged/rugged_branch.c +11 -14
  8. data/ext/rugged/rugged_commit.c +31 -24
  9. data/ext/rugged/rugged_config.c +2 -2
  10. data/ext/rugged/rugged_index.c +133 -198
  11. data/ext/rugged/rugged_note.c +372 -0
  12. data/ext/rugged/rugged_object.c +50 -22
  13. data/ext/rugged/rugged_reference.c +122 -130
  14. data/ext/rugged/rugged_remote.c +72 -29
  15. data/ext/rugged/rugged_repo.c +402 -20
  16. data/ext/rugged/rugged_revwalk.c +7 -3
  17. data/ext/rugged/rugged_settings.c +110 -0
  18. data/ext/rugged/rugged_signature.c +23 -7
  19. data/ext/rugged/rugged_tag.c +32 -16
  20. data/ext/rugged/rugged_tree.c +44 -15
  21. data/lib/rugged.rb +1 -0
  22. data/lib/rugged/index.rb +8 -0
  23. data/lib/rugged/remote.rb +13 -0
  24. data/lib/rugged/repository.rb +3 -3
  25. data/lib/rugged/version.rb +1 -1
  26. data/test/blob_test.rb +13 -15
  27. data/test/branch_test.rb +32 -67
  28. data/test/commit_test.rb +50 -12
  29. data/test/config_test.rb +12 -11
  30. data/test/coverage/HEAD.json +1 -1
  31. data/test/coverage/cover.rb +40 -21
  32. data/test/errors_test.rb +34 -0
  33. data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
  34. data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
  35. data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
  36. data/test/fixtures/testrepo.git/logs/refs/notes/commits +1 -0
  37. data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +1 -0
  38. data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
  39. data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +1 -0
  40. data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
  41. data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
  42. data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +3 -0
  43. data/test/fixtures/testrepo.git/refs/notes/commits +1 -0
  44. data/test/index_test.rb +65 -69
  45. data/test/lib_test.rb +76 -11
  46. data/test/note_test.rb +158 -0
  47. data/test/object_test.rb +8 -11
  48. data/test/reference_test.rb +77 -85
  49. data/test/remote_test.rb +86 -8
  50. data/test/repo_pack_test.rb +9 -7
  51. data/test/repo_reset_test.rb +80 -0
  52. data/test/repo_test.rb +176 -53
  53. data/test/tag_test.rb +44 -7
  54. data/test/test_helper.rb +63 -35
  55. data/test/tree_test.rb +34 -13
  56. data/test/walker_test.rb +14 -14
  57. data/vendor/libgit2/Makefile.embed +1 -1
  58. data/vendor/libgit2/deps/http-parser/http_parser.c +974 -578
  59. data/vendor/libgit2/deps/http-parser/http_parser.h +106 -70
  60. data/vendor/libgit2/deps/regex/regcomp.c +7 -6
  61. data/vendor/libgit2/deps/regex/regex_internal.c +1 -1
  62. data/vendor/libgit2/deps/regex/regex_internal.h +12 -3
  63. data/vendor/libgit2/deps/regex/regexec.c +5 -5
  64. data/vendor/libgit2/include/git2.h +5 -1
  65. data/vendor/libgit2/include/git2/attr.h +4 -2
  66. data/vendor/libgit2/include/git2/blob.h +39 -12
  67. data/vendor/libgit2/include/git2/branch.h +123 -35
  68. data/vendor/libgit2/include/git2/checkout.h +206 -48
  69. data/vendor/libgit2/include/git2/clone.h +72 -27
  70. data/vendor/libgit2/include/git2/commit.h +20 -17
  71. data/vendor/libgit2/include/git2/common.h +67 -1
  72. data/vendor/libgit2/include/git2/config.h +81 -60
  73. data/vendor/libgit2/include/git2/cred_helpers.h +53 -0
  74. data/vendor/libgit2/include/git2/diff.h +459 -150
  75. data/vendor/libgit2/include/git2/errors.h +9 -1
  76. data/vendor/libgit2/include/git2/graph.h +41 -0
  77. data/vendor/libgit2/include/git2/ignore.h +7 -6
  78. data/vendor/libgit2/include/git2/index.h +323 -97
  79. data/vendor/libgit2/include/git2/indexer.h +27 -59
  80. data/vendor/libgit2/include/git2/inttypes.h +4 -0
  81. data/vendor/libgit2/include/git2/merge.h +13 -3
  82. data/vendor/libgit2/include/git2/message.h +14 -8
  83. data/vendor/libgit2/include/git2/net.h +9 -7
  84. data/vendor/libgit2/include/git2/notes.h +88 -29
  85. data/vendor/libgit2/include/git2/object.h +16 -6
  86. data/vendor/libgit2/include/git2/odb.h +80 -17
  87. data/vendor/libgit2/include/git2/odb_backend.h +47 -11
  88. data/vendor/libgit2/include/git2/oid.h +26 -17
  89. data/vendor/libgit2/include/git2/pack.h +62 -8
  90. data/vendor/libgit2/include/git2/push.h +131 -0
  91. data/vendor/libgit2/include/git2/refdb.h +103 -0
  92. data/vendor/libgit2/include/git2/refdb_backend.h +109 -0
  93. data/vendor/libgit2/include/git2/reflog.h +30 -21
  94. data/vendor/libgit2/include/git2/refs.h +215 -193
  95. data/vendor/libgit2/include/git2/refspec.h +22 -2
  96. data/vendor/libgit2/include/git2/remote.h +158 -37
  97. data/vendor/libgit2/include/git2/repository.h +150 -31
  98. data/vendor/libgit2/include/git2/reset.h +43 -9
  99. data/vendor/libgit2/include/git2/revparse.h +48 -4
  100. data/vendor/libgit2/include/git2/revwalk.h +25 -10
  101. data/vendor/libgit2/include/git2/signature.h +20 -12
  102. data/vendor/libgit2/include/git2/stash.h +121 -0
  103. data/vendor/libgit2/include/git2/status.h +122 -53
  104. data/vendor/libgit2/include/git2/strarray.h +17 -11
  105. data/vendor/libgit2/include/git2/submodule.h +42 -7
  106. data/vendor/libgit2/include/git2/tag.h +72 -59
  107. data/vendor/libgit2/include/git2/threads.h +4 -2
  108. data/vendor/libgit2/include/git2/trace.h +68 -0
  109. data/vendor/libgit2/include/git2/transport.h +328 -0
  110. data/vendor/libgit2/include/git2/tree.h +149 -120
  111. data/vendor/libgit2/include/git2/types.h +13 -12
  112. data/vendor/libgit2/include/git2/version.h +3 -3
  113. data/vendor/libgit2/src/amiga/map.c +2 -2
  114. data/vendor/libgit2/src/attr.c +58 -48
  115. data/vendor/libgit2/src/attr.h +4 -18
  116. data/vendor/libgit2/src/attr_file.c +30 -6
  117. data/vendor/libgit2/src/attr_file.h +6 -8
  118. data/vendor/libgit2/src/attrcache.h +24 -0
  119. data/vendor/libgit2/src/blob.c +30 -7
  120. data/vendor/libgit2/src/blob.h +1 -1
  121. data/vendor/libgit2/src/branch.c +361 -68
  122. data/vendor/libgit2/src/branch.h +17 -0
  123. data/vendor/libgit2/src/bswap.h +1 -1
  124. data/vendor/libgit2/src/buf_text.c +291 -0
  125. data/vendor/libgit2/src/buf_text.h +122 -0
  126. data/vendor/libgit2/src/buffer.c +27 -101
  127. data/vendor/libgit2/src/buffer.h +54 -39
  128. data/vendor/libgit2/src/cache.c +15 -6
  129. data/vendor/libgit2/src/cache.h +1 -1
  130. data/vendor/libgit2/src/cc-compat.h +3 -1
  131. data/vendor/libgit2/src/checkout.c +1165 -222
  132. data/vendor/libgit2/src/checkout.h +24 -0
  133. data/vendor/libgit2/src/clone.c +171 -86
  134. data/vendor/libgit2/src/commit.c +44 -45
  135. data/vendor/libgit2/src/commit.h +3 -3
  136. data/vendor/libgit2/src/commit_list.c +194 -0
  137. data/vendor/libgit2/src/commit_list.h +49 -0
  138. data/vendor/libgit2/src/common.h +44 -10
  139. data/vendor/libgit2/src/compress.c +1 -1
  140. data/vendor/libgit2/src/compress.h +1 -1
  141. data/vendor/libgit2/src/config.c +211 -124
  142. data/vendor/libgit2/src/config.h +23 -4
  143. data/vendor/libgit2/src/config_cache.c +2 -2
  144. data/vendor/libgit2/src/config_file.c +129 -53
  145. data/vendor/libgit2/src/config_file.h +10 -8
  146. data/vendor/libgit2/src/crlf.c +66 -67
  147. data/vendor/libgit2/src/date.c +12 -12
  148. data/vendor/libgit2/src/delta-apply.c +14 -1
  149. data/vendor/libgit2/src/delta-apply.h +18 -1
  150. data/vendor/libgit2/src/delta.c +40 -107
  151. data/vendor/libgit2/src/delta.h +19 -17
  152. data/vendor/libgit2/src/diff.c +347 -496
  153. data/vendor/libgit2/src/diff.h +27 -1
  154. data/vendor/libgit2/src/diff_output.c +564 -249
  155. data/vendor/libgit2/src/diff_output.h +15 -8
  156. data/vendor/libgit2/src/diff_tform.c +687 -0
  157. data/vendor/libgit2/src/errors.c +27 -36
  158. data/vendor/libgit2/src/fetch.c +13 -351
  159. data/vendor/libgit2/src/fetch.h +13 -3
  160. data/vendor/libgit2/src/fetchhead.c +295 -0
  161. data/vendor/libgit2/src/fetchhead.h +34 -0
  162. data/vendor/libgit2/src/filebuf.c +42 -15
  163. data/vendor/libgit2/src/filebuf.h +4 -2
  164. data/vendor/libgit2/src/fileops.c +466 -113
  165. data/vendor/libgit2/src/fileops.h +154 -28
  166. data/vendor/libgit2/src/filter.c +3 -75
  167. data/vendor/libgit2/src/filter.h +1 -29
  168. data/vendor/libgit2/src/fnmatch.c +1 -1
  169. data/vendor/libgit2/src/fnmatch.h +1 -1
  170. data/vendor/libgit2/src/global.c +54 -10
  171. data/vendor/libgit2/src/global.h +10 -1
  172. data/vendor/libgit2/src/graph.c +178 -0
  173. data/vendor/libgit2/src/hash.c +25 -52
  174. data/vendor/libgit2/src/hash.h +21 -9
  175. data/vendor/libgit2/src/{sha1/sha1.c → hash/hash_generic.c} +20 -12
  176. data/vendor/libgit2/src/hash/hash_generic.h +24 -0
  177. data/vendor/libgit2/src/hash/hash_openssl.h +45 -0
  178. data/vendor/libgit2/src/hash/hash_win32.c +291 -0
  179. data/vendor/libgit2/src/hash/hash_win32.h +140 -0
  180. data/vendor/libgit2/src/hashsig.c +368 -0
  181. data/vendor/libgit2/src/hashsig.h +72 -0
  182. data/vendor/libgit2/src/ignore.c +22 -15
  183. data/vendor/libgit2/src/ignore.h +6 -1
  184. data/vendor/libgit2/src/index.c +770 -171
  185. data/vendor/libgit2/src/index.h +13 -5
  186. data/vendor/libgit2/src/indexer.c +286 -431
  187. data/vendor/libgit2/src/iterator.c +854 -466
  188. data/vendor/libgit2/src/iterator.h +134 -109
  189. data/vendor/libgit2/src/map.h +1 -1
  190. data/vendor/libgit2/src/merge.c +296 -0
  191. data/vendor/libgit2/src/merge.h +22 -0
  192. data/vendor/libgit2/src/message.c +1 -1
  193. data/vendor/libgit2/src/message.h +1 -1
  194. data/vendor/libgit2/src/mwindow.c +35 -30
  195. data/vendor/libgit2/src/mwindow.h +2 -2
  196. data/vendor/libgit2/src/netops.c +162 -98
  197. data/vendor/libgit2/src/netops.h +50 -15
  198. data/vendor/libgit2/src/notes.c +109 -58
  199. data/vendor/libgit2/src/notes.h +2 -1
  200. data/vendor/libgit2/src/object.c +46 -57
  201. data/vendor/libgit2/src/object.h +1 -8
  202. data/vendor/libgit2/src/odb.c +151 -40
  203. data/vendor/libgit2/src/odb.h +5 -1
  204. data/vendor/libgit2/src/odb_loose.c +4 -5
  205. data/vendor/libgit2/src/odb_pack.c +122 -80
  206. data/vendor/libgit2/src/offmap.h +65 -0
  207. data/vendor/libgit2/src/oid.c +12 -4
  208. data/vendor/libgit2/src/oidmap.h +1 -1
  209. data/vendor/libgit2/src/pack-objects.c +88 -61
  210. data/vendor/libgit2/src/pack-objects.h +8 -8
  211. data/vendor/libgit2/src/pack.c +293 -28
  212. data/vendor/libgit2/src/pack.h +49 -4
  213. data/vendor/libgit2/src/path.c +103 -14
  214. data/vendor/libgit2/src/path.h +23 -7
  215. data/vendor/libgit2/src/pathspec.c +168 -0
  216. data/vendor/libgit2/src/pathspec.h +40 -0
  217. data/vendor/libgit2/src/pool.c +29 -4
  218. data/vendor/libgit2/src/pool.h +8 -1
  219. data/vendor/libgit2/src/posix.c +26 -27
  220. data/vendor/libgit2/src/posix.h +2 -3
  221. data/vendor/libgit2/src/pqueue.c +23 -1
  222. data/vendor/libgit2/src/pqueue.h +23 -1
  223. data/vendor/libgit2/src/push.c +653 -0
  224. data/vendor/libgit2/src/push.h +51 -0
  225. data/vendor/libgit2/src/refdb.c +185 -0
  226. data/vendor/libgit2/src/refdb.h +46 -0
  227. data/vendor/libgit2/src/refdb_fs.c +1024 -0
  228. data/vendor/libgit2/src/refdb_fs.h +15 -0
  229. data/vendor/libgit2/src/reflog.c +77 -45
  230. data/vendor/libgit2/src/reflog.h +1 -3
  231. data/vendor/libgit2/src/refs.c +366 -1326
  232. data/vendor/libgit2/src/refs.h +22 -13
  233. data/vendor/libgit2/src/refspec.c +46 -7
  234. data/vendor/libgit2/src/refspec.h +11 -1
  235. data/vendor/libgit2/src/remote.c +758 -120
  236. data/vendor/libgit2/src/remote.h +10 -5
  237. data/vendor/libgit2/src/repo_template.h +6 -6
  238. data/vendor/libgit2/src/repository.c +315 -96
  239. data/vendor/libgit2/src/repository.h +5 -3
  240. data/vendor/libgit2/src/reset.c +99 -81
  241. data/vendor/libgit2/src/revparse.c +157 -84
  242. data/vendor/libgit2/src/revwalk.c +68 -470
  243. data/vendor/libgit2/src/revwalk.h +44 -0
  244. data/vendor/libgit2/src/sha1_lookup.c +1 -1
  245. data/vendor/libgit2/src/sha1_lookup.h +1 -1
  246. data/vendor/libgit2/src/signature.c +68 -200
  247. data/vendor/libgit2/src/signature.h +1 -1
  248. data/vendor/libgit2/src/stash.c +663 -0
  249. data/vendor/libgit2/src/status.c +101 -79
  250. data/vendor/libgit2/src/strmap.h +1 -1
  251. data/vendor/libgit2/src/submodule.c +67 -51
  252. data/vendor/libgit2/src/submodule.h +1 -1
  253. data/vendor/libgit2/src/tag.c +35 -29
  254. data/vendor/libgit2/src/tag.h +1 -1
  255. data/vendor/libgit2/src/thread-utils.c +1 -1
  256. data/vendor/libgit2/src/thread-utils.h +2 -2
  257. data/vendor/libgit2/src/trace.c +39 -0
  258. data/vendor/libgit2/src/trace.h +56 -0
  259. data/vendor/libgit2/src/transport.c +81 -34
  260. data/vendor/libgit2/src/transports/cred.c +60 -0
  261. data/vendor/libgit2/src/transports/cred_helpers.c +49 -0
  262. data/vendor/libgit2/src/transports/git.c +234 -127
  263. data/vendor/libgit2/src/transports/http.c +761 -433
  264. data/vendor/libgit2/src/transports/local.c +460 -64
  265. data/vendor/libgit2/src/transports/smart.c +345 -0
  266. data/vendor/libgit2/src/transports/smart.h +179 -0
  267. data/vendor/libgit2/src/{pkt.c → transports/smart_pkt.c} +131 -12
  268. data/vendor/libgit2/src/transports/smart_protocol.c +856 -0
  269. data/vendor/libgit2/src/transports/winhttp.c +1136 -0
  270. data/vendor/libgit2/src/tree-cache.c +2 -2
  271. data/vendor/libgit2/src/tree-cache.h +1 -1
  272. data/vendor/libgit2/src/tree.c +239 -166
  273. data/vendor/libgit2/src/tree.h +11 -2
  274. data/vendor/libgit2/src/tsort.c +39 -23
  275. data/vendor/libgit2/src/unix/map.c +1 -1
  276. data/vendor/libgit2/src/unix/posix.h +12 -2
  277. data/vendor/libgit2/src/unix/realpath.c +30 -0
  278. data/vendor/libgit2/src/util.c +250 -13
  279. data/vendor/libgit2/src/util.h +71 -14
  280. data/vendor/libgit2/src/vector.c +123 -60
  281. data/vendor/libgit2/src/vector.h +24 -22
  282. data/vendor/libgit2/src/win32/dir.c +1 -1
  283. data/vendor/libgit2/src/win32/dir.h +1 -1
  284. data/vendor/libgit2/src/win32/error.c +77 -0
  285. data/vendor/libgit2/src/win32/error.h +13 -0
  286. data/vendor/libgit2/src/win32/findfile.c +143 -54
  287. data/vendor/libgit2/src/win32/findfile.h +10 -6
  288. data/vendor/libgit2/src/win32/map.c +1 -1
  289. data/vendor/libgit2/src/win32/mingw-compat.h +1 -1
  290. data/vendor/libgit2/src/win32/msvc-compat.h +10 -1
  291. data/vendor/libgit2/src/win32/posix.h +10 -1
  292. data/vendor/libgit2/src/win32/posix_w32.c +132 -63
  293. data/vendor/libgit2/src/win32/precompiled.c +1 -1
  294. data/vendor/libgit2/src/win32/pthread.c +1 -1
  295. data/vendor/libgit2/src/win32/pthread.h +1 -1
  296. data/vendor/libgit2/src/win32/utf-conv.c +5 -5
  297. data/vendor/libgit2/src/win32/utf-conv.h +3 -3
  298. data/vendor/libgit2/src/win32/version.h +20 -0
  299. metadata +308 -252
  300. data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  301. data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
  302. data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
  303. data/test/index_test.rb~ +0 -218
  304. data/vendor/libgit2/src/pkt.h +0 -91
  305. data/vendor/libgit2/src/ppc/sha1.c +0 -70
  306. data/vendor/libgit2/src/ppc/sha1.h +0 -26
  307. data/vendor/libgit2/src/protocol.c +0 -110
  308. data/vendor/libgit2/src/protocol.h +0 -21
  309. data/vendor/libgit2/src/sha1.h +0 -33
  310. data/vendor/libgit2/src/transport.h +0 -148
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2009-2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
3
  *
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
@@ -17,6 +17,7 @@
17
17
 
18
18
  #include "git2/diff.h"
19
19
  #include "diff.h"
20
+ #include "diff_output.h"
20
21
 
21
22
  static unsigned int index_delta2status(git_delta_t index_status)
22
23
  {
@@ -76,32 +77,72 @@ static unsigned int workdir_delta2status(git_delta_t workdir_status)
76
77
  return st;
77
78
  }
78
79
 
80
+ typedef struct {
81
+ git_status_cb cb;
82
+ void *payload;
83
+ const git_status_options *opts;
84
+ } status_user_callback;
85
+
86
+ static int status_invoke_cb(
87
+ git_diff_delta *h2i, git_diff_delta *i2w, void *payload)
88
+ {
89
+ status_user_callback *usercb = payload;
90
+ const char *path = NULL;
91
+ unsigned int status = 0;
92
+
93
+ if (i2w) {
94
+ path = i2w->old_file.path;
95
+ status |= workdir_delta2status(i2w->status);
96
+ }
97
+ if (h2i) {
98
+ path = h2i->old_file.path;
99
+ status |= index_delta2status(h2i->status);
100
+ }
101
+
102
+ /* if excluding submodules and this is a submodule everywhere */
103
+ if (usercb->opts &&
104
+ (usercb->opts->flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES) != 0)
105
+ {
106
+ bool in_tree = (h2i && h2i->status != GIT_DELTA_ADDED);
107
+ bool in_index = (h2i && h2i->status != GIT_DELTA_DELETED);
108
+ bool in_wd = (i2w && i2w->status != GIT_DELTA_DELETED);
109
+
110
+ if ((!in_tree || h2i->old_file.mode == GIT_FILEMODE_COMMIT) &&
111
+ (!in_index || h2i->new_file.mode == GIT_FILEMODE_COMMIT) &&
112
+ (!in_wd || i2w->new_file.mode == GIT_FILEMODE_COMMIT))
113
+ return 0;
114
+ }
115
+
116
+ return usercb->cb(path, status, usercb->payload);
117
+ }
118
+
79
119
  int git_status_foreach_ext(
80
120
  git_repository *repo,
81
121
  const git_status_options *opts,
82
- int (*cb)(const char *, unsigned int, void *),
83
- void *cbdata)
122
+ git_status_cb cb,
123
+ void *payload)
84
124
  {
85
- int err = 0, cmp;
86
- git_diff_options diffopt;
87
- git_diff_list *idx2head = NULL, *wd2idx = NULL;
125
+ int err = 0;
126
+ git_diff_options diffopt = GIT_DIFF_OPTIONS_INIT;
127
+ git_diff_list *head2idx = NULL, *idx2wd = NULL;
88
128
  git_tree *head = NULL;
89
129
  git_status_show_t show =
90
130
  opts ? opts->show : GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
91
- git_diff_delta *i2h, *w2i;
92
- size_t i, j, i_max, j_max;
93
- bool ignore_case = false;
131
+ status_user_callback usercb;
94
132
 
95
133
  assert(show <= GIT_STATUS_SHOW_INDEX_THEN_WORKDIR);
96
134
 
135
+ GITERR_CHECK_VERSION(opts, GIT_STATUS_OPTIONS_VERSION, "git_status_options");
136
+
97
137
  if (show != GIT_STATUS_SHOW_INDEX_ONLY &&
98
138
  (err = git_repository__ensure_not_bare(repo, "status")) < 0)
99
139
  return err;
100
140
 
101
- if ((err = git_repository_head_tree(&head, repo)) < 0)
102
- return err;
141
+ /* if there is no HEAD, that's okay - we'll make an empty iterator */
142
+ if (((err = git_repository_head_tree(&head, repo)) < 0) &&
143
+ !(err == GIT_ENOTFOUND || err == GIT_EORPHANEDHEAD))
144
+ return err;
103
145
 
104
- memset(&diffopt, 0, sizeof(diffopt));
105
146
  memcpy(&diffopt.pathspec, &opts->pathspec, sizeof(diffopt.pathspec));
106
147
 
107
148
  diffopt.flags = GIT_DIFF_INCLUDE_TYPECHANGE;
@@ -116,70 +157,42 @@ int git_status_foreach_ext(
116
157
  diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_UNTRACKED_DIRS;
117
158
  if ((opts->flags & GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH) != 0)
118
159
  diffopt.flags = diffopt.flags | GIT_DIFF_DISABLE_PATHSPEC_MATCH;
119
- /* TODO: support EXCLUDE_SUBMODULES flag */
160
+ if ((opts->flags & GIT_STATUS_OPT_RECURSE_IGNORED_DIRS) != 0)
161
+ diffopt.flags = diffopt.flags | GIT_DIFF_RECURSE_IGNORED_DIRS;
162
+ if ((opts->flags & GIT_STATUS_OPT_EXCLUDE_SUBMODULES) != 0)
163
+ diffopt.flags = diffopt.flags | GIT_DIFF_IGNORE_SUBMODULES;
164
+
165
+ if (show != GIT_STATUS_SHOW_WORKDIR_ONLY) {
166
+ err = git_diff_tree_to_index(&head2idx, repo, head, NULL, &diffopt);
167
+ if (err < 0)
168
+ goto cleanup;
169
+ }
120
170
 
121
- if (show != GIT_STATUS_SHOW_WORKDIR_ONLY &&
122
- (err = git_diff_index_to_tree(repo, &diffopt, head, &idx2head)) < 0)
123
- goto cleanup;
171
+ if (show != GIT_STATUS_SHOW_INDEX_ONLY) {
172
+ err = git_diff_index_to_workdir(&idx2wd, repo, NULL, &diffopt);
173
+ if (err < 0)
174
+ goto cleanup;
175
+ }
124
176
 
125
- if (show != GIT_STATUS_SHOW_INDEX_ONLY &&
126
- (err = git_diff_workdir_to_index(repo, &diffopt, &wd2idx)) < 0)
127
- goto cleanup;
177
+ usercb.cb = cb;
178
+ usercb.payload = payload;
179
+ usercb.opts = opts;
128
180
 
129
181
  if (show == GIT_STATUS_SHOW_INDEX_THEN_WORKDIR) {
130
- for (i = 0; !err && i < idx2head->deltas.length; i++) {
131
- i2h = GIT_VECTOR_GET(&idx2head->deltas, i);
132
- if (cb(i2h->old_file.path, index_delta2status(i2h->status), cbdata))
133
- err = GIT_EUSER;
134
- }
135
- git_diff_list_free(idx2head);
136
- idx2head = NULL;
137
- }
182
+ if ((err = git_diff__paired_foreach(
183
+ head2idx, NULL, status_invoke_cb, &usercb)) < 0)
184
+ goto cleanup;
138
185
 
139
- i_max = idx2head ? idx2head->deltas.length : 0;
140
- j_max = wd2idx ? wd2idx->deltas.length : 0;
141
-
142
- if (idx2head && wd2idx &&
143
- (0 != (idx2head->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE) ||
144
- 0 != (wd2idx->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE)))
145
- {
146
- /* Then use the ignore-case sorter... */
147
- ignore_case = true;
148
-
149
- /* and assert that both are ignore-case sorted. If this function
150
- * ever needs to support merge joining result sets that are not sorted
151
- * by the same function, then it will need to be extended to do a spool
152
- * and sort on one of the results before merge joining */
153
- assert(0 != (idx2head->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE) &&
154
- 0 != (wd2idx->opts.flags & GIT_DIFF_DELTAS_ARE_ICASE));
186
+ git_diff_list_free(head2idx);
187
+ head2idx = NULL;
155
188
  }
156
189
 
157
- for (i = 0, j = 0; !err && (i < i_max || j < j_max); ) {
158
- i2h = idx2head ? GIT_VECTOR_GET(&idx2head->deltas,i) : NULL;
159
- w2i = wd2idx ? GIT_VECTOR_GET(&wd2idx->deltas,j) : NULL;
160
-
161
- cmp = !w2i ? -1 : !i2h ? 1 : STRCMP_CASESELECT(ignore_case, i2h->old_file.path, w2i->old_file.path);
162
-
163
- if (cmp < 0) {
164
- if (cb(i2h->old_file.path, index_delta2status(i2h->status), cbdata))
165
- err = GIT_EUSER;
166
- i++;
167
- } else if (cmp > 0) {
168
- if (cb(w2i->old_file.path, workdir_delta2status(w2i->status), cbdata))
169
- err = GIT_EUSER;
170
- j++;
171
- } else {
172
- if (cb(i2h->old_file.path, index_delta2status(i2h->status) |
173
- workdir_delta2status(w2i->status), cbdata))
174
- err = GIT_EUSER;
175
- i++; j++;
176
- }
177
- }
190
+ err = git_diff__paired_foreach(head2idx, idx2wd, status_invoke_cb, &usercb);
178
191
 
179
192
  cleanup:
180
193
  git_tree_free(head);
181
- git_diff_list_free(idx2head);
182
- git_diff_list_free(wd2idx);
194
+ git_diff_list_free(head2idx);
195
+ git_diff_list_free(idx2wd);
183
196
 
184
197
  if (err == GIT_EUSER)
185
198
  giterr_clear();
@@ -189,12 +202,11 @@ cleanup:
189
202
 
190
203
  int git_status_foreach(
191
204
  git_repository *repo,
192
- int (*callback)(const char *, unsigned int, void *),
205
+ git_status_cb callback,
193
206
  void *payload)
194
207
  {
195
- git_status_options opts;
208
+ git_status_options opts = GIT_STATUS_OPTIONS_INIT;
196
209
 
197
- memset(&opts, 0, sizeof(opts));
198
210
  opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
199
211
  opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED |
200
212
  GIT_STATUS_OPT_INCLUDE_UNTRACKED |
@@ -207,21 +219,24 @@ struct status_file_info {
207
219
  char *expected;
208
220
  unsigned int count;
209
221
  unsigned int status;
222
+ int fnm_flags;
210
223
  int ambiguous;
211
224
  };
212
225
 
213
226
  static int get_one_status(const char *path, unsigned int status, void *data)
214
227
  {
215
228
  struct status_file_info *sfi = data;
229
+ int (*strcomp)(const char *a, const char *b);
216
230
 
217
231
  sfi->count++;
218
232
  sfi->status = status;
219
233
 
220
- if (sfi->count > 1 ||
221
- (strcmp(sfi->expected, path) != 0 &&
222
- p_fnmatch(sfi->expected, path, 0) != 0)) {
223
- giterr_set(GITERR_INVALID,
224
- "Ambiguous path '%s' given to git_status_file", sfi->expected);
234
+ strcomp = (sfi->fnm_flags & FNM_CASEFOLD) ? git__strcasecmp : git__strcmp;
235
+
236
+ if (sfi->count > 1 ||
237
+ (strcomp(sfi->expected, path) != 0 &&
238
+ p_fnmatch(sfi->expected, path, sfi->fnm_flags) != 0))
239
+ {
225
240
  sfi->ambiguous = true;
226
241
  return GIT_EAMBIGUOUS;
227
242
  }
@@ -235,16 +250,20 @@ int git_status_file(
235
250
  const char *path)
236
251
  {
237
252
  int error;
238
- git_status_options opts;
239
- struct status_file_info sfi;
253
+ git_status_options opts = GIT_STATUS_OPTIONS_INIT;
254
+ struct status_file_info sfi = {0};
255
+ git_index *index;
240
256
 
241
257
  assert(status_flags && repo && path);
242
258
 
243
- memset(&sfi, 0, sizeof(sfi));
259
+ if ((error = git_repository_index__weakptr(&index, repo)) < 0)
260
+ return error;
261
+
244
262
  if ((sfi.expected = git__strdup(path)) == NULL)
245
263
  return -1;
264
+ if (index->ignore_case)
265
+ sfi.fnm_flags = FNM_CASEFOLD;
246
266
 
247
- memset(&opts, 0, sizeof(opts));
248
267
  opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
249
268
  opts.flags = GIT_STATUS_OPT_INCLUDE_IGNORED |
250
269
  GIT_STATUS_OPT_INCLUDE_UNTRACKED |
@@ -255,8 +274,11 @@ int git_status_file(
255
274
 
256
275
  error = git_status_foreach_ext(repo, &opts, get_one_status, &sfi);
257
276
 
258
- if (error < 0 && sfi.ambiguous)
277
+ if (error < 0 && sfi.ambiguous) {
278
+ giterr_set(GITERR_INVALID,
279
+ "Ambiguous path '%s' given to git_status_file", sfi.expected);
259
280
  error = GIT_EAMBIGUOUS;
281
+ }
260
282
 
261
283
  if (!error && !sfi.count) {
262
284
  git_buf full = GIT_BUF_INIT;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
3
  *
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (C) 2012 the libgit2 contributors
2
+ * Copyright (C) the libgit2 contributors. All rights reserved.
3
3
  *
4
4
  * This file is part of libgit2, distributed under the GNU GPL v2 with
5
5
  * a Linking Exception. For full terms see the included COPYING file.
@@ -12,6 +12,7 @@
12
12
  #include "git2/index.h"
13
13
  #include "git2/submodule.h"
14
14
  #include "buffer.h"
15
+ #include "buf_text.h"
15
16
  #include "vector.h"
16
17
  #include "posix.h"
17
18
  #include "config_file.h"
@@ -65,8 +66,8 @@ __KHASH_IMPL(
65
66
  str, static kh_inline, const char *, void *, 1,
66
67
  str_hash_no_trailing_slash, str_equal_no_trailing_slash);
67
68
 
68
- static int load_submodule_config(git_repository *repo, bool force);
69
- static git_config_file *open_gitmodules(git_repository *, bool, const git_oid *);
69
+ static int load_submodule_config(git_repository *repo);
70
+ static git_config_backend *open_gitmodules(git_repository *, bool, const git_oid *);
70
71
  static int lookup_head_remote(git_buf *url, git_repository *repo);
71
72
  static int submodule_get(git_submodule **, git_repository *, const char *, const char *);
72
73
  static void submodule_release(git_submodule *sm, int decr);
@@ -105,7 +106,7 @@ int git_submodule_lookup(
105
106
 
106
107
  assert(repo && name);
107
108
 
108
- if ((error = load_submodule_config(repo, false)) < 0)
109
+ if ((error = load_submodule_config(repo)) < 0)
109
110
  return error;
110
111
 
111
112
  pos = git_strmap_lookup_index(repo->submodules, name);
@@ -147,7 +148,7 @@ int git_submodule_foreach(
147
148
 
148
149
  assert(repo && callback);
149
150
 
150
- if ((error = load_submodule_config(repo, false)) < 0)
151
+ if ((error = load_submodule_config(repo)) < 0)
151
152
  return error;
152
153
 
153
154
  git_strmap_foreach_value(repo->submodules, sm, {
@@ -156,7 +157,7 @@ int git_submodule_foreach(
156
157
  * and path are not the same.
157
158
  */
158
159
  if (sm->refcount > 1) {
159
- if (git_vector_bsearch(&seen, sm) != GIT_ENOTFOUND)
160
+ if (git_vector_bsearch(NULL, &seen, sm) != GIT_ENOTFOUND)
160
161
  continue;
161
162
  if ((error = git_vector_insert(&seen, sm)) < 0)
162
163
  break;
@@ -201,10 +202,10 @@ int git_submodule_add_setup(
201
202
  int use_gitlink)
202
203
  {
203
204
  int error = 0;
204
- git_config_file *mods = NULL;
205
+ git_config_backend *mods = NULL;
205
206
  git_submodule *sm;
206
207
  git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT;
207
- git_repository_init_options initopt;
208
+ git_repository_init_options initopt = GIT_REPOSITORY_INIT_OPTIONS_INIT;
208
209
  git_repository *subrepo = NULL;
209
210
 
210
211
  assert(repo && url && path);
@@ -274,7 +275,6 @@ int git_submodule_add_setup(
274
275
  * Old style: sub-repo goes directly into repo/<name>/.git/
275
276
  */
276
277
 
277
- memset(&initopt, 0, sizeof(initopt));
278
278
  initopt.flags = GIT_REPOSITORY_INIT_MKPATH |
279
279
  GIT_REPOSITORY_INIT_NO_REINIT;
280
280
  initopt.origin_url = real_url.ptr;
@@ -332,7 +332,7 @@ int git_submodule_add_finalize(git_submodule *sm)
332
332
  assert(sm);
333
333
 
334
334
  if ((error = git_repository_index__weakptr(&index, sm->owner)) < 0 ||
335
- (error = git_index_add(index, GIT_MODULES_FILE, 0)) < 0)
335
+ (error = git_index_add_bypath(index, GIT_MODULES_FILE)) < 0)
336
336
  return error;
337
337
 
338
338
  return git_submodule_add_to_index(sm, true);
@@ -341,7 +341,7 @@ int git_submodule_add_finalize(git_submodule *sm)
341
341
  int git_submodule_add_to_index(git_submodule *sm, int write_index)
342
342
  {
343
343
  int error;
344
- git_repository *repo, *sm_repo;
344
+ git_repository *repo, *sm_repo = NULL;
345
345
  git_index *index;
346
346
  git_buf path = GIT_BUF_INIT;
347
347
  git_commit *head;
@@ -371,7 +371,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
371
371
 
372
372
  memset(&entry, 0, sizeof(entry));
373
373
  entry.path = sm->path;
374
- git_index__init_entry_from_stat(&st, &entry);
374
+ git_index_entry__init_from_stat(&entry, &st);
375
375
 
376
376
  /* calling git_submodule_open will have set sm->wd_oid if possible */
377
377
  if ((sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) == 0) {
@@ -393,7 +393,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
393
393
  git_commit_free(head);
394
394
 
395
395
  /* add it */
396
- error = git_index_add2(index, &entry);
396
+ error = git_index_add(index, &entry);
397
397
 
398
398
  /* write it, if requested */
399
399
  if (!error && write_index) {
@@ -412,7 +412,7 @@ cleanup:
412
412
  int git_submodule_save(git_submodule *submodule)
413
413
  {
414
414
  int error = 0;
415
- git_config_file *mods;
415
+ git_config_backend *mods;
416
416
  git_buf key = GIT_BUF_INIT;
417
417
 
418
418
  assert(submodule);
@@ -513,7 +513,7 @@ int git_submodule_set_url(git_submodule *submodule, const char *url)
513
513
  return 0;
514
514
  }
515
515
 
516
- const git_oid *git_submodule_index_oid(git_submodule *submodule)
516
+ const git_oid *git_submodule_index_id(git_submodule *submodule)
517
517
  {
518
518
  assert(submodule);
519
519
 
@@ -523,7 +523,7 @@ const git_oid *git_submodule_index_oid(git_submodule *submodule)
523
523
  return NULL;
524
524
  }
525
525
 
526
- const git_oid *git_submodule_head_oid(git_submodule *submodule)
526
+ const git_oid *git_submodule_head_id(git_submodule *submodule)
527
527
  {
528
528
  assert(submodule);
529
529
 
@@ -533,7 +533,7 @@ const git_oid *git_submodule_head_oid(git_submodule *submodule)
533
533
  return NULL;
534
534
  }
535
535
 
536
- const git_oid *git_submodule_wd_oid(git_submodule *submodule)
536
+ const git_oid *git_submodule_wd_id(git_submodule *submodule)
537
537
  {
538
538
  assert(submodule);
539
539
 
@@ -694,8 +694,8 @@ int git_submodule_open(
694
694
  git_buf_free(&path);
695
695
 
696
696
  /* if we have opened the submodule successfully, let's grab the HEAD OID */
697
- if (!error && !(submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)) {
698
- if (!git_reference_name_to_oid(
697
+ if (!error) {
698
+ if (!git_reference_name_to_id(
699
699
  &submodule->wd_oid, *subrepo, GIT_HEAD_FILE))
700
700
  submodule->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID;
701
701
  else
@@ -708,16 +708,18 @@ int git_submodule_open(
708
708
  int git_submodule_reload_all(git_repository *repo)
709
709
  {
710
710
  assert(repo);
711
- return load_submodule_config(repo, true);
711
+ git_submodule_config_free(repo);
712
+ return load_submodule_config(repo);
712
713
  }
713
714
 
714
715
  int git_submodule_reload(git_submodule *submodule)
715
716
  {
716
717
  git_repository *repo;
717
718
  git_index *index;
718
- int pos, error;
719
+ int error;
720
+ size_t pos;
719
721
  git_tree *head;
720
- git_config_file *mods;
722
+ git_config_backend *mods;
721
723
 
722
724
  assert(submodule);
723
725
 
@@ -731,9 +733,8 @@ int git_submodule_reload(git_submodule *submodule)
731
733
  ~(GIT_SUBMODULE_STATUS_IN_INDEX |
732
734
  GIT_SUBMODULE_STATUS__INDEX_OID_VALID);
733
735
 
734
- pos = git_index_find(index, submodule->path);
735
- if (pos >= 0) {
736
- git_index_entry *entry = git_index_get(index, pos);
736
+ if (!git_index_find(&pos, index, submodule->path)) {
737
+ const git_index_entry *entry = git_index_get_byindex(index, pos);
737
738
 
738
739
  if (S_ISGITLINK(entry->mode)) {
739
740
  if ((error = submodule_load_from_index(repo, entry)) < 0)
@@ -782,7 +783,7 @@ int git_submodule_reload(git_submodule *submodule)
782
783
  git_buf path = GIT_BUF_INIT;
783
784
 
784
785
  git_buf_sets(&path, "submodule\\.");
785
- git_buf_puts_escape_regex(&path, submodule->name);
786
+ git_buf_text_puts_escape_regex(&path, submodule->name);
786
787
  git_buf_puts(&path, ".*");
787
788
 
788
789
  if (git_buf_oom(&path))
@@ -829,6 +830,20 @@ int git_submodule_status(
829
830
  return error;
830
831
  }
831
832
 
833
+ int git_submodule_location(
834
+ unsigned int *location_status,
835
+ git_submodule *submodule)
836
+ {
837
+ assert(location_status && submodule);
838
+
839
+ *location_status = submodule->flags &
840
+ (GIT_SUBMODULE_STATUS_IN_HEAD | GIT_SUBMODULE_STATUS_IN_INDEX |
841
+ GIT_SUBMODULE_STATUS_IN_CONFIG | GIT_SUBMODULE_STATUS_IN_WD);
842
+
843
+ return 0;
844
+ }
845
+
846
+
832
847
  /*
833
848
  * INTERNAL FUNCTIONS
834
849
  */
@@ -1115,13 +1130,15 @@ static int load_submodule_config_from_index(
1115
1130
  git_repository *repo, git_oid *gitmodules_oid)
1116
1131
  {
1117
1132
  int error;
1133
+ git_index *index;
1118
1134
  git_iterator *i;
1119
1135
  const git_index_entry *entry;
1120
1136
 
1121
- if ((error = git_iterator_for_index(&i, repo)) < 0)
1137
+ if ((error = git_repository_index__weakptr(&index, repo)) < 0 ||
1138
+ (error = git_iterator_for_index(&i, index, 0, NULL, NULL)) < 0)
1122
1139
  return error;
1123
1140
 
1124
- error = git_iterator_current(i, &entry);
1141
+ error = git_iterator_current(&entry, i);
1125
1142
 
1126
1143
  while (!error && entry != NULL) {
1127
1144
 
@@ -1137,7 +1154,7 @@ static int load_submodule_config_from_index(
1137
1154
  git_oid_cpy(gitmodules_oid, &entry->oid);
1138
1155
  }
1139
1156
 
1140
- error = git_iterator_advance(i, &entry);
1157
+ error = git_iterator_advance(&entry, i);
1141
1158
  }
1142
1159
 
1143
1160
  git_iterator_free(i);
@@ -1156,12 +1173,12 @@ static int load_submodule_config_from_head(
1156
1173
  if ((error = git_repository_head_tree(&head, repo)) < 0)
1157
1174
  return error;
1158
1175
 
1159
- if ((error = git_iterator_for_tree(&i, repo, head)) < 0) {
1176
+ if ((error = git_iterator_for_tree(&i, head, 0, NULL, NULL)) < 0) {
1160
1177
  git_tree_free(head);
1161
1178
  return error;
1162
1179
  }
1163
1180
 
1164
- error = git_iterator_current(i, &entry);
1181
+ error = git_iterator_current(&entry, i);
1165
1182
 
1166
1183
  while (!error && entry != NULL) {
1167
1184
 
@@ -1178,7 +1195,7 @@ static int load_submodule_config_from_head(
1178
1195
  git_oid_cpy(gitmodules_oid, &entry->oid);
1179
1196
  }
1180
1197
 
1181
- error = git_iterator_advance(i, &entry);
1198
+ error = git_iterator_advance(&entry, i);
1182
1199
  }
1183
1200
 
1184
1201
  git_iterator_free(i);
@@ -1187,14 +1204,14 @@ static int load_submodule_config_from_head(
1187
1204
  return error;
1188
1205
  }
1189
1206
 
1190
- static git_config_file *open_gitmodules(
1207
+ static git_config_backend *open_gitmodules(
1191
1208
  git_repository *repo,
1192
1209
  bool okay_to_create,
1193
1210
  const git_oid *gitmodules_oid)
1194
1211
  {
1195
1212
  const char *workdir = git_repository_workdir(repo);
1196
1213
  git_buf path = GIT_BUF_INIT;
1197
- git_config_file *mods = NULL;
1214
+ git_config_backend *mods = NULL;
1198
1215
 
1199
1216
  if (workdir != NULL) {
1200
1217
  if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0)
@@ -1225,14 +1242,14 @@ static git_config_file *open_gitmodules(
1225
1242
  return mods;
1226
1243
  }
1227
1244
 
1228
- static int load_submodule_config(git_repository *repo, bool force)
1245
+ static int load_submodule_config(git_repository *repo)
1229
1246
  {
1230
1247
  int error;
1231
1248
  git_oid gitmodules_oid;
1232
1249
  git_buf path = GIT_BUF_INIT;
1233
- git_config_file *mods = NULL;
1250
+ git_config_backend *mods = NULL;
1234
1251
 
1235
- if (repo->submodules && !force)
1252
+ if (repo->submodules)
1236
1253
  return 0;
1237
1254
 
1238
1255
  memset(&gitmodules_oid, 0, sizeof(gitmodules_oid));
@@ -1310,13 +1327,13 @@ static int lookup_head_remote(git_buf *url, git_repository *repo)
1310
1327
  goto cleanup;
1311
1328
  }
1312
1329
 
1313
- if ((error = git_branch_tracking(&remote, head)) < 0)
1330
+ if ((error = git_branch_upstream(&remote, head)) < 0)
1314
1331
  goto cleanup;
1315
1332
 
1316
1333
  /* remote should refer to something like refs/remotes/ORIGIN/BRANCH */
1317
1334
 
1318
1335
  if (git_reference_type(remote) != GIT_REF_SYMBOLIC ||
1319
- git__prefixcmp(git_reference_target(remote), GIT_REFS_REMOTES_DIR) != 0)
1336
+ git__prefixcmp(git_reference_symbolic_target(remote), GIT_REFS_REMOTES_DIR) != 0)
1320
1337
  {
1321
1338
  giterr_set(GITERR_SUBMODULE,
1322
1339
  "Cannot resolve relative URL when HEAD is not symbolic");
@@ -1324,7 +1341,7 @@ static int lookup_head_remote(git_buf *url, git_repository *repo)
1324
1341
  goto cleanup;
1325
1342
  }
1326
1343
 
1327
- scan = tgt = git_reference_target(remote) + strlen(GIT_REFS_REMOTES_DIR);
1344
+ scan = tgt = git_reference_symbolic_target(remote) + strlen(GIT_REFS_REMOTES_DIR);
1328
1345
  while (*scan && (*scan != '/' || (scan > tgt && scan[-1] != '\\')))
1329
1346
  scan++; /* find non-escaped slash to end ORIGIN name */
1330
1347
 
@@ -1378,7 +1395,7 @@ static int submodule_update_config(
1378
1395
  goto cleanup;
1379
1396
 
1380
1397
  if (!value)
1381
- error = git_config_delete(config, key.ptr);
1398
+ error = git_config_delete_entry(config, key.ptr);
1382
1399
  else
1383
1400
  error = git_config_set_string(config, key.ptr, value);
1384
1401
 
@@ -1389,8 +1406,8 @@ cleanup:
1389
1406
 
1390
1407
  static int submodule_index_status(unsigned int *status, git_submodule *sm)
1391
1408
  {
1392
- const git_oid *head_oid = git_submodule_head_oid(sm);
1393
- const git_oid *index_oid = git_submodule_index_oid(sm);
1409
+ const git_oid *head_oid = git_submodule_head_id(sm);
1410
+ const git_oid *index_oid = git_submodule_index_id(sm);
1394
1411
 
1395
1412
  if (!head_oid) {
1396
1413
  if (index_oid)
@@ -1410,7 +1427,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
1410
1427
  const git_oid *wd_oid, *index_oid;
1411
1428
  git_repository *sm_repo = NULL;
1412
1429
 
1413
- /* open repo now if we need it (so wd_oid() call won't reopen) */
1430
+ /* open repo now if we need it (so wd_id() call won't reopen) */
1414
1431
  if ((sm->ignore == GIT_SUBMODULE_IGNORE_NONE ||
1415
1432
  sm->ignore == GIT_SUBMODULE_IGNORE_UNTRACKED) &&
1416
1433
  (sm->flags & GIT_SUBMODULE_STATUS_IN_WD) != 0)
@@ -1419,8 +1436,8 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
1419
1436
  return error;
1420
1437
  }
1421
1438
 
1422
- index_oid = git_submodule_index_oid(sm);
1423
- wd_oid = git_submodule_wd_oid(sm);
1439
+ index_oid = git_submodule_index_id(sm);
1440
+ wd_oid = git_submodule_wd_id(sm);
1424
1441
 
1425
1442
  if (!index_oid) {
1426
1443
  if (wd_oid)
@@ -1438,7 +1455,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
1438
1455
 
1439
1456
  if (sm_repo != NULL) {
1440
1457
  git_tree *sm_head;
1441
- git_diff_options opt;
1458
+ git_diff_options opt = GIT_DIFF_OPTIONS_INIT;
1442
1459
  git_diff_list *diff;
1443
1460
 
1444
1461
  /* the diffs below could be optimized with an early termination
@@ -1451,11 +1468,10 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
1451
1468
  if ((error = git_repository_head_tree(&sm_head, sm_repo)) < 0)
1452
1469
  return error;
1453
1470
 
1454
- memset(&opt, 0, sizeof(opt));
1455
1471
  if (sm->ignore == GIT_SUBMODULE_IGNORE_NONE)
1456
1472
  opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
1457
1473
 
1458
- error = git_diff_index_to_tree(sm_repo, &opt, sm_head, &diff);
1474
+ error = git_diff_tree_to_index(&diff, sm_repo, sm_head, NULL, &opt);
1459
1475
 
1460
1476
  if (!error) {
1461
1477
  if (git_diff_num_deltas(diff) > 0)
@@ -1472,7 +1488,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
1472
1488
 
1473
1489
  /* perform index-to-workdir diff on submodule */
1474
1490
 
1475
- error = git_diff_workdir_to_index(sm_repo, &opt, &diff);
1491
+ error = git_diff_index_to_workdir(&diff, sm_repo, NULL, &opt);
1476
1492
 
1477
1493
  if (!error) {
1478
1494
  size_t untracked =
@@ -1481,7 +1497,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
1481
1497
  if (untracked > 0)
1482
1498
  *status |= GIT_SUBMODULE_STATUS_WD_UNTRACKED;
1483
1499
 
1484
- if ((git_diff_num_deltas(diff) - untracked) > 0)
1500
+ if (git_diff_num_deltas(diff) != untracked)
1485
1501
  *status |= GIT_SUBMODULE_STATUS_WD_WD_MODIFIED;
1486
1502
 
1487
1503
  git_diff_list_free(diff);