rugged 0.18.0.gh.de28323 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (283) hide show
  1. data/README.md +9 -4
  2. data/Rakefile +1 -1
  3. data/ext/rugged/extconf.rb +10 -0
  4. data/ext/rugged/rugged.c +153 -86
  5. data/ext/rugged/rugged.h +44 -33
  6. data/ext/rugged/rugged_blob.c +288 -60
  7. data/ext/rugged/rugged_branch.c +82 -57
  8. data/ext/rugged/rugged_commit.c +83 -86
  9. data/ext/rugged/rugged_config.c +68 -68
  10. data/ext/rugged/rugged_diff.c +509 -0
  11. data/ext/rugged/rugged_diff_delta.c +94 -0
  12. data/ext/rugged/rugged_diff_hunk.c +100 -0
  13. data/ext/rugged/rugged_diff_line.c +79 -0
  14. data/ext/rugged/rugged_diff_patch.c +169 -0
  15. data/ext/rugged/rugged_index.c +539 -8
  16. data/ext/rugged/rugged_note.c +74 -80
  17. data/ext/rugged/rugged_object.c +63 -8
  18. data/ext/rugged/rugged_reference.c +231 -145
  19. data/ext/rugged/rugged_remote.c +509 -53
  20. data/ext/rugged/rugged_repo.c +572 -236
  21. data/ext/rugged/rugged_revwalk.c +59 -36
  22. data/ext/rugged/rugged_settings.c +7 -9
  23. data/ext/rugged/rugged_signature.c +7 -11
  24. data/ext/rugged/rugged_tag.c +93 -39
  25. data/ext/rugged/rugged_tree.c +321 -58
  26. data/lib/rugged.rb +1 -0
  27. data/lib/rugged/commit.rb +16 -1
  28. data/lib/rugged/console.rb +9 -0
  29. data/lib/rugged/diff.rb +19 -0
  30. data/lib/rugged/diff/delta.rb +54 -0
  31. data/lib/rugged/diff/hunk.rb +23 -0
  32. data/lib/rugged/diff/line.rb +29 -0
  33. data/lib/rugged/diff/patch.rb +28 -0
  34. data/lib/rugged/repository.rb +36 -39
  35. data/lib/rugged/version.rb +1 -1
  36. data/test/blob_test.rb +308 -1
  37. data/test/branch_test.rb +7 -0
  38. data/test/commit_test.rb +7 -10
  39. data/test/coverage/cover.rb +9 -1
  40. data/test/diff_test.rb +777 -0
  41. data/test/fixtures/archive.tar.gz +0 -0
  42. data/test/fixtures/attr/attr0 +1 -0
  43. data/test/fixtures/attr/attr1 +29 -0
  44. data/test/fixtures/attr/attr2 +21 -0
  45. data/test/fixtures/attr/attr3 +4 -0
  46. data/test/fixtures/attr/binfile +1 -0
  47. data/test/fixtures/attr/dir/file +0 -0
  48. data/test/fixtures/attr/file +1 -0
  49. data/test/fixtures/attr/gitattributes +29 -0
  50. data/test/fixtures/attr/gitignore +2 -0
  51. data/test/fixtures/attr/ign +1 -0
  52. data/test/fixtures/attr/macro_bad +1 -0
  53. data/test/fixtures/attr/macro_test +1 -0
  54. data/test/fixtures/attr/root_test1 +1 -0
  55. data/test/fixtures/attr/root_test2 +6 -0
  56. data/test/fixtures/attr/root_test3 +19 -0
  57. data/test/fixtures/attr/root_test4.txt +14 -0
  58. data/test/fixtures/attr/sub/abc +37 -0
  59. data/test/fixtures/attr/sub/dir/file +0 -0
  60. data/test/fixtures/attr/sub/file +1 -0
  61. data/test/fixtures/attr/sub/ign/file +1 -0
  62. data/test/fixtures/attr/sub/ign/sub/file +1 -0
  63. data/test/fixtures/attr/sub/sub/dir +0 -0
  64. data/test/fixtures/attr/sub/sub/file +1 -0
  65. data/test/fixtures/attr/sub/sub/subsub.txt +1 -0
  66. data/test/fixtures/attr/sub/subdir_test1 +2 -0
  67. data/test/fixtures/attr/sub/subdir_test2.txt +1 -0
  68. data/test/fixtures/diff/another.txt +38 -0
  69. data/test/fixtures/diff/readme.txt +36 -0
  70. data/test/fixtures/mergedrepo/conflicts-one.txt +5 -0
  71. data/test/fixtures/mergedrepo/conflicts-two.txt +5 -0
  72. data/test/fixtures/mergedrepo/one.txt +10 -0
  73. data/test/fixtures/mergedrepo/two.txt +12 -0
  74. data/test/fixtures/status/current_file +1 -0
  75. data/test/fixtures/status/ignored_file +1 -0
  76. data/test/fixtures/status/modified_file +2 -0
  77. data/test/fixtures/status/new_file +1 -0
  78. data/test/fixtures/status/staged_changes +2 -0
  79. data/test/fixtures/status/staged_changes_modified_file +3 -0
  80. data/test/fixtures/status/staged_delete_modified_file +1 -0
  81. data/test/fixtures/status/staged_new_file +1 -0
  82. data/test/fixtures/status/staged_new_file_modified_file +2 -0
  83. data/test/fixtures/status/subdir.txt +2 -0
  84. data/test/fixtures/status/subdir/current_file +1 -0
  85. data/test/fixtures/status/subdir/modified_file +2 -0
  86. data/test/fixtures/status/subdir/new_file +1 -0
  87. data/test/fixtures/status//350/277/231 +1 -0
  88. data/test/fixtures/testrepo.git/config +5 -0
  89. data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
  90. data/test/fixtures/text_file.md +464 -0
  91. data/test/fixtures/unsymlinked.git/HEAD +1 -0
  92. data/test/fixtures/unsymlinked.git/config +6 -0
  93. data/test/fixtures/unsymlinked.git/description +1 -0
  94. data/test/fixtures/unsymlinked.git/info/exclude +2 -0
  95. data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
  96. data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
  97. data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
  98. data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
  99. data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
  100. data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
  101. data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
  102. data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
  103. data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
  104. data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +2 -0
  105. data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
  106. data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
  107. data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
  108. data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
  109. data/test/fixtures/unsymlinked.git/refs/heads/exe-file +1 -0
  110. data/test/fixtures/unsymlinked.git/refs/heads/master +1 -0
  111. data/test/fixtures/unsymlinked.git/refs/heads/reg-file +1 -0
  112. data/test/index_test.rb +120 -0
  113. data/test/reference_test.rb +38 -3
  114. data/test/remote_test.rb +224 -3
  115. data/test/repo_reset_test.rb +2 -0
  116. data/test/repo_test.rb +147 -10
  117. data/test/test_helper.rb +5 -2
  118. data/vendor/libgit2/include/git2/attr.h +3 -3
  119. data/vendor/libgit2/include/git2/blob.h +11 -17
  120. data/vendor/libgit2/include/git2/branch.h +3 -2
  121. data/vendor/libgit2/include/git2/checkout.h +7 -0
  122. data/vendor/libgit2/include/git2/clone.h +3 -0
  123. data/vendor/libgit2/include/git2/commit.h +61 -66
  124. data/vendor/libgit2/include/git2/common.h +73 -42
  125. data/vendor/libgit2/include/git2/config.h +57 -71
  126. data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
  127. data/vendor/libgit2/include/git2/diff.h +179 -30
  128. data/vendor/libgit2/include/git2/errors.h +3 -3
  129. data/vendor/libgit2/include/git2/index.h +225 -146
  130. data/vendor/libgit2/include/git2/indexer.h +2 -22
  131. data/vendor/libgit2/include/git2/inttypes.h +9 -9
  132. data/vendor/libgit2/include/git2/merge.h +123 -5
  133. data/vendor/libgit2/include/git2/odb.h +59 -38
  134. data/vendor/libgit2/include/git2/odb_backend.h +45 -104
  135. data/vendor/libgit2/include/git2/oid.h +30 -19
  136. data/vendor/libgit2/include/git2/pack.h +21 -3
  137. data/vendor/libgit2/include/git2/refdb.h +0 -35
  138. data/vendor/libgit2/include/git2/refs.h +93 -31
  139. data/vendor/libgit2/include/git2/refspec.h +17 -0
  140. data/vendor/libgit2/include/git2/remote.h +60 -20
  141. data/vendor/libgit2/include/git2/repository.h +48 -70
  142. data/vendor/libgit2/include/git2/reset.h +3 -3
  143. data/vendor/libgit2/include/git2/revparse.h +22 -0
  144. data/vendor/libgit2/include/git2/stash.h +1 -1
  145. data/vendor/libgit2/include/git2/status.h +131 -56
  146. data/vendor/libgit2/include/git2/strarray.h +2 -2
  147. data/vendor/libgit2/include/git2/submodule.h +16 -16
  148. data/vendor/libgit2/include/git2/sys/commit.h +46 -0
  149. data/vendor/libgit2/include/git2/sys/config.h +71 -0
  150. data/vendor/libgit2/include/git2/sys/index.h +179 -0
  151. data/vendor/libgit2/include/git2/sys/odb_backend.h +86 -0
  152. data/vendor/libgit2/include/git2/sys/refdb_backend.h +158 -0
  153. data/vendor/libgit2/include/git2/sys/refs.h +38 -0
  154. data/vendor/libgit2/include/git2/sys/repository.h +106 -0
  155. data/vendor/libgit2/include/git2/tag.h +44 -18
  156. data/vendor/libgit2/include/git2/trace.h +1 -2
  157. data/vendor/libgit2/include/git2/transport.h +74 -0
  158. data/vendor/libgit2/include/git2/tree.h +12 -22
  159. data/vendor/libgit2/include/git2/types.h +33 -0
  160. data/vendor/libgit2/include/git2/version.h +2 -2
  161. data/vendor/libgit2/src/array.h +66 -0
  162. data/vendor/libgit2/src/attr.c +26 -13
  163. data/vendor/libgit2/src/attr_file.c +3 -2
  164. data/vendor/libgit2/src/attr_file.h +3 -3
  165. data/vendor/libgit2/src/attrcache.h +4 -4
  166. data/vendor/libgit2/src/blob.c +13 -9
  167. data/vendor/libgit2/src/blob.h +2 -2
  168. data/vendor/libgit2/src/branch.c +67 -49
  169. data/vendor/libgit2/src/cache.c +224 -54
  170. data/vendor/libgit2/src/cache.h +33 -20
  171. data/vendor/libgit2/src/checkout.c +145 -85
  172. data/vendor/libgit2/src/clone.c +62 -50
  173. data/vendor/libgit2/src/commit.c +74 -40
  174. data/vendor/libgit2/src/commit.h +2 -3
  175. data/vendor/libgit2/src/commit_list.c +14 -8
  176. data/vendor/libgit2/src/config.c +119 -36
  177. data/vendor/libgit2/src/config.h +3 -0
  178. data/vendor/libgit2/src/config_cache.c +24 -7
  179. data/vendor/libgit2/src/config_file.c +9 -6
  180. data/vendor/libgit2/src/crlf.c +4 -2
  181. data/vendor/libgit2/src/date.c +3 -3
  182. data/vendor/libgit2/src/delta.c +1 -1
  183. data/vendor/libgit2/src/diff.c +681 -303
  184. data/vendor/libgit2/src/diff.h +34 -2
  185. data/vendor/libgit2/src/diff_driver.c +405 -0
  186. data/vendor/libgit2/src/diff_driver.h +49 -0
  187. data/vendor/libgit2/src/diff_file.c +447 -0
  188. data/vendor/libgit2/src/diff_file.h +58 -0
  189. data/vendor/libgit2/src/diff_patch.c +995 -0
  190. data/vendor/libgit2/src/diff_patch.h +46 -0
  191. data/vendor/libgit2/src/diff_print.c +430 -0
  192. data/vendor/libgit2/src/diff_tform.c +464 -203
  193. data/vendor/libgit2/src/diff_xdiff.c +166 -0
  194. data/vendor/libgit2/src/diff_xdiff.h +28 -0
  195. data/vendor/libgit2/src/fetch.c +11 -4
  196. data/vendor/libgit2/src/fileops.c +85 -61
  197. data/vendor/libgit2/src/fileops.h +4 -0
  198. data/vendor/libgit2/src/global.c +10 -2
  199. data/vendor/libgit2/src/global.h +0 -8
  200. data/vendor/libgit2/src/hash/hash_generic.h +3 -3
  201. data/vendor/libgit2/src/hash/hash_win32.h +4 -4
  202. data/vendor/libgit2/src/hashsig.c +0 -1
  203. data/vendor/libgit2/src/ignore.c +68 -28
  204. data/vendor/libgit2/src/ignore.h +10 -1
  205. data/vendor/libgit2/src/index.c +666 -84
  206. data/vendor/libgit2/src/index.h +6 -0
  207. data/vendor/libgit2/src/indexer.c +10 -28
  208. data/vendor/libgit2/src/iterator.c +427 -283
  209. data/vendor/libgit2/src/iterator.h +58 -4
  210. data/vendor/libgit2/src/merge.c +1892 -32
  211. data/vendor/libgit2/src/merge.h +132 -5
  212. data/vendor/libgit2/src/merge_file.c +174 -0
  213. data/vendor/libgit2/src/merge_file.h +71 -0
  214. data/vendor/libgit2/src/mwindow.c +1 -1
  215. data/vendor/libgit2/src/notes.c +45 -48
  216. data/vendor/libgit2/src/object.c +89 -127
  217. data/vendor/libgit2/src/object.h +0 -1
  218. data/vendor/libgit2/src/object_api.c +129 -0
  219. data/vendor/libgit2/src/odb.c +156 -59
  220. data/vendor/libgit2/src/odb.h +5 -2
  221. data/vendor/libgit2/src/odb_loose.c +31 -17
  222. data/vendor/libgit2/src/odb_pack.c +39 -43
  223. data/vendor/libgit2/src/oid.c +62 -27
  224. data/vendor/libgit2/src/oid.h +33 -0
  225. data/vendor/libgit2/src/oidmap.h +4 -6
  226. data/vendor/libgit2/src/pack-objects.c +54 -22
  227. data/vendor/libgit2/src/pack.c +98 -56
  228. data/vendor/libgit2/src/pack.h +3 -1
  229. data/vendor/libgit2/src/pathspec.c +26 -1
  230. data/vendor/libgit2/src/pathspec.h +14 -0
  231. data/vendor/libgit2/src/pool.c +5 -0
  232. data/vendor/libgit2/src/posix.c +2 -2
  233. data/vendor/libgit2/src/posix.h +3 -0
  234. data/vendor/libgit2/src/push.c +13 -10
  235. data/vendor/libgit2/src/refdb.c +82 -62
  236. data/vendor/libgit2/src/refdb.h +16 -16
  237. data/vendor/libgit2/src/refdb_fs.c +386 -133
  238. data/vendor/libgit2/src/reflog.c +3 -1
  239. data/vendor/libgit2/src/refs.c +247 -221
  240. data/vendor/libgit2/src/refs.h +2 -1
  241. data/vendor/libgit2/src/refspec.c +18 -1
  242. data/vendor/libgit2/src/refspec.h +3 -1
  243. data/vendor/libgit2/src/remote.c +434 -253
  244. data/vendor/libgit2/src/remote.h +5 -3
  245. data/vendor/libgit2/src/repository.c +197 -111
  246. data/vendor/libgit2/src/repository.h +26 -5
  247. data/vendor/libgit2/src/reset.c +1 -1
  248. data/vendor/libgit2/src/revparse.c +84 -79
  249. data/vendor/libgit2/src/revwalk.c +1 -1
  250. data/vendor/libgit2/src/signature.c +22 -10
  251. data/vendor/libgit2/src/stash.c +5 -2
  252. data/vendor/libgit2/src/status.c +311 -107
  253. data/vendor/libgit2/src/status.h +23 -0
  254. data/vendor/libgit2/src/submodule.c +21 -13
  255. data/vendor/libgit2/src/tag.c +42 -31
  256. data/vendor/libgit2/src/tag.h +2 -3
  257. data/vendor/libgit2/src/thread-utils.h +105 -3
  258. data/vendor/libgit2/src/trace.c +1 -2
  259. data/vendor/libgit2/src/trace.h +3 -3
  260. data/vendor/libgit2/src/transport.c +18 -6
  261. data/vendor/libgit2/src/transports/cred.c +103 -1
  262. data/vendor/libgit2/src/transports/local.c +19 -9
  263. data/vendor/libgit2/src/transports/smart_protocol.c +32 -12
  264. data/vendor/libgit2/src/transports/ssh.c +519 -0
  265. data/vendor/libgit2/src/transports/winhttp.c +3 -1
  266. data/vendor/libgit2/src/tree.c +26 -28
  267. data/vendor/libgit2/src/tree.h +3 -3
  268. data/vendor/libgit2/src/unix/posix.h +2 -0
  269. data/vendor/libgit2/src/util.c +43 -6
  270. data/vendor/libgit2/src/util.h +40 -12
  271. data/vendor/libgit2/src/vector.c +3 -5
  272. data/vendor/libgit2/src/vector.h +9 -0
  273. data/vendor/libgit2/src/win32/dir.c +1 -1
  274. data/vendor/libgit2/src/win32/error.c +2 -0
  275. data/vendor/libgit2/src/win32/findfile.c +3 -6
  276. data/vendor/libgit2/src/win32/posix_w32.c +85 -59
  277. data/vendor/libgit2/src/win32/pthread.c +16 -8
  278. data/vendor/libgit2/src/win32/pthread.h +7 -4
  279. metadata +407 -306
  280. data/test/coverage/HEAD.json +0 -1
  281. data/vendor/libgit2/include/git2/refdb_backend.h +0 -109
  282. data/vendor/libgit2/src/diff_output.c +0 -1819
  283. data/vendor/libgit2/src/diff_output.h +0 -93
@@ -400,21 +400,6 @@ GIT_EXTERN(int) git_repository_is_bare(git_repository *repo);
400
400
  */
401
401
  GIT_EXTERN(int) git_repository_config(git_config **out, git_repository *repo);
402
402
 
403
- /**
404
- * Set the configuration file for this repository
405
- *
406
- * This configuration file will be used for all configuration
407
- * queries involving this repository.
408
- *
409
- * The repository will keep a reference to the config file;
410
- * the user must still free the config after setting it
411
- * to the repository, or it will leak.
412
- *
413
- * @param repo A repository object
414
- * @param config A Config object
415
- */
416
- GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config);
417
-
418
403
  /**
419
404
  * Get the Object Database for this repository.
420
405
  *
@@ -431,21 +416,6 @@ GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *con
431
416
  */
432
417
  GIT_EXTERN(int) git_repository_odb(git_odb **out, git_repository *repo);
433
418
 
434
- /**
435
- * Set the Object Database for this repository
436
- *
437
- * The ODB will be used for all object-related operations
438
- * involving this repository.
439
- *
440
- * The repository will keep a reference to the ODB; the user
441
- * must still free the ODB object after setting it to the
442
- * repository, or it will leak.
443
- *
444
- * @param repo A repository object
445
- * @param odb An ODB object
446
- */
447
- GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
448
-
449
419
  /**
450
420
  * Get the Reference Database Backend for this repository.
451
421
  *
@@ -462,23 +432,6 @@ GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
462
432
  */
463
433
  GIT_EXTERN(int) git_repository_refdb(git_refdb **out, git_repository *repo);
464
434
 
465
- /**
466
- * Set the Reference Database Backend for this repository
467
- *
468
- * The refdb will be used for all reference related operations
469
- * involving this repository.
470
- *
471
- * The repository will keep a reference to the refdb; the user
472
- * must still free the refdb object after setting it to the
473
- * repository, or it will leak.
474
- *
475
- * @param repo A repository object
476
- * @param refdb An refdb object
477
- */
478
- GIT_EXTERN(void) git_repository_set_refdb(
479
- git_repository *repo,
480
- git_refdb *refdb);
481
-
482
435
  /**
483
436
  * Get the Index file for this repository.
484
437
  *
@@ -495,21 +448,6 @@ GIT_EXTERN(void) git_repository_set_refdb(
495
448
  */
496
449
  GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
497
450
 
498
- /**
499
- * Set the index file for this repository
500
- *
501
- * This index will be used for all index-related operations
502
- * involving this repository.
503
- *
504
- * The repository will keep a reference to the index file;
505
- * the user must still free the index after setting it
506
- * to the repository, or it will leak.
507
- *
508
- * @param repo A repository object
509
- * @param index An index object
510
- */
511
- GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
512
-
513
451
  /**
514
452
  * Retrieve git's prepared message
515
453
  *
@@ -522,10 +460,19 @@ GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index
522
460
  * Use this function to get the contents of this file. Don't forget to
523
461
  * remove the file after you create the commit.
524
462
  *
463
+ * If the repository message exists and there are no errors reading it, this
464
+ * returns the bytes needed to store the message in memory (i.e. message
465
+ * file size plus one terminating NUL byte). That value is returned even if
466
+ * `out` is NULL or `len` is shorter than the necessary size.
467
+ *
468
+ * The `out` buffer will *always* be NUL terminated, even if truncation
469
+ * occurs.
470
+ *
525
471
  * @param out Buffer to write data into or NULL to just read required size
526
- * @param len Length of buffer in bytes
472
+ * @param len Length of `out` buffer in bytes
527
473
  * @param repo Repository to read prepared message from
528
- * @return Bytes written to buffer, GIT_ENOTFOUND if no message, or -1 on error
474
+ * @return GIT_ENOUTFOUND if no message exists, other value < 0 for other
475
+ * errors, or total bytes in message (may be > `len`) on success
529
476
  */
530
477
  GIT_EXTERN(int) git_repository_message(char *out, size_t len, git_repository *repo);
531
478
 
@@ -572,7 +519,7 @@ typedef int (*git_repository_mergehead_foreach_cb)(const git_oid *oid,
572
519
  *
573
520
  * @param repo A repository object
574
521
  * @param callback Callback function
575
- * @param apyload Pointer to callback data (optional)
522
+ * @param payload Pointer to callback data (optional)
576
523
  * @return 0 on success, GIT_ENOTFOUND, GIT_EUSER or error
577
524
  */
578
525
  GIT_EXTERN(int) git_repository_mergehead_foreach(git_repository *repo,
@@ -598,11 +545,11 @@ GIT_EXTERN(int) git_repository_mergehead_foreach(git_repository *repo,
598
545
  * applied when calculating the hash.
599
546
  */
600
547
  GIT_EXTERN(int) git_repository_hashfile(
601
- git_oid *out,
602
- git_repository *repo,
603
- const char *path,
604
- git_otype type,
605
- const char *as_path);
548
+ git_oid *out,
549
+ git_repository *repo,
550
+ const char *path,
551
+ git_otype type,
552
+ const char *as_path);
606
553
 
607
554
  /**
608
555
  * Make the repository HEAD point to the specified reference.
@@ -688,6 +635,37 @@ typedef enum {
688
635
  */
689
636
  GIT_EXTERN(int) git_repository_state(git_repository *repo);
690
637
 
638
+ /**
639
+ * Sets the active namespace for this Git Repository
640
+ *
641
+ * This namespace affects all reference operations for the repo.
642
+ * See `man gitnamespaces`
643
+ *
644
+ * @param repo The repo
645
+ * @param nmspace The namespace. This should not include the refs
646
+ * folder, e.g. to namespace all references under `refs/namespaces/foo/`,
647
+ * use `foo` as the namespace.
648
+ * @return 0 on success, -1 on error
649
+ */
650
+ GIT_EXTERN(int) git_repository_set_namespace(git_repository *repo, const char *nmspace);
651
+
652
+ /**
653
+ * Get the currently active namespace for this repository
654
+ *
655
+ * @param repo The repo
656
+ * @return the active namespace, or NULL if there isn't one
657
+ */
658
+ GIT_EXTERN(const char *) git_repository_get_namespace(git_repository *repo);
659
+
660
+
661
+ /**
662
+ * Determine if the repository was a shallow clone
663
+ *
664
+ * @param repo The repository
665
+ * @return 1 if shallow, zero if not
666
+ */
667
+ GIT_EXTERN(int) git_repository_is_shallow(git_repository *repo);
668
+
691
669
  /** @} */
692
670
  GIT_END_DECL
693
671
  #endif
@@ -72,9 +72,9 @@ GIT_EXTERN(int) git_reset(
72
72
  * @return 0 on success or an error code < 0
73
73
  */
74
74
  GIT_EXTERN(int) git_reset_default(
75
- git_repository *repo,
76
- git_object *target,
77
- git_strarray* pathspecs);
75
+ git_repository *repo,
76
+ git_object *target,
77
+ git_strarray* pathspecs);
78
78
 
79
79
  /** @} */
80
80
  GIT_END_DECL
@@ -32,6 +32,28 @@ GIT_BEGIN_DECL
32
32
  */
33
33
  GIT_EXTERN(int) git_revparse_single(git_object **out, git_repository *repo, const char *spec);
34
34
 
35
+ /**
36
+ * Find a single object, as specified by a revision string.
37
+ * See `man gitrevisions`,
38
+ * or http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for
39
+ * information on the syntax accepted.
40
+ *
41
+ * In some cases (`@{<-n>}` or `<branchname>@{upstream}`), the expression may
42
+ * point to an intermediate reference. When such expressions are being passed
43
+ * in, `reference_out` will be valued as well.
44
+ *
45
+ * @param object_out pointer to output object
46
+ * @param reference_out pointer to output reference or NULL
47
+ * @param repo the repository to search in
48
+ * @param spec the textual specification for an object
49
+ * @return 0 on success, GIT_ENOTFOUND, GIT_EAMBIGUOUS, GIT_EINVALIDSPEC
50
+ * or an error code
51
+ */
52
+ GIT_EXTERN(int) git_revparse_ext(
53
+ git_object **object_out,
54
+ git_reference **reference_out,
55
+ git_repository *repo,
56
+ const char *spec);
35
57
 
36
58
  /**
37
59
  * Revparse flags. These indicate the intended behavior of the spec passed to
@@ -89,7 +89,7 @@ typedef int (*git_stash_cb)(
89
89
  *
90
90
  * @param repo Repository where to find the stash.
91
91
  *
92
- * @param callabck Callback to invoke per found stashed state. The most recent
92
+ * @param callback Callback to invoke per found stashed state. The most recent
93
93
  * stash state will be enumerated first.
94
94
  *
95
95
  * @param payload Extra parameter to callback function.
@@ -42,6 +42,7 @@ typedef enum {
42
42
  GIT_STATUS_WT_MODIFIED = (1u << 8),
43
43
  GIT_STATUS_WT_DELETED = (1u << 9),
44
44
  GIT_STATUS_WT_TYPECHANGE = (1u << 10),
45
+ GIT_STATUS_WT_RENAMED = (1u << 11),
45
46
 
46
47
  GIT_STATUS_IGNORED = (1u << 14),
47
48
  } git_status_t;
@@ -58,44 +59,20 @@ typedef enum {
58
59
  typedef int (*git_status_cb)(
59
60
  const char *path, unsigned int status_flags, void *payload);
60
61
 
61
- /**
62
- * Gather file statuses and run a callback for each one.
63
- *
64
- * The callback is passed the path of the file, the status (a combination of
65
- * the `git_status_t` values above) and the `payload` data pointer passed
66
- * into this function.
67
- *
68
- * If the callback returns a non-zero value, this function will stop looping
69
- * and return GIT_EUSER.
70
- *
71
- * @param repo A repository object
72
- * @param callback The function to call on each file
73
- * @param payload Pointer to pass through to callback function
74
- * @return 0 on success, GIT_EUSER on non-zero callback, or error code
75
- */
76
- GIT_EXTERN(int) git_status_foreach(
77
- git_repository *repo,
78
- git_status_cb callback,
79
- void *payload);
80
-
81
62
  /**
82
63
  * For extended status, select the files on which to report status.
83
64
  *
84
- * - GIT_STATUS_SHOW_INDEX_AND_WORKDIR is the default. This is the
85
- * rough equivalent of `git status --porcelain` where each file
86
- * will receive a callback indicating its status in the index and
87
- * in the workdir.
88
- * - GIT_STATUS_SHOW_INDEX_ONLY will only make callbacks for index
89
- * side of status. The status of the index contents relative to
90
- * the HEAD will be given.
91
- * - GIT_STATUS_SHOW_WORKDIR_ONLY will only make callbacks for the
92
- * workdir side of status, reporting the status of workdir content
93
- * relative to the index.
94
- * - GIT_STATUS_SHOW_INDEX_THEN_WORKDIR behaves like index-only
95
- * followed by workdir-only, causing two callbacks to be issued
96
- * per file (first index then workdir). This is slightly more
97
- * efficient than making separate calls. This makes it easier to
98
- * emulate the output of a plain `git status`.
65
+ * - GIT_STATUS_SHOW_INDEX_AND_WORKDIR is the default. This roughly
66
+ * matches `git status --porcelain` where each file gets a callback
67
+ * indicating its status in the index and in the working directory.
68
+ * - GIT_STATUS_SHOW_INDEX_ONLY only gives status based on HEAD to index
69
+ * comparison, not looking at working directory changes.
70
+ * - GIT_STATUS_SHOW_WORKDIR_ONLY only gives status based on index to
71
+ * working directory comparison, not comparing the index to the HEAD.
72
+ * - GIT_STATUS_SHOW_INDEX_THEN_WORKDIR runs index-only then workdir-only,
73
+ * issuing (up to) two callbacks per file (first index, then workdir).
74
+ * This is slightly more efficient than separate calls and can make it
75
+ * easier to emulate plain `git status` text output.
99
76
  */
100
77
  typedef enum {
101
78
  GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0,
@@ -110,26 +87,36 @@ typedef enum {
110
87
  * - GIT_STATUS_OPT_INCLUDE_UNTRACKED says that callbacks should be made
111
88
  * on untracked files. These will only be made if the workdir files are
112
89
  * included in the status "show" option.
113
- * - GIT_STATUS_OPT_INCLUDE_IGNORED says that ignored files should get
114
- * callbacks. Again, these callbacks will only be made if the workdir
115
- * files are included in the status "show" option. Right now, there is
116
- * no option to include all files in directories that are ignored
117
- * completely.
90
+ * - GIT_STATUS_OPT_INCLUDE_IGNORED says that ignored files get callbacks.
91
+ * Again, these callbacks will only be made if the workdir files are
92
+ * included in the status "show" option.
118
93
  * - GIT_STATUS_OPT_INCLUDE_UNMODIFIED indicates that callback should be
119
94
  * made even on unmodified files.
120
- * - GIT_STATUS_OPT_EXCLUDE_SUBMODULES indicates that directories which
121
- * appear to be submodules should just be skipped over.
122
- * - GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS indicates that the contents of
123
- * untracked directories should be included in the status. Normally if
124
- * an entire directory is new, then just the top-level directory will be
125
- * included (with a trailing slash on the entry name). Given this flag,
126
- * the directory itself will not be included, but all the files in it
127
- * will.
95
+ * - GIT_STATUS_OPT_EXCLUDE_SUBMODULES indicates that submodules should be
96
+ * skipped. This only applies if there are no pending typechanges to
97
+ * the submodule (either from or to another type).
98
+ * - GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS indicates that all files in
99
+ * untracked directories should be included. Normally if an entire
100
+ * directory is new, then just the top-level directory is included (with
101
+ * a trailing slash on the entry name). This flag says to include all
102
+ * of the individual files in the directory instead.
128
103
  * - GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH indicates that the given path
129
- * will be treated as a literal path, and not as a pathspec.
104
+ * should be treated as a literal path, and not as a pathspec pattern.
130
105
  * - GIT_STATUS_OPT_RECURSE_IGNORED_DIRS indicates that the contents of
131
106
  * ignored directories should be included in the status. This is like
132
107
  * doing `git ls-files -o -i --exclude-standard` with core git.
108
+ * - GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX indicates that rename detection
109
+ * should be processed between the head and the index and enables
110
+ * the GIT_STATUS_INDEX_RENAMED as a possible status flag.
111
+ * - GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR indicates tha rename
112
+ * detection should be run between the index and the working directory
113
+ * and enabled GIT_STATUS_WT_RENAMED as a possible status flag.
114
+ * - GIT_STATUS_OPT_SORT_CASE_SENSITIVELY overrides the native case
115
+ * sensitivity for the file system and forces the output to be in
116
+ * case-sensitive order
117
+ * - GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY overrides the native case
118
+ * sensitivity for the file system and forces the output to be in
119
+ * case-insensitive order
133
120
  *
134
121
  * Calling `git_status_foreach()` is like calling the extended version
135
122
  * with: GIT_STATUS_OPT_INCLUDE_IGNORED, GIT_STATUS_OPT_INCLUDE_UNTRACKED,
@@ -137,13 +124,17 @@ typedef enum {
137
124
  * together as `GIT_STATUS_OPT_DEFAULTS` if you want them as a baseline.
138
125
  */
139
126
  typedef enum {
140
- GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1u << 0),
141
- GIT_STATUS_OPT_INCLUDE_IGNORED = (1u << 1),
142
- GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1u << 2),
143
- GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1u << 3),
144
- GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1u << 4),
145
- GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1u << 5),
146
- GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1u << 6),
127
+ GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1u << 0),
128
+ GIT_STATUS_OPT_INCLUDE_IGNORED = (1u << 1),
129
+ GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1u << 2),
130
+ GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1u << 3),
131
+ GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1u << 4),
132
+ GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1u << 5),
133
+ GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1u << 6),
134
+ GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = (1u << 7),
135
+ GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = (1u << 8),
136
+ GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = (1u << 9),
137
+ GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1u << 10),
147
138
  } git_status_opt_t;
148
139
 
149
140
  #define GIT_STATUS_OPT_DEFAULTS \
@@ -177,6 +168,47 @@ typedef struct {
177
168
  #define GIT_STATUS_OPTIONS_VERSION 1
178
169
  #define GIT_STATUS_OPTIONS_INIT {GIT_STATUS_OPTIONS_VERSION}
179
170
 
171
+ /**
172
+ * A status entry, providing the differences between the file as it exists
173
+ * in HEAD and the index, and providing the differences between the index
174
+ * and the working directory.
175
+ *
176
+ * The `status` value provides the status flags for this file.
177
+ *
178
+ * The `head_to_index` value provides detailed information about the
179
+ * differences between the file in HEAD and the file in the index.
180
+ *
181
+ * The `index_to_workdir` value provides detailed information about the
182
+ * differences between the file in the index and the file in the
183
+ * working directory.
184
+ */
185
+ typedef struct {
186
+ git_status_t status;
187
+ git_diff_delta *head_to_index;
188
+ git_diff_delta *index_to_workdir;
189
+ } git_status_entry;
190
+
191
+
192
+ /**
193
+ * Gather file statuses and run a callback for each one.
194
+ *
195
+ * The callback is passed the path of the file, the status (a combination of
196
+ * the `git_status_t` values above) and the `payload` data pointer passed
197
+ * into this function.
198
+ *
199
+ * If the callback returns a non-zero value, this function will stop looping
200
+ * and return GIT_EUSER.
201
+ *
202
+ * @param repo A repository object
203
+ * @param callback The function to call on each file
204
+ * @param payload Pointer to pass through to callback function
205
+ * @return 0 on success, GIT_EUSER on non-zero callback, or error code
206
+ */
207
+ GIT_EXTERN(int) git_status_foreach(
208
+ git_repository *repo,
209
+ git_status_cb callback,
210
+ void *payload);
211
+
180
212
  /**
181
213
  * Gather file status information and run callbacks as requested.
182
214
  *
@@ -215,6 +247,49 @@ GIT_EXTERN(int) git_status_file(
215
247
  git_repository *repo,
216
248
  const char *path);
217
249
 
250
+ /**
251
+ * Gather file status information and populate the `git_status_list`.
252
+ *
253
+ * @param out Pointer to store the status results in
254
+ * @param repo Repository object
255
+ * @param opts Status options structure
256
+ * @return 0 on success or error code
257
+ */
258
+ GIT_EXTERN(int) git_status_list_new(
259
+ git_status_list **out,
260
+ git_repository *repo,
261
+ const git_status_options *opts);
262
+
263
+ /**
264
+ * Gets the count of status entries in this list.
265
+ *
266
+ * @param statuslist Existing status list object
267
+ * @return the number of status entries
268
+ */
269
+ GIT_EXTERN(size_t) git_status_list_entrycount(
270
+ git_status_list *statuslist);
271
+
272
+ /**
273
+ * Get a pointer to one of the entries in the status list.
274
+ *
275
+ * The entry is not modifiable and should not be freed.
276
+ *
277
+ * @param statuslist Existing status list object
278
+ * @param idx Position of the entry
279
+ * @return Pointer to the entry; NULL if out of bounds
280
+ */
281
+ GIT_EXTERN(const git_status_entry *) git_status_byindex(
282
+ git_status_list *statuslist,
283
+ size_t idx);
284
+
285
+ /**
286
+ * Free an existing status list
287
+ *
288
+ * @param statuslist Existing status list object
289
+ */
290
+ GIT_EXTERN(void) git_status_list_free(
291
+ git_status_list *statuslist);
292
+
218
293
  /**
219
294
  * Test if the ignore rules apply to a given file.
220
295
  *