rugged 0.22.0b5 → 0.22.1b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -3
  3. data/ext/rugged/extconf.rb +21 -5
  4. data/ext/rugged/rugged.c +1 -0
  5. data/ext/rugged/rugged.h +8 -0
  6. data/ext/rugged/rugged_backend.c +34 -0
  7. data/ext/rugged/rugged_branch_collection.c +1 -0
  8. data/ext/rugged/rugged_remote.c +37 -86
  9. data/ext/rugged/rugged_remote_collection.c +2 -1
  10. data/ext/rugged/rugged_repo.c +149 -24
  11. data/ext/rugged/rugged_revwalk.c +1 -2
  12. data/ext/rugged/rugged_submodule.c +1 -1
  13. data/ext/rugged/rugged_tree.c +69 -5
  14. data/lib/rugged/version.rb +1 -1
  15. data/vendor/libgit2/CMakeLists.txt +2 -1
  16. data/vendor/libgit2/include/git2.h +0 -1
  17. data/vendor/libgit2/include/git2/checkout.h +8 -0
  18. data/vendor/libgit2/include/git2/merge.h +8 -0
  19. data/vendor/libgit2/include/git2/push.h +0 -110
  20. data/vendor/libgit2/include/git2/remote.h +30 -1
  21. data/vendor/libgit2/include/git2/revert.h +1 -1
  22. data/vendor/libgit2/include/git2/submodule.h +80 -1
  23. data/vendor/libgit2/include/git2/sys/index.h +2 -2
  24. data/vendor/libgit2/include/git2/{threads.h → sys/openssl.h} +10 -12
  25. data/vendor/libgit2/include/git2/sys/refs.h +11 -0
  26. data/vendor/libgit2/include/git2/tree.h +1 -1
  27. data/vendor/libgit2/include/git2/version.h +3 -3
  28. data/vendor/libgit2/src/attr_file.c +3 -1
  29. data/vendor/libgit2/src/buffer.c +2 -1
  30. data/vendor/libgit2/src/checkout.c +135 -39
  31. data/vendor/libgit2/src/checkout.h +7 -0
  32. data/vendor/libgit2/src/config_file.c +5 -7
  33. data/vendor/libgit2/src/crlf.c +2 -0
  34. data/vendor/libgit2/src/describe.c +6 -2
  35. data/vendor/libgit2/src/diff.c +1 -0
  36. data/vendor/libgit2/src/fileops.c +87 -19
  37. data/vendor/libgit2/src/fileops.h +18 -0
  38. data/vendor/libgit2/src/global.c +1 -1
  39. data/vendor/libgit2/src/ident.c +2 -0
  40. data/vendor/libgit2/src/index.c +4 -4
  41. data/vendor/libgit2/src/merge.c +3 -1
  42. data/vendor/libgit2/src/notes.c +1 -1
  43. data/vendor/libgit2/src/pack.c +1 -0
  44. data/vendor/libgit2/src/path.c +17 -12
  45. data/vendor/libgit2/src/path.h +17 -3
  46. data/vendor/libgit2/src/push.h +110 -0
  47. data/vendor/libgit2/src/rebase.c +4 -2
  48. data/vendor/libgit2/src/remote.c +237 -16
  49. data/vendor/libgit2/src/remote.h +2 -0
  50. data/vendor/libgit2/src/repository.c +7 -3
  51. data/vendor/libgit2/src/submodule.c +229 -18
  52. data/vendor/libgit2/src/transports/local.c +61 -2
  53. data/vendor/libgit2/src/transports/smart_protocol.c +5 -3
  54. data/vendor/libgit2/src/tree.c +2 -2
  55. data/vendor/libgit2/src/util.h +13 -2
  56. data/vendor/libgit2/src/win32/mingw-compat.h +2 -0
  57. data/vendor/libgit2/src/win32/path_w32.h +2 -0
  58. metadata +4 -4
  59. data/vendor/libgit2/cmake/Modules/FindLIBSSH2.cmake +0 -44
@@ -227,8 +227,7 @@ static VALUE rb_git_walker_push_range(VALUE self, VALUE range)
227
227
  {
228
228
  git_revwalk *walk;
229
229
  Data_Get_Struct(self, git_revwalk, walk);
230
- int error = git_revwalk_push_range(walk, StringValuePtr(range));
231
- rugged_exception_check(error);
230
+ rugged_exception_check(git_revwalk_push_range(walk, StringValueCStr(range)));
232
231
  return Qnil;
233
232
  }
234
233
 
@@ -862,7 +862,7 @@ static VALUE rb_git_submodule_update_rule(VALUE self)
862
862
  git_submodule_update_t update;
863
863
 
864
864
  Data_Get_Struct(self, git_submodule, submodule);
865
- update = git_submodule_update(submodule);
865
+ update = git_submodule_update_strategy(submodule);
866
866
 
867
867
  return rb_git_subm_update_rule_fromC(update);
868
868
  }
@@ -93,6 +93,69 @@ static VALUE rb_git_tree_entrycount(VALUE self)
93
93
  return INT2FIX(git_tree_entrycount(tree));
94
94
  }
95
95
 
96
+ struct rugged_treecount_cb_payload
97
+ {
98
+ int count;
99
+ int limit;
100
+ };
101
+
102
+ static int rugged__treecount_cb(const char *root, const git_tree_entry *entry, void *data)
103
+ {
104
+ struct rugged_treecount_cb_payload *payload = data;
105
+
106
+ if (payload->limit >= 0 && payload->count >= payload->limit) {
107
+ return -1;
108
+ } else if(git_tree_entry_type(entry) == GIT_OBJ_TREE) {
109
+ return 0;
110
+ } else {
111
+ ++(payload->count);
112
+ return 1;
113
+ }
114
+ }
115
+
116
+ /*
117
+ * call-seq:
118
+ * tree.count_recursive(limit=nil) -> count
119
+ *
120
+ * `limit` - The maximum number of blobs to the count in the repository.
121
+ * Rugged will stop walking the tree after `limit` items to avoid long
122
+ * execution times.
123
+ *
124
+ * Return the number of blobs (up to the limit) contained in the tree and
125
+ * all subtrees.
126
+ */
127
+ static VALUE rb_git_tree_entrycount_recursive(int argc, VALUE* argv, VALUE self)
128
+ {
129
+ git_tree *tree;
130
+ int error;
131
+ struct rugged_treecount_cb_payload payload;
132
+ VALUE rb_limit;
133
+
134
+ Data_Get_Struct(self, git_tree, tree);
135
+
136
+ rb_scan_args(argc, argv, "01", &rb_limit);
137
+
138
+ payload.limit = -1;
139
+ payload.count = 0;
140
+
141
+ if (!NIL_P(rb_limit)) {
142
+ Check_Type(rb_limit, T_FIXNUM);
143
+ payload.limit = FIX2INT(rb_limit);
144
+ }
145
+
146
+
147
+ error = git_tree_walk(tree, GIT_TREEWALK_PRE, &rugged__treecount_cb, (void *)&payload);
148
+
149
+ if (error && giterr_last()->klass == GITERR_CALLBACK) {
150
+ giterr_clear();
151
+ error = 0;
152
+ }
153
+
154
+ rugged_exception_check(error);
155
+
156
+ return INT2FIX(payload.count);
157
+ }
158
+
96
159
  /*
97
160
  * call-seq:
98
161
  * tree[e] -> entry
@@ -631,13 +694,13 @@ static void rb_git_treebuilder_free(git_treebuilder *bld)
631
694
 
632
695
  /*
633
696
  * call-seq:
634
- * TreeBuilder.new(repository, [tree])
697
+ * Tree::Builder.new(repository, [tree])
635
698
  *
636
- * Create a new Rugged::Trebuilder instance to write a tree to
699
+ * Create a new Rugged::Tree::Builder instance to write a tree to
637
700
  * the given +repository+.
638
701
  *
639
- * If an optional +tree+ is given, the returned TreeBuilder will be
640
- * initialized with the entry of +tree+. Otherwise, the TreeBuilder
702
+ * If an optional +tree+ is given, the returned Tree::Builder will be
703
+ * initialized with the entry of +tree+. Otherwise, the Tree::Builder
641
704
  * will be empty and has to be filled manually.
642
705
  */
643
706
  static VALUE rb_git_treebuilder_new(int argc, VALUE *argv, VALUE klass)
@@ -658,7 +721,7 @@ static VALUE rb_git_treebuilder_new(int argc, VALUE *argv, VALUE klass)
658
721
  rugged_check_repo(rb_repo);
659
722
  Data_Get_Struct(rb_repo, git_repository, repo);
660
723
 
661
- error = git_treebuilder_create(&builder, repo, tree);
724
+ error = git_treebuilder_new(&builder, repo, tree);
662
725
  rugged_exception_check(error);
663
726
 
664
727
  rb_builder = Data_Wrap_Struct(klass, NULL, &rb_git_treebuilder_free, builder);
@@ -813,6 +876,7 @@ void Init_rugged_tree(void)
813
876
  */
814
877
  rb_cRuggedTree = rb_define_class_under(rb_mRugged, "Tree", rb_cRuggedObject);
815
878
  rb_define_method(rb_cRuggedTree, "count", rb_git_tree_entrycount, 0);
879
+ rb_define_method(rb_cRuggedTree, "count_recursive", rb_git_tree_entrycount_recursive, -1);
816
880
  rb_define_method(rb_cRuggedTree, "length", rb_git_tree_entrycount, 0);
817
881
  rb_define_method(rb_cRuggedTree, "get_entry", rb_git_tree_get_entry, 1);
818
882
  rb_define_method(rb_cRuggedTree, "get_entry_by_oid", rb_git_tree_get_entry_by_oid, 1);
@@ -1,3 +1,3 @@
1
1
  module Rugged
2
- Version = VERSION = '0.22.0b5'
2
+ Version = VERSION = '0.22.1b1'
3
3
  end
@@ -19,6 +19,7 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Mo
19
19
 
20
20
  INCLUDE(CheckLibraryExists)
21
21
  INCLUDE(AddCFlagIfSupported)
22
+ INCLUDE(FindPkgConfig)
22
23
 
23
24
  # Build options
24
25
  #
@@ -212,7 +213,7 @@ ENDIF()
212
213
 
213
214
  # Optional external dependency: libssh2
214
215
  IF (USE_SSH)
215
- FIND_PACKAGE(LIBSSH2)
216
+ PKG_CHECK_MODULES(LIBSSH2 libssh2)
216
217
  ENDIF()
217
218
  IF (LIBSSH2_FOUND)
218
219
  ADD_DEFINITIONS(-DGIT_SSH)
@@ -57,7 +57,6 @@
57
57
  #include "git2/status.h"
58
58
  #include "git2/submodule.h"
59
59
  #include "git2/tag.h"
60
- #include "git2/threads.h"
61
60
  #include "git2/transport.h"
62
61
  #include "git2/tree.h"
63
62
  #include "git2/types.h"
@@ -104,6 +104,11 @@ GIT_BEGIN_DECL
104
104
  * overwritten. Normally, files that are ignored in the working directory
105
105
  * are not considered "precious" and may be overwritten if the checkout
106
106
  * target contains that file.
107
+ *
108
+ * - GIT_CHECKOUT_DONT_REMOVE_EXISTING prevents checkout from removing
109
+ * files or folders that fold to the same name on case insensitive
110
+ * filesystems. This can cause files to retain their existing names
111
+ * and write through existing symbolic links.
107
112
  */
108
113
  typedef enum {
109
114
  GIT_CHECKOUT_NONE = 0, /**< default is a dry run, no actual updates */
@@ -158,6 +163,9 @@ typedef enum {
158
163
  /** Include common ancestor data in diff3 format files for conflicts */
159
164
  GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = (1u << 21),
160
165
 
166
+ /** Don't overwrite existing files or folders */
167
+ GIT_CHECKOUT_DONT_REMOVE_EXISTING = (1u << 22),
168
+
161
169
  /**
162
170
  * THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
163
171
  */
@@ -479,6 +479,10 @@ GIT_EXTERN(int) git_merge_trees(
479
479
  * or checked out. If the index is to be converted to a tree, the caller
480
480
  * should resolve any conflicts that arose as part of the merge.
481
481
  *
482
+ * The merge performed uses the first common ancestor, unlike the
483
+ * `git-merge-recursive` strategy, which may produce an artificial common
484
+ * ancestor tree when there are multiple ancestors.
485
+ *
482
486
  * The returned index must be freed explicitly with `git_index_free`.
483
487
  *
484
488
  * @param out pointer to store the index result in
@@ -501,6 +505,10 @@ GIT_EXTERN(int) git_merge_commits(
501
505
  * to the index. Callers should inspect the repository's index after this
502
506
  * completes, resolve any conflicts and prepare a commit.
503
507
  *
508
+ * The merge performed uses the first common ancestor, unlike the
509
+ * `git-merge-recursive` strategy, which may produce an artificial common
510
+ * ancestor tree when there are multiple ancestors.
511
+ *
504
512
  * For compatibility with git, the repository is put into a merging
505
513
  * state. Once the commit is done (or if the uses wishes to abort),
506
514
  * you should clear this state by calling
@@ -59,116 +59,6 @@ typedef int (*git_push_transfer_progress)(
59
59
  size_t bytes,
60
60
  void* payload);
61
61
 
62
- /**
63
- * Create a new push object
64
- *
65
- * @param out New push object
66
- * @param remote Remote instance
67
- *
68
- * @return 0 or an error code
69
- */
70
- GIT_EXTERN(int) git_push_new(git_push **out, git_remote *remote);
71
-
72
- /**
73
- * Set options on a push object
74
- *
75
- * @param push The push object
76
- * @param opts The options to set on the push object
77
- *
78
- * @return 0 or an error code
79
- */
80
- GIT_EXTERN(int) git_push_set_options(
81
- git_push *push,
82
- const git_push_options *opts);
83
-
84
- /**
85
- * Set the callbacks for a push
86
- *
87
- * @param push The push object
88
- * @param pack_progress_cb Function to call with progress information during
89
- * pack building. Be aware that this is called inline with pack building
90
- * operations, so performance may be affected.
91
- * @param pack_progress_cb_payload Payload for the pack progress callback.
92
- * @param transfer_progress_cb Function to call with progress information during
93
- * the upload portion of a push. Be aware that this is called inline with
94
- * pack building operations, so performance may be affected.
95
- * @param transfer_progress_cb_payload Payload for the network progress callback.
96
- * @return 0 or an error code
97
- */
98
- GIT_EXTERN(int) git_push_set_callbacks(
99
- git_push *push,
100
- git_packbuilder_progress pack_progress_cb,
101
- void *pack_progress_cb_payload,
102
- git_push_transfer_progress transfer_progress_cb,
103
- void *transfer_progress_cb_payload);
104
-
105
- /**
106
- * Add a refspec to be pushed
107
- *
108
- * @param push The push object
109
- * @param refspec Refspec string
110
- *
111
- * @return 0 or an error code
112
- */
113
- GIT_EXTERN(int) git_push_add_refspec(git_push *push, const char *refspec);
114
-
115
- /**
116
- * Update remote tips after a push
117
- *
118
- * @param push The push object
119
- * @param signature The identity to use when updating reflogs
120
- * @param reflog_message The message to insert into the reflogs. If NULL, the
121
- * default is "update by push".
122
- *
123
- * @return 0 or an error code
124
- */
125
- GIT_EXTERN(int) git_push_update_tips(
126
- git_push *push,
127
- const git_signature *signature,
128
- const char *reflog_message);
129
-
130
- /**
131
- * Perform the push
132
- *
133
- * This function will return an error in case of a protocol error or
134
- * the server being unable to unpack the data we sent.
135
- *
136
- * The return value does not reflect whether the server accepted or
137
- * refused any reference updates. Use `git_push_status_foreach()` in
138
- * order to find out which updates were accepted or rejected.
139
- *
140
- * @param push The push object
141
- *
142
- * @return 0 or an error code
143
- */
144
- GIT_EXTERN(int) git_push_finish(git_push *push);
145
-
146
- /**
147
- * Invoke callback `cb' on each status entry
148
- *
149
- * For each of the updated references, we receive a status report in the
150
- * form of `ok refs/heads/master` or `ng refs/heads/master <msg>`.
151
- * `msg != NULL` means the reference has not been updated for the given
152
- * reason.
153
- *
154
- * Return a non-zero value from the callback to stop the loop.
155
- *
156
- * @param push The push object
157
- * @param cb The callback to call on each object
158
- *
159
- * @return 0 on success, non-zero callback return value, or error code
160
- */
161
- GIT_EXTERN(int) git_push_status_foreach(git_push *push,
162
- int (*cb)(const char *ref, const char *msg, void *data),
163
- void *data);
164
-
165
- /**
166
- * Free the given push object
167
- *
168
- * @param push The push object
169
- */
170
- GIT_EXTERN(void) git_push_free(git_push *push);
171
-
172
62
  /** @} */
173
63
  GIT_END_DECL
174
64
  #endif
@@ -319,6 +319,19 @@ GIT_EXTERN(int) git_remote_ls(const git_remote_head ***out, size_t *size, git_r
319
319
  */
320
320
  GIT_EXTERN(int) git_remote_download(git_remote *remote, const git_strarray *refspecs);
321
321
 
322
+ /**
323
+ * Create a packfile and send it to the server
324
+ *
325
+ * Connect to the remote if it hasn't been done yet, negotiate with
326
+ * the remote git which objects are missing, create a packfile with the missing objects and send it.
327
+ *
328
+ * @param remote the remote
329
+ * @param refspecs the refspecs to use for this negotiation and
330
+ * upload. Use NULL or an empty array to use the base refspecs
331
+ * @return 0 or an error code
332
+ */
333
+ GIT_EXTERN(int) git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts);
334
+
322
335
  /**
323
336
  * Check whether the remote is connected
324
337
  *
@@ -374,6 +387,14 @@ GIT_EXTERN(int) git_remote_update_tips(
374
387
  const git_signature *signature,
375
388
  const char *reflog_message);
376
389
 
390
+ /**
391
+ * Prune tracking refs that are no longer present on remote
392
+ *
393
+ * @param remote the remote to prune
394
+ * @return 0 or an error code
395
+ */
396
+ GIT_EXTERN(int) git_remote_prune(git_remote *remote);
397
+
377
398
  /**
378
399
  * Download new data and update tips
379
400
  *
@@ -407,7 +428,7 @@ GIT_EXTERN(int) git_remote_fetch(
407
428
  * @param reflog_message message to use for the reflog of upated references
408
429
  */
409
430
  GIT_EXTERN(int) git_remote_push(git_remote *remote,
410
- git_strarray *refspecs,
431
+ const git_strarray *refspecs,
411
432
  const git_push_options *opts,
412
433
  const git_signature *signature, const char *reflog_message);
413
434
 
@@ -584,6 +605,14 @@ GIT_EXTERN(void) git_remote_set_autotag(
584
605
  git_remote *remote,
585
606
  git_remote_autotag_option_t value);
586
607
 
608
+ /**
609
+ * Retrieve the ref-prune setting
610
+ *
611
+ * @param remote the remote to query
612
+ * @return the ref-prune setting
613
+ */
614
+ GIT_EXTERN(int) git_remote_prune_refs(const git_remote *remote);
615
+
587
616
  /**
588
617
  * Give the remote a new name
589
618
  *
@@ -71,7 +71,7 @@ GIT_EXTERN(int) git_revert_commit(
71
71
  const git_merge_options *merge_options);
72
72
 
73
73
  /**
74
- * Reverts the given commit, producing changes in the working directory.
74
+ * Reverts the given commit, producing changes in the index and working directory.
75
75
  *
76
76
  * @param repo the repository to revert
77
77
  * @param commit the commit to revert
@@ -10,6 +10,8 @@
10
10
  #include "common.h"
11
11
  #include "types.h"
12
12
  #include "oid.h"
13
+ #include "remote.h"
14
+ #include "checkout.h"
13
15
 
14
16
  /**
15
17
  * @file git2/submodule.h
@@ -105,6 +107,83 @@ typedef enum {
105
107
  GIT_SUBMODULE_STATUS_WD_WD_MODIFIED | \
106
108
  GIT_SUBMODULE_STATUS_WD_UNTRACKED)) != 0)
107
109
 
110
+ /**
111
+ * Submodule update options structure
112
+ *
113
+ * Use the GIT_SUBMODULE_UPDATE_OPTIONS_INIT to get the default settings,
114
+ * like this:
115
+ *
116
+ * git_submodule_update_options opts = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
117
+ */
118
+ typedef struct git_submodule_update_options {
119
+ unsigned int version;
120
+
121
+ /**
122
+ * These options are passed to the checkout step. To disable
123
+ * checkout, set the `checkout_strategy` to
124
+ * `GIT_CHECKOUT_NONE`. Generally you will want the use
125
+ * GIT_CHECKOUT_SAFE to update files in the working
126
+ * directory. Use the `clone_checkout_strategy` field
127
+ * to set the checkout strategy that will be used in
128
+ * the case where update needs to clone the repository.
129
+ */
130
+ git_checkout_options checkout_opts;
131
+
132
+ /**
133
+ * Callbacks to use for reporting fetch progress, and for acquiring
134
+ * credentials in the event they are needed.
135
+ */
136
+ git_remote_callbacks remote_callbacks;
137
+
138
+ /**
139
+ * The checkout strategy to use when the sub repository needs to
140
+ * be cloned. Use GIT_CHECKOUT_SAFE_CREATE to create all files
141
+ * in the working directory for the newly cloned repository.
142
+ */
143
+ unsigned int clone_checkout_strategy;
144
+
145
+ /**
146
+ * The identity used when updating the reflog. NULL means to
147
+ * use the default signature using the config.
148
+ */
149
+ git_signature *signature;
150
+ } git_submodule_update_options;
151
+
152
+ #define GIT_SUBMODULE_UPDATE_OPTIONS_VERSION 1
153
+ #define GIT_SUBMODULE_UPDATE_OPTIONS_INIT \
154
+ { GIT_CHECKOUT_OPTIONS_VERSION, \
155
+ { GIT_CHECKOUT_OPTIONS_VERSION, GIT_CHECKOUT_SAFE}, \
156
+ GIT_REMOTE_CALLBACKS_INIT, GIT_CHECKOUT_SAFE_CREATE }
157
+
158
+ /**
159
+ * Initializes a `git_submodule_update_options` with default values.
160
+ * Equivalent to creating an instance with GIT_SUBMODULE_UPDATE_OPTIONS_INIT.
161
+ *
162
+ * @param opts The `git_submodule_update_options` instance to initialize.
163
+ * @param version Version of struct; pass `GIT_SUBMODULE_UPDATE_OPTIONS_VERSION`
164
+ * @return Zero on success; -1 on failure.
165
+ */
166
+ GIT_EXTERN(int) git_submodule_update_init_options(
167
+ git_submodule_update_options *opts, unsigned int version);
168
+
169
+ /**
170
+ * Update a submodule. This will clone a missing submodule and
171
+ * checkout the subrepository to the commit specified in the index of
172
+ * containing repository.
173
+ *
174
+ * @param submodule Submodule object
175
+ * @param init If the submodule is not initialized, setting this flag to true
176
+ * will initialize the submodule before updating. Otherwise, this will
177
+ * return an error if attempting to update an uninitialzed repository.
178
+ * but setting this to true forces them to be updated.
179
+ * @param options configuration options for the update. If NULL, the
180
+ * function works as though GIT_SUBMODULE_UPDATE_OPTIONS_INIT was passed.
181
+ * @return 0 on success, any non-zero return value from a callback
182
+ * function, or a negative value to indicate an error (use
183
+ * `giterr_last` for a detailed error message).
184
+ */
185
+ GIT_EXTERN(int) git_submodule_update(git_submodule *submodule, int init, git_submodule_update_options *options);
186
+
108
187
  /**
109
188
  * Lookup submodule information by name or path.
110
189
  *
@@ -403,7 +482,7 @@ GIT_EXTERN(git_submodule_ignore_t) git_submodule_set_ignore(
403
482
  * @return The current git_submodule_update_t value that will be used
404
483
  * for this submodule.
405
484
  */
406
- GIT_EXTERN(git_submodule_update_t) git_submodule_update(
485
+ GIT_EXTERN(git_submodule_update_t) git_submodule_update_strategy(
407
486
  git_submodule *submodule);
408
487
 
409
488
  /**