rugged 0.23.0b2 → 0.23.0b4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rugged/rugged_blob.c +39 -0
  3. data/ext/rugged/rugged_diff.c +7 -3
  4. data/ext/rugged/rugged_index.c +2 -2
  5. data/ext/rugged/rugged_remote.c +27 -148
  6. data/ext/rugged/rugged_remote_collection.c +134 -12
  7. data/ext/rugged/rugged_repo.c +74 -5
  8. data/ext/rugged/rugged_submodule.c +18 -208
  9. data/ext/rugged/rugged_submodule_collection.c +148 -0
  10. data/lib/rugged/version.rb +1 -1
  11. data/vendor/libgit2/AUTHORS +1 -0
  12. data/vendor/libgit2/CMakeLists.txt +33 -25
  13. data/vendor/libgit2/deps/winhttp/winhttp.def +29 -29
  14. data/vendor/libgit2/include/git2.h +1 -1
  15. data/vendor/libgit2/include/git2/blob.h +4 -6
  16. data/vendor/libgit2/include/git2/checkout.h +10 -1
  17. data/vendor/libgit2/include/git2/clone.h +6 -7
  18. data/vendor/libgit2/include/git2/commit.h +11 -0
  19. data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
  20. data/vendor/libgit2/include/git2/describe.h +1 -1
  21. data/vendor/libgit2/include/git2/diff.h +68 -11
  22. data/vendor/libgit2/include/git2/errors.h +4 -1
  23. data/vendor/libgit2/include/git2/filter.h +16 -0
  24. data/vendor/libgit2/include/git2/index.h +38 -11
  25. data/vendor/libgit2/include/git2/odb.h +1 -1
  26. data/vendor/libgit2/include/git2/odb_backend.h +2 -2
  27. data/vendor/libgit2/include/git2/remote.h +300 -207
  28. data/vendor/libgit2/include/git2/reset.h +1 -0
  29. data/vendor/libgit2/include/git2/stash.h +135 -4
  30. data/vendor/libgit2/include/git2/status.h +1 -0
  31. data/vendor/libgit2/include/git2/submodule.h +46 -75
  32. data/vendor/libgit2/include/git2/sys/odb_backend.h +1 -1
  33. data/vendor/libgit2/include/git2/sys/stream.h +2 -0
  34. data/vendor/libgit2/include/git2/sys/transport.h +1 -21
  35. data/vendor/libgit2/include/git2/transport.h +27 -0
  36. data/vendor/libgit2/include/git2/types.h +20 -10
  37. data/vendor/libgit2/include/git2/version.h +3 -3
  38. data/vendor/libgit2/libgit2.pc.in +4 -2
  39. data/vendor/libgit2/src/attr.c +2 -1
  40. data/vendor/libgit2/src/attr_file.c +18 -37
  41. data/vendor/libgit2/src/blame.c +2 -2
  42. data/vendor/libgit2/src/blob.c +4 -3
  43. data/vendor/libgit2/src/branch.c +6 -3
  44. data/vendor/libgit2/src/buf_text.c +4 -6
  45. data/vendor/libgit2/src/buf_text.h +1 -2
  46. data/vendor/libgit2/src/buffer.c +8 -6
  47. data/vendor/libgit2/src/buffer.h +1 -1
  48. data/vendor/libgit2/src/cache.c +1 -0
  49. data/vendor/libgit2/src/checkout.c +34 -20
  50. data/vendor/libgit2/src/clone.c +29 -29
  51. data/vendor/libgit2/src/commit.c +65 -0
  52. data/vendor/libgit2/src/common.h +5 -0
  53. data/vendor/libgit2/src/config.c +20 -0
  54. data/vendor/libgit2/src/config.h +6 -0
  55. data/vendor/libgit2/src/config_file.c +2 -2
  56. data/vendor/libgit2/src/crlf.c +39 -17
  57. data/vendor/libgit2/src/curl_stream.c +257 -0
  58. data/vendor/libgit2/src/curl_stream.h +14 -0
  59. data/vendor/libgit2/src/diff.c +223 -88
  60. data/vendor/libgit2/src/diff.h +21 -1
  61. data/vendor/libgit2/src/diff_file.c +23 -13
  62. data/vendor/libgit2/src/diff_file.h +4 -2
  63. data/vendor/libgit2/src/diff_patch.c +266 -71
  64. data/vendor/libgit2/src/diff_patch.h +36 -0
  65. data/vendor/libgit2/src/diff_print.c +156 -126
  66. data/vendor/libgit2/src/diff_tform.c +32 -54
  67. data/vendor/libgit2/src/fetch.c +27 -10
  68. data/vendor/libgit2/src/fetch.h +2 -2
  69. data/vendor/libgit2/src/filebuf.c +1 -1
  70. data/vendor/libgit2/src/fileops.c +6 -2
  71. data/vendor/libgit2/src/filter.c +28 -7
  72. data/vendor/libgit2/src/fnmatch.c +5 -5
  73. data/vendor/libgit2/src/global.c +16 -0
  74. data/vendor/libgit2/src/ident.c +2 -2
  75. data/vendor/libgit2/src/ignore.c +1 -0
  76. data/vendor/libgit2/src/index.c +338 -80
  77. data/vendor/libgit2/src/index.h +4 -1
  78. data/vendor/libgit2/src/indexer.c +19 -5
  79. data/vendor/libgit2/src/iterator.c +118 -11
  80. data/vendor/libgit2/src/iterator.h +25 -0
  81. data/vendor/libgit2/src/merge.c +96 -106
  82. data/vendor/libgit2/src/merge.h +14 -4
  83. data/vendor/libgit2/src/netops.c +3 -3
  84. data/vendor/libgit2/src/odb.c +17 -9
  85. data/vendor/libgit2/src/odb.h +1 -1
  86. data/vendor/libgit2/src/odb_loose.c +2 -2
  87. data/vendor/libgit2/src/odb_pack.c +1 -1
  88. data/vendor/libgit2/src/openssl_stream.c +118 -27
  89. data/vendor/libgit2/src/pack-objects.c +28 -0
  90. data/vendor/libgit2/src/pack-objects.h +1 -0
  91. data/vendor/libgit2/src/pack.c +18 -10
  92. data/vendor/libgit2/src/path.c +16 -11
  93. data/vendor/libgit2/src/path.h +1 -1
  94. data/vendor/libgit2/src/push.c +26 -42
  95. data/vendor/libgit2/src/push.h +2 -34
  96. data/vendor/libgit2/src/rebase.c +1 -1
  97. data/vendor/libgit2/src/refs.c +1 -1
  98. data/vendor/libgit2/src/refspec.c +6 -0
  99. data/vendor/libgit2/src/remote.c +381 -274
  100. data/vendor/libgit2/src/remote.h +0 -4
  101. data/vendor/libgit2/src/repository.c +33 -12
  102. data/vendor/libgit2/src/repository.h +0 -1
  103. data/vendor/libgit2/src/reset.c +1 -0
  104. data/vendor/libgit2/src/stash.c +439 -17
  105. data/vendor/libgit2/src/status.c +6 -0
  106. data/vendor/libgit2/src/stransport_stream.c +58 -21
  107. data/vendor/libgit2/src/stream.h +15 -0
  108. data/vendor/libgit2/src/submodule.c +410 -664
  109. data/vendor/libgit2/src/submodule.h +0 -24
  110. data/vendor/libgit2/src/transaction.c +1 -0
  111. data/vendor/libgit2/src/transports/cred.c +55 -1
  112. data/vendor/libgit2/src/transports/http.c +18 -2
  113. data/vendor/libgit2/src/transports/local.c +60 -59
  114. data/vendor/libgit2/src/transports/smart.h +1 -1
  115. data/vendor/libgit2/src/transports/smart_protocol.c +11 -11
  116. data/vendor/libgit2/src/transports/ssh.c +46 -7
  117. data/vendor/libgit2/src/unix/posix.h +4 -0
  118. data/vendor/libgit2/src/util.c +9 -9
  119. data/vendor/libgit2/src/util.h +9 -0
  120. data/vendor/libgit2/src/win32/posix.h +3 -0
  121. data/vendor/libgit2/src/win32/posix_w32.c +38 -0
  122. data/vendor/libgit2/src/win32/w32_util.h +10 -0
  123. metadata +4 -3
  124. data/vendor/libgit2/include/git2/push.h +0 -94
@@ -38,13 +38,16 @@ typedef enum {
38
38
  GIT_EUNMERGED = -10, /**< Merge in progress prevented operation */
39
39
  GIT_ENONFASTFORWARD = -11, /**< Reference was not fast-forwardable */
40
40
  GIT_EINVALIDSPEC = -12, /**< Name/ref spec was not in a valid format */
41
- GIT_EMERGECONFLICT = -13, /**< Merge conflicts prevented operation */
41
+ GIT_ECONFLICT = -13, /**< Checkout conflicts prevented operation */
42
42
  GIT_ELOCKED = -14, /**< Lock file prevented operation */
43
43
  GIT_EMODIFIED = -15, /**< Reference value does not match expected */
44
44
  GIT_EAUTH = -16, /**< Authentication error */
45
45
  GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */
46
46
  GIT_EAPPLIED = -18, /**< Patch/merge has already been applied */
47
47
  GIT_EPEEL = -19, /**< The requested peel operation is not possible */
48
+ GIT_EEOF = -20, /**< Unexpected EOF */
49
+ GIT_EINVALID = -21, /**< Invalid operation or input */
50
+ GIT_EUNCOMMITTED = -22, /**< Uncommitted changes in index prevented operation */
48
51
 
49
52
  GIT_PASSTHROUGH = -30, /**< Internal only */
50
53
  GIT_ITEROVER = -31, /**< Signals end of iteration with iterator */
@@ -95,6 +95,22 @@ GIT_EXTERN(int) git_filter_list_load(
95
95
  git_filter_mode_t mode,
96
96
  uint32_t flags);
97
97
 
98
+ /**
99
+ * Query the filter list to see if a given filter (by name) will run.
100
+ * The built-in filters "crlf" and "ident" can be queried, otherwise this
101
+ * is the name of the filter specified by the filter attribute.
102
+ *
103
+ * This will return 0 if the given filter is not in the list, or 1 if
104
+ * the filter will be applied.
105
+ *
106
+ * @param filters A loaded git_filter_list (or NULL)
107
+ * @param name The name of the filter to query
108
+ * @return 1 if the filter is in the list, 0 otherwise
109
+ */
110
+ GIT_EXTERN(int) git_filter_list_contains(
111
+ git_filter_list *filters,
112
+ const char *name);
113
+
98
114
  /**
99
115
  * Apply filter list to a data buffer.
100
116
  *
@@ -24,9 +24,9 @@ GIT_BEGIN_DECL
24
24
 
25
25
  /** Time structure used in a git index entry */
26
26
  typedef struct {
27
- git_time_t seconds;
27
+ int32_t seconds;
28
28
  /* nsec should not be stored as time_t compatible */
29
- unsigned int nanoseconds;
29
+ uint32_t nanoseconds;
30
30
  } git_index_time;
31
31
 
32
32
  /**
@@ -44,22 +44,27 @@ typedef struct {
44
44
  * accessed via the later `GIT_IDXENTRY_...` bitmasks below. Some of
45
45
  * these flags are read from and written to disk, but some are set aside
46
46
  * for in-memory only reference.
47
+ *
48
+ * Note that the time and size fields are truncated to 32 bits. This
49
+ * is enough to detect changes, which is enough for the index to
50
+ * function as a cache, but it should not be taken as an authoritative
51
+ * source for that data.
47
52
  */
48
53
  typedef struct git_index_entry {
49
54
  git_index_time ctime;
50
55
  git_index_time mtime;
51
56
 
52
- unsigned int dev;
53
- unsigned int ino;
54
- unsigned int mode;
55
- unsigned int uid;
56
- unsigned int gid;
57
- git_off_t file_size;
57
+ uint32_t dev;
58
+ uint32_t ino;
59
+ uint32_t mode;
60
+ uint32_t uid;
61
+ uint32_t gid;
62
+ uint32_t file_size;
58
63
 
59
64
  git_oid id;
60
65
 
61
- unsigned short flags;
62
- unsigned short flags_extended;
66
+ uint16_t flags;
67
+ uint16_t flags_extended;
63
68
 
64
69
  const char *path;
65
70
  } git_index_entry;
@@ -268,6 +273,18 @@ GIT_EXTERN(int) git_index_write(git_index *index);
268
273
  */
269
274
  GIT_EXTERN(const char *) git_index_path(const git_index *index);
270
275
 
276
+ /**
277
+ * Get the checksum of the index
278
+ *
279
+ * This checksum is the SHA-1 hash over the index file (except the
280
+ * last 20 bytes which are the checksum itself). In cases where the
281
+ * index does not exist on-disk, it will be zeroed out.
282
+ *
283
+ * @param index an existing index object
284
+ * @return a pointer to the checksum of the index
285
+ */
286
+ GIT_EXTERN(const git_oid *) git_index_checksum(git_index *index);
287
+
271
288
  /**
272
289
  * Read a tree into the index file with stats
273
290
  *
@@ -425,6 +442,15 @@ GIT_EXTERN(int) git_index_add(git_index *index, const git_index_entry *source_en
425
442
  */
426
443
  GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry);
427
444
 
445
+ /**
446
+ * Return whether the given index entry is a conflict (has a high stage
447
+ * entry). This is simply shorthand for `git_index_entry_stage > 0`.
448
+ *
449
+ * @param entry The entry
450
+ * @return 1 if the entry is a conflict entry, 0 otherwise
451
+ */
452
+ GIT_EXTERN(int) git_index_entry_is_conflict(const git_index_entry *entry);
453
+
428
454
  /**@}*/
429
455
 
430
456
  /** @name Workdir Index Entry Functions
@@ -626,7 +652,8 @@ GIT_EXTERN(int) git_index_find(size_t *at_pos, git_index *index, const char *pat
626
652
  /**@{*/
627
653
 
628
654
  /**
629
- * Add or update index entries to represent a conflict
655
+ * Add or update index entries to represent a conflict. Any staged
656
+ * entries that exist at the given paths will be removed.
630
657
  *
631
658
  * The entries are the entries from the tree included in the merge. Any
632
659
  * entry may be null to indicate that that file was not present in the
@@ -247,7 +247,7 @@ GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size
247
247
  * @param type type of the object that will be written
248
248
  * @return 0 if the stream was created; error code otherwise
249
249
  */
250
- GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, size_t size, git_otype type);
250
+ GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **out, git_odb *db, git_off_t size, git_otype type);
251
251
 
252
252
  /**
253
253
  * Write to an odb stream
@@ -86,8 +86,8 @@ struct git_odb_stream {
86
86
  unsigned int mode;
87
87
  void *hash_ctx;
88
88
 
89
- size_t declared_size;
90
- size_t received_bytes;
89
+ git_off_t declared_size;
90
+ git_off_t received_bytes;
91
91
 
92
92
  /**
93
93
  * Write at most `len` bytes into `buffer` and advance the stream.
@@ -14,7 +14,7 @@
14
14
  #include "indexer.h"
15
15
  #include "strarray.h"
16
16
  #include "transport.h"
17
- #include "push.h"
17
+ #include "pack.h"
18
18
 
19
19
  /**
20
20
  * @file git2/remote.h
@@ -28,8 +28,7 @@ GIT_BEGIN_DECL
28
28
  typedef int (*git_remote_rename_problem_cb)(const char *problematic_refspec, void *payload);
29
29
 
30
30
  /**
31
- * Add a remote with the default fetch refspec to the repository's configuration. This
32
- * calls git_remote_save before returning.
31
+ * Add a remote with the default fetch refspec to the repository's configuration.
33
32
  *
34
33
  * @param out the resulting remote
35
34
  * @param repo the repository in which to create the remote
@@ -45,8 +44,7 @@ GIT_EXTERN(int) git_remote_create(
45
44
 
46
45
  /**
47
46
  * Add a remote with the provided fetch refspec (or default if NULL) to the repository's
48
- * configuration. This
49
- * calls git_remote_save before returning.
47
+ * configuration.
50
48
  *
51
49
  * @param out the resulting remote
52
50
  * @param repo the repository in which to create the remote
@@ -65,24 +63,18 @@ GIT_EXTERN(int) git_remote_create_with_fetchspec(
65
63
  /**
66
64
  * Create an anonymous remote
67
65
  *
68
- * Create a remote with the given url and refspec in memory. You can use
69
- * this when you have a URL instead of a remote's name. Note that anonymous
70
- * remotes cannot be converted to persisted remotes.
66
+ * Create a remote with the given url in-memory. You can use this when
67
+ * you have a URL instead of a remote's name.
71
68
  *
72
- * The name, when provided, will be checked for validity.
73
- * See `git_tag_create()` for rules about valid names.
74
- *
75
- * @param out pointer to the new remote object
69
+ * @param out pointer to the new remote objects
76
70
  * @param repo the associated repository
77
71
  * @param url the remote repository's URL
78
- * @param fetch the fetch refspec to use for this remote.
79
72
  * @return 0 or an error code
80
73
  */
81
74
  GIT_EXTERN(int) git_remote_create_anonymous(
82
75
  git_remote **out,
83
76
  git_repository *repo,
84
- const char *url,
85
- const char *fetch);
77
+ const char *url);
86
78
 
87
79
  /**
88
80
  * Get the information for a particular remote
@@ -97,17 +89,6 @@ GIT_EXTERN(int) git_remote_create_anonymous(
97
89
  */
98
90
  GIT_EXTERN(int) git_remote_lookup(git_remote **out, git_repository *repo, const char *name);
99
91
 
100
- /**
101
- * Save a remote to its repository's configuration
102
- *
103
- * One can't save a in-memory remote. Doing so will
104
- * result in a GIT_EINVALIDSPEC being returned.
105
- *
106
- * @param remote the remote to save to config
107
- * @return 0, GIT_EINVALIDSPEC or an error code
108
- */
109
- GIT_EXTERN(int) git_remote_save(const git_remote *remote);
110
-
111
92
  /**
112
93
  * Create a copy of an existing remote. All internal strings are also
113
94
  * duplicated. Callbacks are not duplicated.
@@ -139,6 +120,9 @@ GIT_EXTERN(const char *) git_remote_name(const git_remote *remote);
139
120
  /**
140
121
  * Get the remote's url
141
122
  *
123
+ * If url.*.insteadOf has been configured for this URL, it will
124
+ * return the modified URL.
125
+ *
142
126
  * @param remote the remote
143
127
  * @return a pointer to the url
144
128
  */
@@ -147,44 +131,52 @@ GIT_EXTERN(const char *) git_remote_url(const git_remote *remote);
147
131
  /**
148
132
  * Get the remote's url for pushing
149
133
  *
134
+ * If url.*.pushInsteadOf has been configured for this URL, it
135
+ * will return the modified URL.
136
+ *
150
137
  * @param remote the remote
151
138
  * @return a pointer to the url or NULL if no special url for pushing is set
152
139
  */
153
140
  GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote);
154
141
 
155
142
  /**
156
- * Set the remote's url
143
+ * Set the remote's url in the configuration
157
144
  *
158
- * Existing connections will not be updated.
145
+ * Remote objects already in memory will not be affected. This assumes
146
+ * the common case of a single-url remote and will otherwise return an error.
159
147
  *
160
- * @param remote the remote
148
+ * @param repo the repository in which to perform the change
149
+ * @param remote the remote's name
161
150
  * @param url the url to set
162
151
  * @return 0 or an error value
163
152
  */
164
- GIT_EXTERN(int) git_remote_set_url(git_remote *remote, const char* url);
153
+ GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, const char* url);
165
154
 
166
155
  /**
167
- * Set the remote's url for pushing
156
+ * Set the remote's url for pushing in the configuration.
168
157
  *
169
- * Existing connections will not be updated.
158
+ * Remote objects already in memory will not be affected. This assumes
159
+ * the common case of a single-url remote and will otherwise return an error.
170
160
  *
171
- * @param remote the remote
172
- * @param url the url to set or NULL to clear the pushurl
173
- * @return 0 or an error value
161
+ *
162
+ * @param repo the repository in which to perform the change
163
+ * @param remote the remote's name
164
+ * @param url the url to set
174
165
  */
175
- GIT_EXTERN(int) git_remote_set_pushurl(git_remote *remote, const char* url);
166
+ GIT_EXTERN(int) git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url);
176
167
 
177
168
  /**
178
- * Add a fetch refspec to the remote
169
+ * Add a fetch refspec to the remote's configuration
179
170
  *
180
- * Convenience function for adding a single fetch refspec to the
181
- * current list in the remote.
171
+ * Add the given refspec to the fetch list in the configuration. No
172
+ * loaded remote instances will be affected.
182
173
  *
183
- * @param remote the remote
174
+ * @param repo the repository in which to change the configuration
175
+ * @param remote the name of the remote to change
184
176
  * @param refspec the new fetch refspec
185
- * @return 0 or an error value
177
+ * @return 0, GIT_EINVALIDSPEC if refspec is invalid or an error value
186
178
  */
187
- GIT_EXTERN(int) git_remote_add_fetch(git_remote *remote, const char *refspec);
179
+ GIT_EXTERN(int) git_remote_add_fetch(git_repository *repo, const char *remote, const char *refspec);
188
180
 
189
181
  /**
190
182
  * Get the remote's list of fetch refspecs
@@ -198,26 +190,17 @@ GIT_EXTERN(int) git_remote_add_fetch(git_remote *remote, const char *refspec);
198
190
  GIT_EXTERN(int) git_remote_get_fetch_refspecs(git_strarray *array, const git_remote *remote);
199
191
 
200
192
  /**
201
- * Set the remote's list of fetch refspecs
193
+ * Add a push refspec to the remote's configuration
202
194
  *
203
- * The contents of the string array are copied.
195
+ * Add the given refspec to the push list in the configuration. No
196
+ * loaded remote instances will be affected.
204
197
  *
205
- * @param remote the remote to modify
206
- * @param array the new list of fetch resfpecs
207
- */
208
- GIT_EXTERN(int) git_remote_set_fetch_refspecs(git_remote *remote, git_strarray *array);
209
-
210
- /**
211
- * Add a push refspec to the remote
212
- *
213
- * Convenience function for adding a single push refspec to the
214
- * current list in the remote.
215
- *
216
- * @param remote the remote
198
+ * @param repo the repository in which to change the configuration
199
+ * @param remote the name of the remote to change
217
200
  * @param refspec the new push refspec
218
- * @return 0 or an error value
201
+ * @return 0, GIT_EINVALIDSPEC if refspec is invalid or an error value
219
202
  */
220
- GIT_EXTERN(int) git_remote_add_push(git_remote *remote, const char *refspec);
203
+ GIT_EXTERN(int) git_remote_add_push(git_repository *repo, const char *remote, const char *refspec);
221
204
 
222
205
  /**
223
206
  * Get the remote's list of push refspecs
@@ -230,25 +213,6 @@ GIT_EXTERN(int) git_remote_add_push(git_remote *remote, const char *refspec);
230
213
  */
231
214
  GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, const git_remote *remote);
232
215
 
233
- /**
234
- * Set the remote's list of push refspecs
235
- *
236
- * The contents of the string array are copied.
237
- *
238
- * @param remote the remote to modify
239
- * @param array the new list of push resfpecs
240
- */
241
- GIT_EXTERN(int) git_remote_set_push_refspecs(git_remote *remote, git_strarray *array);
242
-
243
- /**
244
- * Clear the refspecs
245
- *
246
- * Remove all configured fetch and push refspecs from the remote.
247
- *
248
- * @param remote the remote
249
- */
250
- GIT_EXTERN(void) git_remote_clear_refspecs(git_remote *remote);
251
-
252
216
  /**
253
217
  * Get the number of refspecs for a remote
254
218
  *
@@ -276,9 +240,10 @@ GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote,
276
240
  * @param remote the remote to connect to
277
241
  * @param direction GIT_DIRECTION_FETCH if you want to fetch or
278
242
  * GIT_DIRECTION_PUSH if you want to push
243
+ * @param callbacks the callbacks to use for this connection
279
244
  * @return 0 or an error code
280
245
  */
281
- GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction);
246
+ GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks);
282
247
 
283
248
  /**
284
249
  * Get the remote repository's reference advertisement list
@@ -302,36 +267,6 @@ GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction);
302
267
  */
303
268
  GIT_EXTERN(int) git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote);
304
269
 
305
- /**
306
- * Download and index the packfile
307
- *
308
- * Connect to the remote if it hasn't been done yet, negotiate with
309
- * the remote git which objects are missing, download and index the
310
- * packfile.
311
- *
312
- * The .idx file will be created and both it and the packfile with be
313
- * renamed to their final name.
314
- *
315
- * @param remote the remote
316
- * @param refspecs the refspecs to use for this negotiation and
317
- * download. Use NULL or an empty array to use the base refspecs
318
- * @return 0 or an error code
319
- */
320
- GIT_EXTERN(int) git_remote_download(git_remote *remote, const git_strarray *refspecs);
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
-
335
270
  /**
336
271
  * Check whether the remote is connected
337
272
  *
@@ -372,60 +307,6 @@ GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
372
307
  */
373
308
  GIT_EXTERN(void) git_remote_free(git_remote *remote);
374
309
 
375
- /**
376
- * Update the tips to the new state
377
- *
378
- * @param remote the remote to update
379
- * @param reflog_message The message to insert into the reflogs. If
380
- * NULL and fetching, the default is "fetch <name>", where <name> is
381
- * the name of the remote (or its url, for in-memory remotes). This
382
- * parameter is ignored when pushing.
383
- * @return 0 or an error code
384
- */
385
- GIT_EXTERN(int) git_remote_update_tips(
386
- git_remote *remote,
387
- const char *reflog_message);
388
-
389
- /**
390
- * Prune tracking refs that are no longer present on remote
391
- *
392
- * @param remote the remote to prune
393
- * @return 0 or an error code
394
- */
395
- GIT_EXTERN(int) git_remote_prune(git_remote *remote);
396
-
397
- /**
398
- * Download new data and update tips
399
- *
400
- * Convenience function to connect to a remote, download the data,
401
- * disconnect and update the remote-tracking branches.
402
- *
403
- * @param remote the remote to fetch from
404
- * @param refspecs the refspecs to use for this fetch. Pass NULL or an
405
- * empty array to use the base refspecs.
406
- * @param reflog_message The message to insert into the reflogs. If NULL, the
407
- * default is "fetch"
408
- * @return 0 or an error code
409
- */
410
- GIT_EXTERN(int) git_remote_fetch(
411
- git_remote *remote,
412
- const git_strarray *refspecs,
413
- const char *reflog_message);
414
-
415
- /**
416
- * Perform a push
417
- *
418
- * Peform all the steps from a push.
419
- *
420
- * @param remote the remote to push to
421
- * @param refspecs the refspecs to use for pushing. If none are
422
- * passed, the configured refspecs will be used
423
- * @param opts the options
424
- */
425
- GIT_EXTERN(int) git_remote_push(git_remote *remote,
426
- const git_strarray *refspecs,
427
- const git_push_options *opts);
428
-
429
310
  /**
430
311
  * Get a list of the configured remotes for a repo
431
312
  *
@@ -447,6 +328,42 @@ typedef enum git_remote_completion_type {
447
328
  GIT_REMOTE_COMPLETION_ERROR,
448
329
  } git_remote_completion_type;
449
330
 
331
+ /** Push network progress notification function */
332
+ typedef int (*git_push_transfer_progress)(
333
+ unsigned int current,
334
+ unsigned int total,
335
+ size_t bytes,
336
+ void* payload);
337
+ /**
338
+ * Represents an update which will be performed on the remote during push
339
+ */
340
+ typedef struct {
341
+ /**
342
+ * The source name of the reference
343
+ */
344
+ char *src_refname;
345
+ /**
346
+ * The name of the reference to update on the server
347
+ */
348
+ char *dst_refname;
349
+ /**
350
+ * The current target of the reference
351
+ */
352
+ git_oid src;
353
+ /**
354
+ * The new target for the reference
355
+ */
356
+ git_oid dst;
357
+ } git_push_update;
358
+
359
+ /**
360
+ * @param updates an array containing the updates which will be sent
361
+ * as commands to the destination.
362
+ * @param len number of elements in `updates`
363
+ * @param payload Payload provided by the caller
364
+ */
365
+ typedef int (*git_push_negotiation)(const git_push_update **updates, size_t len, void *payload);
366
+
450
367
  /**
451
368
  * The callback settings structure
452
369
  *
@@ -526,6 +443,12 @@ struct git_remote_callbacks {
526
443
  */
527
444
  git_push_negotiation push_negotiation;
528
445
 
446
+ /**
447
+ * Create the transport to use for this operation. Leave NULL
448
+ * to auto-detect.
449
+ */
450
+ git_transport_cb transport;
451
+
529
452
  /**
530
453
  * This will be passed to each of the callbacks in this struct
531
454
  * as the last parameter.
@@ -548,44 +471,230 @@ GIT_EXTERN(int) git_remote_init_callbacks(
548
471
  git_remote_callbacks *opts,
549
472
  unsigned int version);
550
473
 
474
+ typedef enum {
475
+ /**
476
+ * Use the setting from the configuration
477
+ */
478
+ GIT_FETCH_PRUNE_UNSPECIFIED,
479
+ /**
480
+ * Force pruning on
481
+ */
482
+ GIT_FETCH_PRUNE,
483
+ /**
484
+ * Force pruning off
485
+ */
486
+ GIT_FETCH_NO_PRUNE,
487
+ } git_fetch_prune_t;
488
+
489
+ /**
490
+ * Automatic tag following option
491
+ *
492
+ * Lets us select the --tags option to use.
493
+ */
494
+ typedef enum {
495
+ /**
496
+ * Use the setting from the configuration.
497
+ */
498
+ GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED = 0,
499
+ /**
500
+ * Ask the server for tags pointing to objects we're already
501
+ * downloading.
502
+ */
503
+ GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
504
+ /**
505
+ * Don't ask for any tags beyond the refspecs.
506
+ */
507
+ GIT_REMOTE_DOWNLOAD_TAGS_NONE,
508
+ /**
509
+ * Ask for the all the tags.
510
+ */
511
+ GIT_REMOTE_DOWNLOAD_TAGS_ALL,
512
+ } git_remote_autotag_option_t;
513
+
514
+ typedef struct {
515
+ int version;
516
+
517
+ /**
518
+ * Callbacks to use for this fetch operation
519
+ */
520
+ git_remote_callbacks callbacks;
521
+
522
+ /**
523
+ * Whether to perform a prune after the fetch
524
+ */
525
+ git_fetch_prune_t prune;
526
+
527
+ /**
528
+ * Whether to write the results to FETCH_HEAD. Defaults to
529
+ * on. Leave this default in order to behave like git.
530
+ */
531
+ int update_fetchhead;
532
+
533
+ /**
534
+ * Determines how to behave regarding tags on the remote, such
535
+ * as auto-downloading tags for objects we're downloading or
536
+ * downloading all of them.
537
+ *
538
+ * The default is to auto-follow tags.
539
+ */
540
+ git_remote_autotag_option_t download_tags;
541
+ } git_fetch_options;
542
+
543
+ #define GIT_FETCH_OPTIONS_VERSION 1
544
+ #define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1 }
545
+
546
+ /**
547
+ * Initializes a `git_fetch_options` with default values. Equivalent to
548
+ * creating an instance with GIT_FETCH_OPTIONS_INIT.
549
+ *
550
+ * @param opts the `git_push_options` instance to initialize.
551
+ * @param version the version of the struct; you should pass
552
+ * `GIT_FETCH_OPTIONS_VERSION` here.
553
+ * @return Zero on success; -1 on failure.
554
+ */
555
+ GIT_EXTERN(int) git_fetch_init_options(
556
+ git_fetch_options *opts,
557
+ unsigned int version);
558
+
559
+
560
+ /**
561
+ * Controls the behavior of a git_push object.
562
+ */
563
+ typedef struct {
564
+ unsigned int version;
565
+
566
+ /**
567
+ * If the transport being used to push to the remote requires the creation
568
+ * of a pack file, this controls the number of worker threads used by
569
+ * the packbuilder when creating that pack file to be sent to the remote.
570
+ *
571
+ * If set to 0, the packbuilder will auto-detect the number of threads
572
+ * to create. The default value is 1.
573
+ */
574
+ unsigned int pb_parallelism;
575
+
576
+ /**
577
+ * Callbacks to use for this push operation
578
+ */
579
+ git_remote_callbacks callbacks;
580
+ } git_push_options;
581
+
582
+ #define GIT_PUSH_OPTIONS_VERSION 1
583
+ #define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT }
584
+
585
+ /**
586
+ * Initializes a `git_push_options` with default values. Equivalent to
587
+ * creating an instance with GIT_PUSH_OPTIONS_INIT.
588
+ *
589
+ * @param opts the `git_push_options` instance to initialize.
590
+ * @param version the version of the struct; you should pass
591
+ * `GIT_PUSH_OPTIONS_VERSION` here.
592
+ * @return Zero on success; -1 on failure.
593
+ */
594
+ GIT_EXTERN(int) git_push_init_options(
595
+ git_push_options *opts,
596
+ unsigned int version);
597
+
551
598
  /**
552
- * Set the callbacks for a remote
599
+ * Download and index the packfile
553
600
  *
554
- * Note that the remote keeps its own copy of the data and you need to
555
- * call this function again if you want to change the callbacks.
601
+ * Connect to the remote if it hasn't been done yet, negotiate with
602
+ * the remote git which objects are missing, download and index the
603
+ * packfile.
604
+ *
605
+ * The .idx file will be created and both it and the packfile with be
606
+ * renamed to their final name.
556
607
  *
557
- * @param remote the remote to configure
558
- * @param callbacks a pointer to the user's callback settings
608
+ * @param remote the remote
609
+ * @param refspecs the refspecs to use for this negotiation and
610
+ * download. Use NULL or an empty array to use the base refspecs
611
+ * @param opts the options to use for this fetch
559
612
  * @return 0 or an error code
560
613
  */
561
- GIT_EXTERN(int) git_remote_set_callbacks(git_remote *remote, const git_remote_callbacks *callbacks);
614
+ GIT_EXTERN(int) git_remote_download(git_remote *remote, const git_strarray *refspecs, const git_fetch_options *opts);
562
615
 
563
616
  /**
564
- * Retrieve the current callback structure
617
+ * Create a packfile and send it to the server
565
618
  *
566
- * This provides read access to the callbacks structure as the remote
567
- * sees it.
619
+ * Connect to the remote if it hasn't been done yet, negotiate with
620
+ * the remote git which objects are missing, create a packfile with the missing objects and send it.
568
621
  *
569
- * @param remote the remote to query
570
- * @return a pointer to the callbacks structure
622
+ * @param remote the remote
623
+ * @param refspecs the refspecs to use for this negotiation and
624
+ * upload. Use NULL or an empty array to use the base refspecs
625
+ * @param opts the options to use for this push
626
+ * @return 0 or an error code
571
627
  */
572
- GIT_EXTERN(const git_remote_callbacks *) git_remote_get_callbacks(git_remote *remote);
628
+ GIT_EXTERN(int) git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts);
573
629
 
574
630
  /**
575
- * Get the statistics structure that is filled in by the fetch operation.
631
+ * Update the tips to the new state
632
+ *
633
+ * @param remote the remote to update
634
+ * @param reflog_message The message to insert into the reflogs. If
635
+ * NULL and fetching, the default is "fetch <name>", where <name> is
636
+ * the name of the remote (or its url, for in-memory remotes). This
637
+ * parameter is ignored when pushing.
638
+ * @param callbacks pointer to the callback structure to use
639
+ * @param update_fetchhead whether to write to FETCH_HEAD. Pass 1 to behave like git.
640
+ * @param download_tags what the behaviour for downloading tags is for this fetch. This is
641
+ * ignored for push. This must be the same value passed to `git_remote_download()`.
642
+ * @return 0 or an error code
576
643
  */
577
- GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
644
+ GIT_EXTERN(int) git_remote_update_tips(
645
+ git_remote *remote,
646
+ const git_remote_callbacks *callbacks,
647
+ int update_fetchhead,
648
+ git_remote_autotag_option_t download_tags,
649
+ const char *reflog_message);
578
650
 
579
651
  /**
580
- * Automatic tag following option
652
+ * Download new data and update tips
581
653
  *
582
- * Lets us select the --tags option to use.
654
+ * Convenience function to connect to a remote, download the data,
655
+ * disconnect and update the remote-tracking branches.
656
+ *
657
+ * @param remote the remote to fetch from
658
+ * @param refspecs the refspecs to use for this fetch. Pass NULL or an
659
+ * empty array to use the base refspecs.
660
+ * @param opts options to use for this fetch
661
+ * @param reflog_message The message to insert into the reflogs. If NULL, the
662
+ * default is "fetch"
663
+ * @return 0 or an error code
583
664
  */
584
- typedef enum {
585
- GIT_REMOTE_DOWNLOAD_TAGS_AUTO = 0,
586
- GIT_REMOTE_DOWNLOAD_TAGS_NONE = 1,
587
- GIT_REMOTE_DOWNLOAD_TAGS_ALL = 2
588
- } git_remote_autotag_option_t;
665
+ GIT_EXTERN(int) git_remote_fetch(
666
+ git_remote *remote,
667
+ const git_strarray *refspecs,
668
+ const git_fetch_options *opts,
669
+ const char *reflog_message);
670
+
671
+ /**
672
+ * Prune tracking refs that are no longer present on remote
673
+ *
674
+ * @param remote the remote to prune
675
+ * @param callbacks callbacks to use for this prune
676
+ * @return 0 or an error code
677
+ */
678
+ GIT_EXTERN(int) git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks);
679
+
680
+ /**
681
+ * Perform a push
682
+ *
683
+ * Peform all the steps from a push.
684
+ *
685
+ * @param remote the remote to push to
686
+ * @param refspecs the refspecs to use for pushing. If none are
687
+ * passed, the configured refspecs will be used
688
+ * @param opts options to use for this push
689
+ */
690
+ GIT_EXTERN(int) git_remote_push(git_remote *remote,
691
+ const git_strarray *refspecs,
692
+ const git_push_options *opts);
693
+
694
+ /**
695
+ * Get the statistics structure that is filled in by the fetch operation.
696
+ */
697
+ GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
589
698
 
590
699
  /**
591
700
  * Retrieve the tag auto-follow setting
@@ -596,15 +705,16 @@ typedef enum {
596
705
  GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(const git_remote *remote);
597
706
 
598
707
  /**
599
- * Set the tag auto-follow setting
708
+ * Set the remote's tag following setting.
709
+ *
710
+ * The change will be made in the configuration. No loaded remotes
711
+ * will be affected.
600
712
  *
601
- * @param remote the remote to configure
602
- * @param value a GIT_REMOTE_DOWNLOAD_TAGS value
713
+ * @param repo the repository in which to make the change
714
+ * @param remote the name of the remote
715
+ * @param value the new value to take.
603
716
  */
604
- GIT_EXTERN(void) git_remote_set_autotag(
605
- git_remote *remote,
606
- git_remote_autotag_option_t value);
607
-
717
+ GIT_EXTERN(int) git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_autotag_option_t value);
608
718
  /**
609
719
  * Retrieve the ref-prune setting
610
720
  *
@@ -639,23 +749,6 @@ GIT_EXTERN(int) git_remote_rename(
639
749
  const char *name,
640
750
  const char *new_name);
641
751
 
642
- /**
643
- * Retrieve the update FETCH_HEAD setting.
644
- *
645
- * @param remote the remote to query
646
- * @return the update FETCH_HEAD setting
647
- */
648
- GIT_EXTERN(int) git_remote_update_fetchhead(git_remote *remote);
649
-
650
- /**
651
- * Sets the update FETCH_HEAD setting. By default, FETCH_HEAD will be
652
- * updated on every fetch. Set to 0 to disable.
653
- *
654
- * @param remote the remote to configure
655
- * @param value 0 to disable updating FETCH_HEAD
656
- */
657
- GIT_EXTERN(void) git_remote_set_update_fetchhead(git_remote *remote, int value);
658
-
659
752
  /**
660
753
  * Ensure the remote name is well-formed.
661
754
  *