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
@@ -9,6 +9,7 @@
9
9
 
10
10
  #include "git2/remote.h"
11
11
  #include "git2/transport.h"
12
+ #include "git2/sys/transport.h"
12
13
 
13
14
  #include "refspec.h"
14
15
  #include "vector.h"
@@ -22,14 +23,17 @@ struct git_remote {
22
23
  git_vector refs;
23
24
  git_vector refspecs;
24
25
  git_vector active_refspecs;
26
+ git_vector passive_refspecs;
27
+ git_transport_cb transport_cb;
28
+ void *transport_cb_payload;
25
29
  git_transport *transport;
26
30
  git_repository *repo;
27
31
  git_remote_callbacks callbacks;
28
32
  git_transfer_progress stats;
29
33
  unsigned int need_pack;
30
34
  git_remote_autotag_option_t download_tags;
31
- int check_cert;
32
35
  int update_fetchhead;
36
+ int passed_refspecs;
33
37
  };
34
38
 
35
39
  const char* git_remote__urlfordirection(struct git_remote *remote, int direction);
@@ -37,9 +37,6 @@
37
37
 
38
38
  #define GIT_REPO_VERSION 0
39
39
 
40
- const char *git_repository__8dot3_default = "GIT~1";
41
- size_t git_repository__8dot3_default_len = 5;
42
-
43
40
  static void set_odb(git_repository *repo, git_odb *odb)
44
41
  {
45
42
  if (odb) {
@@ -123,7 +120,6 @@ void git_repository_free(git_repository *repo)
123
120
  git__free(repo->path_repository);
124
121
  git__free(repo->workdir);
125
122
  git__free(repo->namespace);
126
- git__free(repo->name_8dot3);
127
123
 
128
124
  git__memzero(repo, sizeof(*repo));
129
125
  git__free(repo);
@@ -795,27 +791,6 @@ const char *git_repository_get_namespace(git_repository *repo)
795
791
  return repo->namespace;
796
792
  }
797
793
 
798
- const char *git_repository__8dot3_name(git_repository *repo)
799
- {
800
- if (!repo->has_8dot3) {
801
- repo->has_8dot3 = 1;
802
-
803
- #ifdef GIT_WIN32
804
- if (!repo->is_bare) {
805
- repo->name_8dot3 = git_win32_path_8dot3_name(repo->path_repository);
806
-
807
- /* We anticipate the 8.3 name is "GIT~1", so use a static for
808
- * easy testing in the common case */
809
- if (strcasecmp(repo->name_8dot3, git_repository__8dot3_default) == 0)
810
- repo->has_8dot3_default = 1;
811
- }
812
- #endif
813
- }
814
-
815
- return repo->has_8dot3_default ?
816
- git_repository__8dot3_default : repo->name_8dot3;
817
- }
818
-
819
794
  static int check_repositoryformatversion(git_config *config)
820
795
  {
821
796
  int version;
@@ -1019,7 +994,7 @@ static int repo_init_config(
1019
994
  uint32_t mode)
1020
995
  {
1021
996
  int error = 0;
1022
- git_buf cfg_path = GIT_BUF_INIT;
997
+ git_buf cfg_path = GIT_BUF_INIT, worktree_path = GIT_BUF_INIT;
1023
998
  git_config *config = NULL;
1024
999
  bool is_bare = ((flags & GIT_REPOSITORY_INIT_BARE) != 0);
1025
1000
  bool is_reinit = ((flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0);
@@ -1044,9 +1019,16 @@ static int repo_init_config(
1044
1019
  if (!is_bare) {
1045
1020
  SET_REPO_CONFIG(bool, "core.logallrefupdates", true);
1046
1021
 
1047
- if (!(flags & GIT_REPOSITORY_INIT__NATURAL_WD))
1048
- SET_REPO_CONFIG(string, "core.worktree", work_dir);
1049
- else if (is_reinit) {
1022
+ if (!(flags & GIT_REPOSITORY_INIT__NATURAL_WD)) {
1023
+ if ((error = git_buf_sets(&worktree_path, work_dir)) < 0)
1024
+ goto cleanup;
1025
+
1026
+ if ((flags & GIT_REPOSITORY_INIT_RELATIVE_GITLINK))
1027
+ if ((error = git_path_make_relative(&worktree_path, repo_dir)) < 0)
1028
+ goto cleanup;
1029
+
1030
+ SET_REPO_CONFIG(string, "core.worktree", worktree_path.ptr);
1031
+ } else if (is_reinit) {
1050
1032
  if (git_config_delete_entry(config, "core.worktree") < 0)
1051
1033
  giterr_clear();
1052
1034
  }
@@ -1063,6 +1045,7 @@ static int repo_init_config(
1063
1045
 
1064
1046
  cleanup:
1065
1047
  git_buf_free(&cfg_path);
1048
+ git_buf_free(&worktree_path);
1066
1049
  git_config_free(config);
1067
1050
 
1068
1051
  return error;
@@ -1151,10 +1134,11 @@ static int repo_write_template(
1151
1134
  }
1152
1135
 
1153
1136
  static int repo_write_gitlink(
1154
- const char *in_dir, const char *to_repo)
1137
+ const char *in_dir, const char *to_repo, bool use_relative_path)
1155
1138
  {
1156
1139
  int error;
1157
1140
  git_buf buf = GIT_BUF_INIT;
1141
+ git_buf path_to_repo = GIT_BUF_INIT;
1158
1142
  struct stat st;
1159
1143
 
1160
1144
  git_path_dirname_r(&buf, to_repo);
@@ -1182,13 +1166,20 @@ static int repo_write_gitlink(
1182
1166
 
1183
1167
  git_buf_clear(&buf);
1184
1168
 
1185
- error = git_buf_printf(&buf, "%s %s", GIT_FILE_CONTENT_PREFIX, to_repo);
1169
+ error = git_buf_sets(&path_to_repo, to_repo);
1170
+
1171
+ if (!error && use_relative_path)
1172
+ error = git_path_make_relative(&path_to_repo, in_dir);
1173
+
1174
+ if (!error)
1175
+ error = git_buf_join(&buf, ' ', GIT_FILE_CONTENT_PREFIX, path_to_repo.ptr);
1186
1176
 
1187
1177
  if (!error)
1188
1178
  error = repo_write_template(in_dir, true, DOT_GIT, 0666, true, buf.ptr);
1189
1179
 
1190
1180
  cleanup:
1191
1181
  git_buf_free(&buf);
1182
+ git_buf_free(&path_to_repo);
1192
1183
  return error;
1193
1184
  }
1194
1185
 
@@ -1232,7 +1223,7 @@ static int repo_init_structure(
1232
1223
  if ((opts->flags & GIT_REPOSITORY_INIT_BARE) == 0 &&
1233
1224
  (opts->flags & GIT_REPOSITORY_INIT__NATURAL_WD) == 0)
1234
1225
  {
1235
- if (repo_write_gitlink(work_dir, repo_dir) < 0)
1226
+ if (repo_write_gitlink(work_dir, repo_dir, opts->flags & GIT_REPOSITORY_INIT_RELATIVE_GITLINK) < 0)
1236
1227
  return -1;
1237
1228
  }
1238
1229
 
@@ -1662,7 +1653,7 @@ int git_repository_set_workdir(
1662
1653
  if (git_repository_config__weakptr(&config, repo) < 0)
1663
1654
  return -1;
1664
1655
 
1665
- error = repo_write_gitlink(path.ptr, git_repository_path(repo));
1656
+ error = repo_write_gitlink(path.ptr, git_repository_path(repo), false);
1666
1657
 
1667
1658
  /* passthrough error means gitlink is unnecessary */
1668
1659
  if (error == GIT_PASSTHROUGH)
@@ -1692,6 +1683,32 @@ int git_repository_is_bare(git_repository *repo)
1692
1683
  return repo->is_bare;
1693
1684
  }
1694
1685
 
1686
+ int git_repository_set_bare(git_repository *repo)
1687
+ {
1688
+ int error;
1689
+ git_config *config;
1690
+
1691
+ assert(repo);
1692
+
1693
+ if (repo->is_bare)
1694
+ return 0;
1695
+
1696
+ if ((error = git_repository_config__weakptr(&config, repo)) < 0)
1697
+ return error;
1698
+
1699
+ if ((error = git_config_set_bool(config, "core.bare", false)) < 0)
1700
+ return error;
1701
+
1702
+ if ((error = git_config__update_entry(config, "core.worktree", NULL, true, true)) < 0)
1703
+ return error;
1704
+
1705
+ git__free(repo->workdir);
1706
+ repo->workdir = NULL;
1707
+ repo->is_bare = 1;
1708
+
1709
+ return 0;
1710
+ }
1711
+
1695
1712
  int git_repository_head_tree(git_tree **tree, git_repository *repo)
1696
1713
  {
1697
1714
  git_reference *head;
@@ -1711,6 +1728,28 @@ cleanup:
1711
1728
  return error;
1712
1729
  }
1713
1730
 
1731
+ int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head)
1732
+ {
1733
+ git_filebuf file = GIT_FILEBUF_INIT;
1734
+ git_buf file_path = GIT_BUF_INIT;
1735
+ char orig_head_str[GIT_OID_HEXSZ];
1736
+ int error = 0;
1737
+
1738
+ git_oid_fmt(orig_head_str, orig_head);
1739
+
1740
+ if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_ORIG_HEAD_FILE)) == 0 &&
1741
+ (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_MERGE_FILE_MODE)) == 0 &&
1742
+ (error = git_filebuf_printf(&file, "%.*s\n", GIT_OID_HEXSZ, orig_head_str)) == 0)
1743
+ error = git_filebuf_commit(&file);
1744
+
1745
+ if (error < 0)
1746
+ git_filebuf_cleanup(&file);
1747
+
1748
+ git_buf_free(&file_path);
1749
+
1750
+ return error;
1751
+ }
1752
+
1714
1753
  int git_repository_message(git_buf *out, git_repository *repo)
1715
1754
  {
1716
1755
  git_buf path = GIT_BUF_INIT;
@@ -1942,8 +1981,8 @@ int git_repository_state(git_repository *repo)
1942
1981
  state = GIT_REPOSITORY_STATE_MERGE;
1943
1982
  else if(git_path_contains_file(&repo_path, GIT_REVERT_HEAD_FILE))
1944
1983
  state = GIT_REPOSITORY_STATE_REVERT;
1945
- else if(git_path_contains_file(&repo_path, GIT_CHERRY_PICK_HEAD_FILE))
1946
- state = GIT_REPOSITORY_STATE_CHERRY_PICK;
1984
+ else if(git_path_contains_file(&repo_path, GIT_CHERRYPICK_HEAD_FILE))
1985
+ state = GIT_REPOSITORY_STATE_CHERRYPICK;
1947
1986
  else if(git_path_contains_file(&repo_path, GIT_BISECT_LOG_FILE))
1948
1987
  state = GIT_REPOSITORY_STATE_BISECT;
1949
1988
 
@@ -1985,7 +2024,7 @@ static const char *state_files[] = {
1985
2024
  GIT_MERGE_MODE_FILE,
1986
2025
  GIT_MERGE_MSG_FILE,
1987
2026
  GIT_REVERT_HEAD_FILE,
1988
- GIT_CHERRY_PICK_HEAD_FILE,
2027
+ GIT_CHERRYPICK_HEAD_FILE,
1989
2028
  GIT_BISECT_LOG_FILE,
1990
2029
  GIT_REBASE_MERGE_DIR,
1991
2030
  GIT_REBASE_APPLY_DIR,
@@ -40,8 +40,6 @@ typedef enum {
40
40
  GIT_CVAR_PRECOMPOSE, /* core.precomposeunicode */
41
41
  GIT_CVAR_SAFE_CRLF, /* core.safecrlf */
42
42
  GIT_CVAR_LOGALLREFUPDATES, /* core.logallrefupdates */
43
- GIT_CVAR_PROTECTHFS, /* core.protectHFS */
44
- GIT_CVAR_PROTECTNTFS, /* core.protectNTFS */
45
43
  GIT_CVAR_CACHE_MAX
46
44
  } git_cvar_cached;
47
45
 
@@ -98,10 +96,6 @@ typedef enum {
98
96
  /* core.logallrefupdates */
99
97
  GIT_LOGALLREFUPDATES_UNSET = 2,
100
98
  GIT_LOGALLREFUPDATES_DEFAULT = GIT_LOGALLREFUPDATES_UNSET,
101
- /* core.protectHFS */
102
- GIT_PROTECTHFS_DEFAULT = GIT_CVAR_FALSE,
103
- /* core.protectNTFS */
104
- GIT_PROTECTNTFS_DEFAULT = GIT_CVAR_FALSE,
105
99
  } git_cvar_value;
106
100
 
107
101
  /* internal repository init flags */
@@ -126,11 +120,8 @@ struct git_repository {
126
120
  char *path_repository;
127
121
  char *workdir;
128
122
  char *namespace;
129
- char *name_8dot3;
130
123
 
131
- unsigned is_bare:1,
132
- has_8dot3:1,
133
- has_8dot3_default:1;
124
+ unsigned is_bare:1;
134
125
  unsigned int lru_counter;
135
126
 
136
127
  git_cvar_value cvar_cache[GIT_CVAR_CACHE_MAX];
@@ -179,21 +170,8 @@ GIT_INLINE(int) git_repository__ensure_not_bare(
179
170
  return GIT_EBAREREPO;
180
171
  }
181
172
 
182
- int git_repository__cleanup_files(git_repository *repo, const char *files[], size_t files_len);
183
-
184
- /*
185
- * Gets the DOS-compatible 8.3 "short name". This will return only the
186
- * short name for the repository directory (ie, "git~1" for ".git"). This
187
- * will always return a pointer to `git_repository__8dot3_default` when
188
- * "GIT~1" is the short name. This will return NULL for bare repositories,
189
- * and systems that do not have a short name.
190
- */
191
- const char *git_repository__8dot3_name(git_repository *repo);
173
+ int git_repository__set_orig_head(git_repository *repo, const git_oid *orig_head);
192
174
 
193
- /* The default DOS-compatible 8.3 "short name" for a git repository,
194
- * "GIT~1".
195
- */
196
- extern const char *git_repository__8dot3_default;
197
- extern size_t git_repository__8dot3_default_len;
175
+ int git_repository__cleanup_files(git_repository *repo, const char *files[], size_t files_len);
198
176
 
199
177
  #endif
@@ -100,7 +100,8 @@ int git_reset(
100
100
  git_repository *repo,
101
101
  git_object *target,
102
102
  git_reset_t reset_type,
103
- git_signature *signature,
103
+ git_checkout_options *checkout_opts,
104
+ const git_signature *signature,
104
105
  const char *log_message)
105
106
  {
106
107
  git_object *commit = NULL;
@@ -112,6 +113,9 @@ int git_reset(
112
113
 
113
114
  assert(repo && target);
114
115
 
116
+ if (checkout_opts)
117
+ opts = *checkout_opts;
118
+
115
119
  if (git_object_owner(target) != repo) {
116
120
  giterr_set(GITERR_OBJECT,
117
121
  "%s - The given target does not belong to this repository.", ERROR_MSG);
@@ -174,7 +174,7 @@ int git_revert(
174
174
  char commit_oidstr[GIT_OID_HEXSZ + 1];
175
175
  const char *commit_msg;
176
176
  git_buf their_label = GIT_BUF_INIT;
177
- git_index *index_new = NULL, *index_repo = NULL;
177
+ git_index *index_new = NULL;
178
178
  int error;
179
179
 
180
180
  assert(repo && commit);
@@ -199,10 +199,9 @@ int git_revert(
199
199
  (error = git_repository_head(&our_ref, repo)) < 0 ||
200
200
  (error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJ_COMMIT)) < 0 ||
201
201
  (error = git_revert_commit(&index_new, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 ||
202
- (error = git_merge__indexes(repo, index_new)) < 0 ||
203
- (error = git_repository_index(&index_repo, repo)) < 0 ||
204
- (error = git_merge__append_conflicts_to_merge_msg(repo, index_repo)) < 0 ||
205
- (error = git_checkout_index(repo, index_repo, &opts.checkout_opts)) < 0)
202
+ (error = git_merge__check_result(repo, index_new)) < 0 ||
203
+ (error = git_merge__append_conflicts_to_merge_msg(repo, index_new)) < 0 ||
204
+ (error = git_checkout_index(repo, index_new, &opts.checkout_opts)) < 0)
206
205
  goto on_error;
207
206
 
208
207
  goto done;
@@ -212,7 +211,6 @@ on_error:
212
211
 
213
212
  done:
214
213
  git_index_free(index_new);
215
- git_index_free(index_repo);
216
214
  git_commit_free(our_commit);
217
215
  git_reference_free(our_ref);
218
216
  git_buf_free(&their_label);
@@ -205,7 +205,6 @@ cleanup:
205
205
  static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t identifier)
206
206
  {
207
207
  git_reflog *reflog;
208
- int error = -1;
209
208
  size_t numentries;
210
209
  const git_reflog_entry *entry;
211
210
  bool search_by_pos = (identifier <= 100000000);
@@ -216,21 +215,11 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t ide
216
215
  numentries = git_reflog_entrycount(reflog);
217
216
 
218
217
  if (search_by_pos) {
219
- if (numentries < identifier + 1) {
220
- giterr_set(
221
- GITERR_REFERENCE,
222
- "Reflog for '%s' has only %"PRIuZ" entries, asked for %"PRIuZ,
223
- git_reference_name(ref), numentries, identifier);
224
-
225
- error = GIT_ENOTFOUND;
226
- goto cleanup;
227
- }
218
+ if (numentries < identifier + 1)
219
+ goto notfound;
228
220
 
229
221
  entry = git_reflog_entry_byindex(reflog, identifier);
230
222
  git_oid_cpy(oid, git_reflog_entry_id_new(entry));
231
- error = 0;
232
- goto cleanup;
233
-
234
223
  } else {
235
224
  size_t i;
236
225
  git_time commit_time;
@@ -243,16 +232,24 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t ide
243
232
  continue;
244
233
 
245
234
  git_oid_cpy(oid, git_reflog_entry_id_new(entry));
246
- error = 0;
247
- goto cleanup;
235
+ break;
248
236
  }
249
237
 
250
- error = GIT_ENOTFOUND;
238
+ if (i == numentries)
239
+ goto notfound;
251
240
  }
252
241
 
253
- cleanup:
254
242
  git_reflog_free(reflog);
255
- return error;
243
+ return 0;
244
+
245
+ notfound:
246
+ giterr_set(
247
+ GITERR_REFERENCE,
248
+ "Reflog for '%s' has only %"PRIuZ" entries, asked for %"PRIuZ,
249
+ git_reference_name(ref), numentries, identifier);
250
+
251
+ git_reflog_free(reflog);
252
+ return GIT_ENOTFOUND;
256
253
  }
257
254
 
258
255
  static int retrieve_revobject_from_reflog(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, size_t position)
@@ -116,6 +116,7 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting,
116
116
  int error;
117
117
  git_object *obj, *oobj;
118
118
  git_commit_list_node *commit;
119
+ git_commit_list *list;
119
120
 
120
121
  if ((error = git_object_lookup(&oobj, walk->repo, oid, GIT_OBJ_ANY)) < 0)
121
122
  return error;
@@ -141,14 +142,20 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting,
141
142
  if (commit == NULL)
142
143
  return -1; /* error already reported by failed lookup */
143
144
 
145
+ if (uninteresting)
146
+ walk->did_hide = 1;
147
+ else
148
+ walk->did_push = 1;
149
+
144
150
  commit->uninteresting = uninteresting;
145
- if (walk->one == NULL && !uninteresting) {
146
- walk->one = commit;
147
- } else {
148
- if (git_vector_insert(&walk->twos, commit) < 0)
149
- return -1;
151
+ list = walk->user_input;
152
+ if (git_commit_list_insert(commit, &list) == NULL) {
153
+ giterr_set_oom();
154
+ return -1;
150
155
  }
151
156
 
157
+ walk->user_input = list;
158
+
152
159
  return 0;
153
160
  }
154
161
 
@@ -367,29 +374,97 @@ static int revwalk_next_reverse(git_commit_list_node **object_out, git_revwalk *
367
374
  }
368
375
 
369
376
 
377
+ static int interesting(git_pqueue *list)
378
+ {
379
+ size_t i;
380
+
381
+ for (i = 0; i < git_pqueue_size(list); i++) {
382
+ git_commit_list_node *commit = git_pqueue_get(list, i);
383
+ if (!commit->uninteresting)
384
+ return 1;
385
+ }
386
+
387
+ return 0;
388
+ }
389
+
390
+ static int contains(git_pqueue *list, git_commit_list_node *node)
391
+ {
392
+ size_t i;
393
+
394
+ for (i = 0; i < git_pqueue_size(list); i++) {
395
+ git_commit_list_node *commit = git_pqueue_get(list, i);
396
+ if (commit == node)
397
+ return 1;
398
+ }
399
+
400
+ return 0;
401
+ }
402
+
403
+ static int premark_uninteresting(git_revwalk *walk)
404
+ {
405
+ int error = 0;
406
+ unsigned short i;
407
+ git_pqueue q;
408
+ git_commit_list *list;
409
+ git_commit_list_node *commit, *parent;
410
+
411
+ if ((error = git_pqueue_init(&q, 0, 8, git_commit_list_time_cmp)) < 0)
412
+ return error;
413
+
414
+ for (list = walk->user_input; list; list = list->next) {
415
+ if ((error = git_commit_list_parse(walk, list->item)) < 0)
416
+ goto cleanup;
417
+
418
+ if ((error = git_pqueue_insert(&q, list->item)) < 0)
419
+ goto cleanup;
420
+ }
421
+
422
+ while (interesting(&q)) {
423
+ commit = git_pqueue_pop(&q);
424
+
425
+ for (i = 0; i < commit->out_degree; i++) {
426
+ parent = commit->parents[i];
427
+
428
+ if ((error = git_commit_list_parse(walk, parent)) < 0)
429
+ goto cleanup;
430
+
431
+ if (commit->uninteresting)
432
+ parent->uninteresting = 1;
433
+
434
+ if (contains(&q, parent))
435
+ continue;
436
+
437
+ if ((error = git_pqueue_insert(&q, parent)) < 0)
438
+ goto cleanup;
439
+ }
440
+ }
441
+
442
+ cleanup:
443
+ git_pqueue_free(&q);
444
+ return error;
445
+ }
446
+
370
447
  static int prepare_walk(git_revwalk *walk)
371
448
  {
372
449
  int error;
373
- unsigned int i;
374
- git_commit_list_node *next, *two;
375
-
376
- /*
377
- * If walk->one is NULL, there were no positive references,
378
- * so we know that the walk is already over.
379
- */
380
- if (walk->one == NULL) {
450
+ git_commit_list *list;
451
+ git_commit_list_node *next;
452
+
453
+ /* If there were no pushes, we know that the walk is already over */
454
+ if (!walk->did_push) {
381
455
  giterr_clear();
382
456
  return GIT_ITEROVER;
383
457
  }
384
458
 
385
- if (process_commit(walk, walk->one, walk->one->uninteresting) < 0)
386
- return -1;
459
+ if (walk->did_hide && (error = premark_uninteresting(walk)) < 0)
460
+ return error;
387
461
 
388
- git_vector_foreach(&walk->twos, i, two) {
389
- if (process_commit(walk, two, two->uninteresting) < 0)
462
+ for (list = walk->user_input; list; list = list->next) {
463
+ if (process_commit(walk, list->item, list->item->uninteresting) < 0)
390
464
  return -1;
391
465
  }
392
466
 
467
+
393
468
  if (walk->sorting & GIT_SORT_TOPOLOGICAL) {
394
469
  unsigned short i;
395
470
 
@@ -440,7 +515,6 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
440
515
 
441
516
  if (git_pqueue_init(
442
517
  &walk->iterator_time, 0, 8, git_commit_list_time_cmp) < 0 ||
443
- git_vector_init(&walk->twos, 4, NULL) < 0 ||
444
518
  git_pool_init(&walk->commit_pool, 1,
445
519
  git_pool__suggest_items_per_page(COMMIT_ALLOC) * COMMIT_ALLOC) < 0)
446
520
  return -1;
@@ -470,7 +544,6 @@ void git_revwalk_free(git_revwalk *walk)
470
544
  git_oidmap_free(walk->commits);
471
545
  git_pool_clear(&walk->commit_pool);
472
546
  git_pqueue_free(&walk->iterator_time);
473
- git_vector_free(&walk->twos);
474
547
  git__free(walk);
475
548
  }
476
549
 
@@ -540,16 +613,17 @@ void git_revwalk_reset(git_revwalk *walk)
540
613
  commit->in_degree = 0;
541
614
  commit->topo_delay = 0;
542
615
  commit->uninteresting = 0;
616
+ commit->flags = 0;
543
617
  });
544
618
 
545
619
  git_pqueue_clear(&walk->iterator_time);
546
620
  git_commit_list_free(&walk->iterator_topo);
547
621
  git_commit_list_free(&walk->iterator_rand);
548
622
  git_commit_list_free(&walk->iterator_reverse);
623
+ git_commit_list_free(&walk->user_input);
624
+ walk->first_parent = 0;
549
625
  walk->walking = 0;
550
-
551
- walk->one = NULL;
552
- git_vector_clear(&walk->twos);
626
+ walk->did_push = walk->did_hide = 0;
553
627
  }
554
628
 
555
629
  int git_revwalk_add_hide_cb(