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.
- data/README.md +9 -4
- data/Rakefile +1 -1
- data/ext/rugged/extconf.rb +10 -0
- data/ext/rugged/rugged.c +153 -86
- data/ext/rugged/rugged.h +44 -33
- data/ext/rugged/rugged_blob.c +288 -60
- data/ext/rugged/rugged_branch.c +82 -57
- data/ext/rugged/rugged_commit.c +83 -86
- data/ext/rugged/rugged_config.c +68 -68
- data/ext/rugged/rugged_diff.c +509 -0
- data/ext/rugged/rugged_diff_delta.c +94 -0
- data/ext/rugged/rugged_diff_hunk.c +100 -0
- data/ext/rugged/rugged_diff_line.c +79 -0
- data/ext/rugged/rugged_diff_patch.c +169 -0
- data/ext/rugged/rugged_index.c +539 -8
- data/ext/rugged/rugged_note.c +74 -80
- data/ext/rugged/rugged_object.c +63 -8
- data/ext/rugged/rugged_reference.c +231 -145
- data/ext/rugged/rugged_remote.c +509 -53
- data/ext/rugged/rugged_repo.c +572 -236
- data/ext/rugged/rugged_revwalk.c +59 -36
- data/ext/rugged/rugged_settings.c +7 -9
- data/ext/rugged/rugged_signature.c +7 -11
- data/ext/rugged/rugged_tag.c +93 -39
- data/ext/rugged/rugged_tree.c +321 -58
- data/lib/rugged.rb +1 -0
- data/lib/rugged/commit.rb +16 -1
- data/lib/rugged/console.rb +9 -0
- data/lib/rugged/diff.rb +19 -0
- data/lib/rugged/diff/delta.rb +54 -0
- data/lib/rugged/diff/hunk.rb +23 -0
- data/lib/rugged/diff/line.rb +29 -0
- data/lib/rugged/diff/patch.rb +28 -0
- data/lib/rugged/repository.rb +36 -39
- data/lib/rugged/version.rb +1 -1
- data/test/blob_test.rb +308 -1
- data/test/branch_test.rb +7 -0
- data/test/commit_test.rb +7 -10
- data/test/coverage/cover.rb +9 -1
- data/test/diff_test.rb +777 -0
- data/test/fixtures/archive.tar.gz +0 -0
- data/test/fixtures/attr/attr0 +1 -0
- data/test/fixtures/attr/attr1 +29 -0
- data/test/fixtures/attr/attr2 +21 -0
- data/test/fixtures/attr/attr3 +4 -0
- data/test/fixtures/attr/binfile +1 -0
- data/test/fixtures/attr/dir/file +0 -0
- data/test/fixtures/attr/file +1 -0
- data/test/fixtures/attr/gitattributes +29 -0
- data/test/fixtures/attr/gitignore +2 -0
- data/test/fixtures/attr/ign +1 -0
- data/test/fixtures/attr/macro_bad +1 -0
- data/test/fixtures/attr/macro_test +1 -0
- data/test/fixtures/attr/root_test1 +1 -0
- data/test/fixtures/attr/root_test2 +6 -0
- data/test/fixtures/attr/root_test3 +19 -0
- data/test/fixtures/attr/root_test4.txt +14 -0
- data/test/fixtures/attr/sub/abc +37 -0
- data/test/fixtures/attr/sub/dir/file +0 -0
- data/test/fixtures/attr/sub/file +1 -0
- data/test/fixtures/attr/sub/ign/file +1 -0
- data/test/fixtures/attr/sub/ign/sub/file +1 -0
- data/test/fixtures/attr/sub/sub/dir +0 -0
- data/test/fixtures/attr/sub/sub/file +1 -0
- data/test/fixtures/attr/sub/sub/subsub.txt +1 -0
- data/test/fixtures/attr/sub/subdir_test1 +2 -0
- data/test/fixtures/attr/sub/subdir_test2.txt +1 -0
- data/test/fixtures/diff/another.txt +38 -0
- data/test/fixtures/diff/readme.txt +36 -0
- data/test/fixtures/mergedrepo/conflicts-one.txt +5 -0
- data/test/fixtures/mergedrepo/conflicts-two.txt +5 -0
- data/test/fixtures/mergedrepo/one.txt +10 -0
- data/test/fixtures/mergedrepo/two.txt +12 -0
- data/test/fixtures/status/current_file +1 -0
- data/test/fixtures/status/ignored_file +1 -0
- data/test/fixtures/status/modified_file +2 -0
- data/test/fixtures/status/new_file +1 -0
- data/test/fixtures/status/staged_changes +2 -0
- data/test/fixtures/status/staged_changes_modified_file +3 -0
- data/test/fixtures/status/staged_delete_modified_file +1 -0
- data/test/fixtures/status/staged_new_file +1 -0
- data/test/fixtures/status/staged_new_file_modified_file +2 -0
- data/test/fixtures/status/subdir.txt +2 -0
- data/test/fixtures/status/subdir/current_file +1 -0
- data/test/fixtures/status/subdir/modified_file +2 -0
- data/test/fixtures/status/subdir/new_file +1 -0
- data/test/fixtures/status//350/277/231 +1 -0
- data/test/fixtures/testrepo.git/config +5 -0
- data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
- data/test/fixtures/text_file.md +464 -0
- data/test/fixtures/unsymlinked.git/HEAD +1 -0
- data/test/fixtures/unsymlinked.git/config +6 -0
- data/test/fixtures/unsymlinked.git/description +1 -0
- data/test/fixtures/unsymlinked.git/info/exclude +2 -0
- data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
- data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
- data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
- data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
- data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
- data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
- data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
- data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
- data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
- data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +2 -0
- data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
- data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
- data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
- data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
- data/test/fixtures/unsymlinked.git/refs/heads/exe-file +1 -0
- data/test/fixtures/unsymlinked.git/refs/heads/master +1 -0
- data/test/fixtures/unsymlinked.git/refs/heads/reg-file +1 -0
- data/test/index_test.rb +120 -0
- data/test/reference_test.rb +38 -3
- data/test/remote_test.rb +224 -3
- data/test/repo_reset_test.rb +2 -0
- data/test/repo_test.rb +147 -10
- data/test/test_helper.rb +5 -2
- data/vendor/libgit2/include/git2/attr.h +3 -3
- data/vendor/libgit2/include/git2/blob.h +11 -17
- data/vendor/libgit2/include/git2/branch.h +3 -2
- data/vendor/libgit2/include/git2/checkout.h +7 -0
- data/vendor/libgit2/include/git2/clone.h +3 -0
- data/vendor/libgit2/include/git2/commit.h +61 -66
- data/vendor/libgit2/include/git2/common.h +73 -42
- data/vendor/libgit2/include/git2/config.h +57 -71
- data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
- data/vendor/libgit2/include/git2/diff.h +179 -30
- data/vendor/libgit2/include/git2/errors.h +3 -3
- data/vendor/libgit2/include/git2/index.h +225 -146
- data/vendor/libgit2/include/git2/indexer.h +2 -22
- data/vendor/libgit2/include/git2/inttypes.h +9 -9
- data/vendor/libgit2/include/git2/merge.h +123 -5
- data/vendor/libgit2/include/git2/odb.h +59 -38
- data/vendor/libgit2/include/git2/odb_backend.h +45 -104
- data/vendor/libgit2/include/git2/oid.h +30 -19
- data/vendor/libgit2/include/git2/pack.h +21 -3
- data/vendor/libgit2/include/git2/refdb.h +0 -35
- data/vendor/libgit2/include/git2/refs.h +93 -31
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +60 -20
- data/vendor/libgit2/include/git2/repository.h +48 -70
- data/vendor/libgit2/include/git2/reset.h +3 -3
- data/vendor/libgit2/include/git2/revparse.h +22 -0
- data/vendor/libgit2/include/git2/stash.h +1 -1
- data/vendor/libgit2/include/git2/status.h +131 -56
- data/vendor/libgit2/include/git2/strarray.h +2 -2
- data/vendor/libgit2/include/git2/submodule.h +16 -16
- data/vendor/libgit2/include/git2/sys/commit.h +46 -0
- data/vendor/libgit2/include/git2/sys/config.h +71 -0
- data/vendor/libgit2/include/git2/sys/index.h +179 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +86 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +158 -0
- data/vendor/libgit2/include/git2/sys/refs.h +38 -0
- data/vendor/libgit2/include/git2/sys/repository.h +106 -0
- data/vendor/libgit2/include/git2/tag.h +44 -18
- data/vendor/libgit2/include/git2/trace.h +1 -2
- data/vendor/libgit2/include/git2/transport.h +74 -0
- data/vendor/libgit2/include/git2/tree.h +12 -22
- data/vendor/libgit2/include/git2/types.h +33 -0
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/array.h +66 -0
- data/vendor/libgit2/src/attr.c +26 -13
- data/vendor/libgit2/src/attr_file.c +3 -2
- data/vendor/libgit2/src/attr_file.h +3 -3
- data/vendor/libgit2/src/attrcache.h +4 -4
- data/vendor/libgit2/src/blob.c +13 -9
- data/vendor/libgit2/src/blob.h +2 -2
- data/vendor/libgit2/src/branch.c +67 -49
- data/vendor/libgit2/src/cache.c +224 -54
- data/vendor/libgit2/src/cache.h +33 -20
- data/vendor/libgit2/src/checkout.c +145 -85
- data/vendor/libgit2/src/clone.c +62 -50
- data/vendor/libgit2/src/commit.c +74 -40
- data/vendor/libgit2/src/commit.h +2 -3
- data/vendor/libgit2/src/commit_list.c +14 -8
- data/vendor/libgit2/src/config.c +119 -36
- data/vendor/libgit2/src/config.h +3 -0
- data/vendor/libgit2/src/config_cache.c +24 -7
- data/vendor/libgit2/src/config_file.c +9 -6
- data/vendor/libgit2/src/crlf.c +4 -2
- data/vendor/libgit2/src/date.c +3 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/diff.c +681 -303
- data/vendor/libgit2/src/diff.h +34 -2
- data/vendor/libgit2/src/diff_driver.c +405 -0
- data/vendor/libgit2/src/diff_driver.h +49 -0
- data/vendor/libgit2/src/diff_file.c +447 -0
- data/vendor/libgit2/src/diff_file.h +58 -0
- data/vendor/libgit2/src/diff_patch.c +995 -0
- data/vendor/libgit2/src/diff_patch.h +46 -0
- data/vendor/libgit2/src/diff_print.c +430 -0
- data/vendor/libgit2/src/diff_tform.c +464 -203
- data/vendor/libgit2/src/diff_xdiff.c +166 -0
- data/vendor/libgit2/src/diff_xdiff.h +28 -0
- data/vendor/libgit2/src/fetch.c +11 -4
- data/vendor/libgit2/src/fileops.c +85 -61
- data/vendor/libgit2/src/fileops.h +4 -0
- data/vendor/libgit2/src/global.c +10 -2
- data/vendor/libgit2/src/global.h +0 -8
- data/vendor/libgit2/src/hash/hash_generic.h +3 -3
- data/vendor/libgit2/src/hash/hash_win32.h +4 -4
- data/vendor/libgit2/src/hashsig.c +0 -1
- data/vendor/libgit2/src/ignore.c +68 -28
- data/vendor/libgit2/src/ignore.h +10 -1
- data/vendor/libgit2/src/index.c +666 -84
- data/vendor/libgit2/src/index.h +6 -0
- data/vendor/libgit2/src/indexer.c +10 -28
- data/vendor/libgit2/src/iterator.c +427 -283
- data/vendor/libgit2/src/iterator.h +58 -4
- data/vendor/libgit2/src/merge.c +1892 -32
- data/vendor/libgit2/src/merge.h +132 -5
- data/vendor/libgit2/src/merge_file.c +174 -0
- data/vendor/libgit2/src/merge_file.h +71 -0
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/notes.c +45 -48
- data/vendor/libgit2/src/object.c +89 -127
- data/vendor/libgit2/src/object.h +0 -1
- data/vendor/libgit2/src/object_api.c +129 -0
- data/vendor/libgit2/src/odb.c +156 -59
- data/vendor/libgit2/src/odb.h +5 -2
- data/vendor/libgit2/src/odb_loose.c +31 -17
- data/vendor/libgit2/src/odb_pack.c +39 -43
- data/vendor/libgit2/src/oid.c +62 -27
- data/vendor/libgit2/src/oid.h +33 -0
- data/vendor/libgit2/src/oidmap.h +4 -6
- data/vendor/libgit2/src/pack-objects.c +54 -22
- data/vendor/libgit2/src/pack.c +98 -56
- data/vendor/libgit2/src/pack.h +3 -1
- data/vendor/libgit2/src/pathspec.c +26 -1
- data/vendor/libgit2/src/pathspec.h +14 -0
- data/vendor/libgit2/src/pool.c +5 -0
- data/vendor/libgit2/src/posix.c +2 -2
- data/vendor/libgit2/src/posix.h +3 -0
- data/vendor/libgit2/src/push.c +13 -10
- data/vendor/libgit2/src/refdb.c +82 -62
- data/vendor/libgit2/src/refdb.h +16 -16
- data/vendor/libgit2/src/refdb_fs.c +386 -133
- data/vendor/libgit2/src/reflog.c +3 -1
- data/vendor/libgit2/src/refs.c +247 -221
- data/vendor/libgit2/src/refs.h +2 -1
- data/vendor/libgit2/src/refspec.c +18 -1
- data/vendor/libgit2/src/refspec.h +3 -1
- data/vendor/libgit2/src/remote.c +434 -253
- data/vendor/libgit2/src/remote.h +5 -3
- data/vendor/libgit2/src/repository.c +197 -111
- data/vendor/libgit2/src/repository.h +26 -5
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revparse.c +84 -79
- data/vendor/libgit2/src/revwalk.c +1 -1
- data/vendor/libgit2/src/signature.c +22 -10
- data/vendor/libgit2/src/stash.c +5 -2
- data/vendor/libgit2/src/status.c +311 -107
- data/vendor/libgit2/src/status.h +23 -0
- data/vendor/libgit2/src/submodule.c +21 -13
- data/vendor/libgit2/src/tag.c +42 -31
- data/vendor/libgit2/src/tag.h +2 -3
- data/vendor/libgit2/src/thread-utils.h +105 -3
- data/vendor/libgit2/src/trace.c +1 -2
- data/vendor/libgit2/src/trace.h +3 -3
- data/vendor/libgit2/src/transport.c +18 -6
- data/vendor/libgit2/src/transports/cred.c +103 -1
- data/vendor/libgit2/src/transports/local.c +19 -9
- data/vendor/libgit2/src/transports/smart_protocol.c +32 -12
- data/vendor/libgit2/src/transports/ssh.c +519 -0
- data/vendor/libgit2/src/transports/winhttp.c +3 -1
- data/vendor/libgit2/src/tree.c +26 -28
- data/vendor/libgit2/src/tree.h +3 -3
- data/vendor/libgit2/src/unix/posix.h +2 -0
- data/vendor/libgit2/src/util.c +43 -6
- data/vendor/libgit2/src/util.h +40 -12
- data/vendor/libgit2/src/vector.c +3 -5
- data/vendor/libgit2/src/vector.h +9 -0
- data/vendor/libgit2/src/win32/dir.c +1 -1
- data/vendor/libgit2/src/win32/error.c +2 -0
- data/vendor/libgit2/src/win32/findfile.c +3 -6
- data/vendor/libgit2/src/win32/posix_w32.c +85 -59
- data/vendor/libgit2/src/win32/pthread.c +16 -8
- data/vendor/libgit2/src/win32/pthread.h +7 -4
- metadata +407 -306
- data/test/coverage/HEAD.json +0 -1
- data/vendor/libgit2/include/git2/refdb_backend.h +0 -109
- data/vendor/libgit2/src/diff_output.c +0 -1819
- data/vendor/libgit2/src/diff_output.h +0 -93
@@ -85,10 +85,21 @@ GIT_EXTERN(void) git_oid_fromraw(git_oid *out, const unsigned char *raw);
|
|
85
85
|
* needed for an oid encoded in hex (40 bytes). Only the
|
86
86
|
* oid digits are written; a '\\0' terminator must be added
|
87
87
|
* by the caller if it is required.
|
88
|
-
* @param
|
88
|
+
* @param id oid structure to format.
|
89
89
|
*/
|
90
90
|
GIT_EXTERN(void) git_oid_fmt(char *out, const git_oid *id);
|
91
91
|
|
92
|
+
/**
|
93
|
+
* Format a git_oid into a partial hex string.
|
94
|
+
*
|
95
|
+
* @param out output hex string; you say how many bytes to write.
|
96
|
+
* If the number of bytes is > GIT_OID_HEXSZ, extra bytes
|
97
|
+
* will be zeroed; if not, a '\0' terminator is NOT added.
|
98
|
+
* @param n number of characters to write into out string
|
99
|
+
* @param id oid structure to format.
|
100
|
+
*/
|
101
|
+
GIT_EXTERN(void) git_oid_nfmt(char *out, size_t n, const git_oid *id);
|
102
|
+
|
92
103
|
/**
|
93
104
|
* Format a git_oid into a loose-object path string.
|
94
105
|
*
|
@@ -107,7 +118,7 @@ GIT_EXTERN(void) git_oid_pathfmt(char *out, const git_oid *id);
|
|
107
118
|
/**
|
108
119
|
* Format a git_oid into a newly allocated c-string.
|
109
120
|
*
|
110
|
-
* @param
|
121
|
+
* @param id the oid structure to format
|
111
122
|
* @return the c-string; NULL if memory is exhausted. Caller must
|
112
123
|
* deallocate the string with git__free().
|
113
124
|
*/
|
@@ -117,10 +128,12 @@ GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *id);
|
|
117
128
|
* Format a git_oid into a buffer as a hex format c-string.
|
118
129
|
*
|
119
130
|
* If the buffer is smaller than GIT_OID_HEXSZ+1, then the resulting
|
120
|
-
* oid c-string will be truncated to n-1 characters
|
121
|
-
*
|
122
|
-
*
|
123
|
-
*
|
131
|
+
* oid c-string will be truncated to n-1 characters (but will still be
|
132
|
+
* NUL-byte terminated).
|
133
|
+
*
|
134
|
+
* If there are any input parameter errors (out == NULL, n == 0, oid ==
|
135
|
+
* NULL), then a pointer to an empty string is returned, so that the
|
136
|
+
* return value can always be printed.
|
124
137
|
*
|
125
138
|
* @param out the buffer into which the oid string is output.
|
126
139
|
* @param n the size of the out buffer.
|
@@ -145,19 +158,7 @@ GIT_EXTERN(void) git_oid_cpy(git_oid *out, const git_oid *src);
|
|
145
158
|
* @param b second oid structure.
|
146
159
|
* @return <0, 0, >0 if a < b, a == b, a > b.
|
147
160
|
*/
|
148
|
-
|
149
|
-
{
|
150
|
-
const unsigned char *sha1 = a->id;
|
151
|
-
const unsigned char *sha2 = b->id;
|
152
|
-
int i;
|
153
|
-
|
154
|
-
for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) {
|
155
|
-
if (*sha1 != *sha2)
|
156
|
-
return *sha1 - *sha2;
|
157
|
-
}
|
158
|
-
|
159
|
-
return 0;
|
160
|
-
}
|
161
|
+
GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b);
|
161
162
|
|
162
163
|
/**
|
163
164
|
* Compare two oid structures for equality
|
@@ -192,6 +193,16 @@ GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len);
|
|
192
193
|
*/
|
193
194
|
GIT_EXTERN(int) git_oid_streq(const git_oid *id, const char *str);
|
194
195
|
|
196
|
+
/**
|
197
|
+
* Compare an oid to an hex formatted object id.
|
198
|
+
*
|
199
|
+
* @param id oid structure.
|
200
|
+
* @param str input hex string of an object id.
|
201
|
+
* @return -1 if str is not valid, <0 if id sorts before str,
|
202
|
+
* 0 if id matches str, >0 if id sorts after str.
|
203
|
+
*/
|
204
|
+
GIT_EXTERN(int) git_oid_strcmp(const git_oid *id, const char *str);
|
205
|
+
|
195
206
|
/**
|
196
207
|
* Check is an oid is all zeros.
|
197
208
|
*
|
@@ -95,14 +95,32 @@ GIT_EXTERN(int) git_packbuilder_insert(git_packbuilder *pb, const git_oid *id, c
|
|
95
95
|
GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *id);
|
96
96
|
|
97
97
|
/**
|
98
|
-
*
|
98
|
+
* Insert a commit object
|
99
|
+
*
|
100
|
+
* This will add a commit as well as the completed referenced tree.
|
101
|
+
*
|
102
|
+
* @param pb The packbuilder
|
103
|
+
* @param id The oid of the commit
|
104
|
+
*
|
105
|
+
* @return 0 or an error code
|
106
|
+
*/
|
107
|
+
GIT_EXTERN(int) git_packbuilder_insert_commit(git_packbuilder *pb, const git_oid *id);
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Write the new pack and corresponding index file to path.
|
99
111
|
*
|
100
112
|
* @param pb The packbuilder
|
101
|
-
* @param path
|
113
|
+
* @param path to the directory where the packfile and index should be stored
|
114
|
+
* @param progress_cb function to call with progress information from the indexer (optional)
|
115
|
+
* @param progress_cb_payload payload for the progress callback (optional)
|
102
116
|
*
|
103
117
|
* @return 0 or an error code
|
104
118
|
*/
|
105
|
-
GIT_EXTERN(int) git_packbuilder_write(
|
119
|
+
GIT_EXTERN(int) git_packbuilder_write(
|
120
|
+
git_packbuilder *pb,
|
121
|
+
const char *path,
|
122
|
+
git_transfer_progress_callback progress_cb,
|
123
|
+
void *progress_cb_payload);
|
106
124
|
|
107
125
|
typedef int (*git_packbuilder_foreach_cb)(void *buf, size_t size, void *payload);
|
108
126
|
/**
|
@@ -21,27 +21,6 @@
|
|
21
21
|
*/
|
22
22
|
GIT_BEGIN_DECL
|
23
23
|
|
24
|
-
/**
|
25
|
-
* Create a new reference. Either an oid or a symbolic target must be
|
26
|
-
* specified.
|
27
|
-
*
|
28
|
-
* @param refdb the reference database to associate with this reference
|
29
|
-
* @param name the reference name
|
30
|
-
* @param oid the object id for a direct reference
|
31
|
-
* @param symbolic the target for a symbolic reference
|
32
|
-
* @return the created git_reference or NULL on error
|
33
|
-
*/
|
34
|
-
GIT_EXTERN(git_reference *) git_reference__alloc(
|
35
|
-
git_refdb *refdb,
|
36
|
-
const char *name,
|
37
|
-
const git_oid *oid,
|
38
|
-
const git_oid *peel);
|
39
|
-
|
40
|
-
GIT_EXTERN(git_reference *) git_reference__alloc_symbolic(
|
41
|
-
git_refdb *refdb,
|
42
|
-
const char *name,
|
43
|
-
const char *target);
|
44
|
-
|
45
24
|
/**
|
46
25
|
* Create a new reference database with no backends.
|
47
26
|
*
|
@@ -83,20 +62,6 @@ GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb);
|
|
83
62
|
*/
|
84
63
|
GIT_EXTERN(void) git_refdb_free(git_refdb *refdb);
|
85
64
|
|
86
|
-
/**
|
87
|
-
* Sets the custom backend to an existing reference DB
|
88
|
-
*
|
89
|
-
* Read <refdb_backends.h> for more information.
|
90
|
-
*
|
91
|
-
* @param refdb database to add the backend to
|
92
|
-
* @param backend pointer to a git_refdb_backend instance
|
93
|
-
* @param priority Value for ordering the backends queue
|
94
|
-
* @return 0 on success; error code otherwise
|
95
|
-
*/
|
96
|
-
GIT_EXTERN(int) git_refdb_set_backend(
|
97
|
-
git_refdb *refdb,
|
98
|
-
git_refdb_backend *backend);
|
99
|
-
|
100
65
|
/** @} */
|
101
66
|
GIT_END_DECL
|
102
67
|
|
@@ -48,12 +48,25 @@ GIT_EXTERN(int) git_reference_lookup(git_reference **out, git_repository *repo,
|
|
48
48
|
*
|
49
49
|
* @param out Pointer to oid to be filled in
|
50
50
|
* @param repo The repository in which to look up the reference
|
51
|
-
* @param name The long name for the reference
|
51
|
+
* @param name The long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...)
|
52
52
|
* @return 0 on success, ENOTFOUND, EINVALIDSPEC or an error code.
|
53
53
|
*/
|
54
54
|
GIT_EXTERN(int) git_reference_name_to_id(
|
55
55
|
git_oid *out, git_repository *repo, const char *name);
|
56
56
|
|
57
|
+
/**
|
58
|
+
* Lookup a reference by DWIMing its short name
|
59
|
+
*
|
60
|
+
* Apply the git precendence rules to the given shorthand to determine
|
61
|
+
* which reference the user is refering to.
|
62
|
+
*
|
63
|
+
* @param out pointer in which to store the reference
|
64
|
+
* @param repo the repository in which to look
|
65
|
+
* @param shorthand the short name for the reference
|
66
|
+
* @return 0 or an error code
|
67
|
+
*/
|
68
|
+
GIT_EXTERN(int) git_reference_dwim(git_reference **out, git_repository *repo, const char *shorthand);
|
69
|
+
|
57
70
|
/**
|
58
71
|
* Create a new symbolic reference.
|
59
72
|
*
|
@@ -185,7 +198,7 @@ GIT_EXTERN(const char *) git_reference_name(const git_reference *ref);
|
|
185
198
|
* If a direct reference is passed as an argument, a copy of that
|
186
199
|
* reference is returned. This copy must be manually freed too.
|
187
200
|
*
|
188
|
-
* @param
|
201
|
+
* @param out Pointer to the peeled reference
|
189
202
|
* @param ref The reference
|
190
203
|
* @return 0 or an error code
|
191
204
|
*/
|
@@ -244,11 +257,6 @@ GIT_EXTERN(int) git_reference_set_target(
|
|
244
257
|
* The new name will be checked for validity.
|
245
258
|
* See `git_reference_create_symbolic()` for rules about valid names.
|
246
259
|
*
|
247
|
-
* On success, the given git_reference will be deleted from disk and a
|
248
|
-
* new `git_reference` will be returned.
|
249
|
-
*
|
250
|
-
* The reference will be immediately renamed in-memory and on disk.
|
251
|
-
*
|
252
260
|
* If the `force` flag is not enabled, and there's already
|
253
261
|
* a reference with the given name, the renaming will fail.
|
254
262
|
*
|
@@ -258,13 +266,13 @@ GIT_EXTERN(int) git_reference_set_target(
|
|
258
266
|
* the reflog if it exists.
|
259
267
|
*
|
260
268
|
* @param ref The reference to rename
|
261
|
-
* @param
|
269
|
+
* @param new_name The new name for the reference
|
262
270
|
* @param force Overwrite an existing reference
|
263
271
|
* @return 0 on success, EINVALIDSPEC, EEXISTS or an error code
|
264
272
|
*
|
265
273
|
*/
|
266
274
|
GIT_EXTERN(int) git_reference_rename(
|
267
|
-
git_reference **
|
275
|
+
git_reference **new_ref,
|
268
276
|
git_reference *ref,
|
269
277
|
const char *new_name,
|
270
278
|
int force);
|
@@ -284,12 +292,6 @@ GIT_EXTERN(int) git_reference_delete(git_reference *ref);
|
|
284
292
|
/**
|
285
293
|
* Fill a list with all the references that can be found in a repository.
|
286
294
|
*
|
287
|
-
* Using the `list_flags` parameter, the listed references may be filtered
|
288
|
-
* by type (`GIT_REF_OID` or `GIT_REF_SYMBOLIC`) or using a bitwise OR of
|
289
|
-
* `git_ref_t` values. To include packed refs, include `GIT_REF_PACKED`.
|
290
|
-
* For convenience, use the value `GIT_REF_LISTALL` to obtain all
|
291
|
-
* references, including packed ones.
|
292
|
-
*
|
293
295
|
* The string array will be filled with the names of all references; these
|
294
296
|
* values are owned by the user and should be free'd manually when no
|
295
297
|
* longer needed, using `git_strarray_free()`.
|
@@ -297,39 +299,36 @@ GIT_EXTERN(int) git_reference_delete(git_reference *ref);
|
|
297
299
|
* @param array Pointer to a git_strarray structure where
|
298
300
|
* the reference names will be stored
|
299
301
|
* @param repo Repository where to find the refs
|
300
|
-
* @param list_flags Filtering flags for the reference listing
|
301
302
|
* @return 0 or an error code
|
302
303
|
*/
|
303
|
-
GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo
|
304
|
+
GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo);
|
304
305
|
|
305
|
-
typedef int (*git_reference_foreach_cb)(
|
306
|
+
typedef int (*git_reference_foreach_cb)(git_reference *reference, void *payload);
|
307
|
+
typedef int (*git_reference_foreach_name_cb)(const char *name, void *payload);
|
306
308
|
|
307
309
|
/**
|
308
310
|
* Perform a callback on each reference in the repository.
|
309
311
|
*
|
310
|
-
* Using the `list_flags` parameter, the references may be filtered by
|
311
|
-
* type (`GIT_REF_OID` or `GIT_REF_SYMBOLIC`) or using a bitwise OR of
|
312
|
-
* `git_ref_t` values. To include packed refs, include `GIT_REF_PACKED`.
|
313
|
-
* For convenience, use the value `GIT_REF_LISTALL` to obtain all
|
314
|
-
* references, including packed ones.
|
315
|
-
*
|
316
312
|
* The `callback` function will be called for each reference in the
|
317
313
|
* repository, receiving the name of the reference and the `payload` value
|
318
314
|
* passed to this method. Returning a non-zero value from the callback
|
319
315
|
* will terminate the iteration.
|
320
316
|
*
|
321
317
|
* @param repo Repository where to find the refs
|
322
|
-
* @param list_flags Filtering flags for the reference listing.
|
323
318
|
* @param callback Function which will be called for every listed ref
|
324
319
|
* @param payload Additional data to pass to the callback
|
325
320
|
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
|
326
321
|
*/
|
327
322
|
GIT_EXTERN(int) git_reference_foreach(
|
328
323
|
git_repository *repo,
|
329
|
-
unsigned int list_flags,
|
330
324
|
git_reference_foreach_cb callback,
|
331
325
|
void *payload);
|
332
326
|
|
327
|
+
GIT_EXTERN(int) git_reference_foreach_name(
|
328
|
+
git_repository *repo,
|
329
|
+
git_reference_foreach_name_cb callback,
|
330
|
+
void *payload);
|
331
|
+
|
333
332
|
/**
|
334
333
|
* Free the given reference.
|
335
334
|
*
|
@@ -346,6 +345,49 @@ GIT_EXTERN(void) git_reference_free(git_reference *ref);
|
|
346
345
|
*/
|
347
346
|
GIT_EXTERN(int) git_reference_cmp(git_reference *ref1, git_reference *ref2);
|
348
347
|
|
348
|
+
/**
|
349
|
+
* Create an iterator for the repo's references
|
350
|
+
*
|
351
|
+
* @param out pointer in which to store the iterator
|
352
|
+
* @param repo the repository
|
353
|
+
* @return 0 or an error code
|
354
|
+
*/
|
355
|
+
GIT_EXTERN(int) git_reference_iterator_new(
|
356
|
+
git_reference_iterator **out,
|
357
|
+
git_repository *repo);
|
358
|
+
|
359
|
+
/**
|
360
|
+
* Create an iterator for the repo's references that match the
|
361
|
+
* specified glob
|
362
|
+
*
|
363
|
+
* @param out pointer in which to store the iterator
|
364
|
+
* @param repo the repository
|
365
|
+
* @param glob the glob to match against the reference names
|
366
|
+
* @return 0 or an error code
|
367
|
+
*/
|
368
|
+
GIT_EXTERN(int) git_reference_iterator_glob_new(
|
369
|
+
git_reference_iterator **out,
|
370
|
+
git_repository *repo,
|
371
|
+
const char *glob);
|
372
|
+
|
373
|
+
/**
|
374
|
+
* Get the next reference
|
375
|
+
*
|
376
|
+
* @param out pointer in which to store the reference
|
377
|
+
* @param iter the iterator
|
378
|
+
* @return 0, GIT_ITEROVER if there are no more; or an error code
|
379
|
+
*/
|
380
|
+
GIT_EXTERN(int) git_reference_next(git_reference **out, git_reference_iterator *iter);
|
381
|
+
|
382
|
+
GIT_EXTERN(int) git_reference_next_name(const char **out, git_reference_iterator *iter);
|
383
|
+
|
384
|
+
/**
|
385
|
+
* Free the iterator and its associated resources
|
386
|
+
*
|
387
|
+
* @param iter the iterator to free
|
388
|
+
*/
|
389
|
+
GIT_EXTERN(void) git_reference_iterator_free(git_reference_iterator *iter);
|
390
|
+
|
349
391
|
/**
|
350
392
|
* Perform a callback on each reference in the repository whose name
|
351
393
|
* matches the given pattern.
|
@@ -360,7 +402,6 @@ GIT_EXTERN(int) git_reference_cmp(git_reference *ref1, git_reference *ref2);
|
|
360
402
|
*
|
361
403
|
* @param repo Repository where to find the refs
|
362
404
|
* @param glob Pattern to match (fnmatch-style) against reference name.
|
363
|
-
* @param list_flags Filtering flags for the reference listing.
|
364
405
|
* @param callback Function which will be called for every listed ref
|
365
406
|
* @param payload Additional data to pass to the callback
|
366
407
|
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
|
@@ -368,8 +409,7 @@ GIT_EXTERN(int) git_reference_cmp(git_reference *ref1, git_reference *ref2);
|
|
368
409
|
GIT_EXTERN(int) git_reference_foreach_glob(
|
369
410
|
git_repository *repo,
|
370
411
|
const char *glob,
|
371
|
-
|
372
|
-
git_reference_foreach_cb callback,
|
412
|
+
git_reference_foreach_name_cb callback,
|
373
413
|
void *payload);
|
374
414
|
|
375
415
|
/**
|
@@ -422,6 +462,13 @@ typedef enum {
|
|
422
462
|
* (e.g., foo/<star>/bar but not foo/bar<star>).
|
423
463
|
*/
|
424
464
|
GIT_REF_FORMAT_REFSPEC_PATTERN = (1 << 1),
|
465
|
+
|
466
|
+
/**
|
467
|
+
* Interpret the name as part of a refspec in shorthand form
|
468
|
+
* so the `ONELEVEL` naming rules aren't enforced and 'master'
|
469
|
+
* becomes a valid name.
|
470
|
+
*/
|
471
|
+
GIT_REF_FORMAT_REFSPEC_SHORTHAND = (1 << 2),
|
425
472
|
} git_reference_normalize_t;
|
426
473
|
|
427
474
|
/**
|
@@ -459,9 +506,9 @@ GIT_EXTERN(int) git_reference_normalize_name(
|
|
459
506
|
* If you pass `GIT_OBJ_ANY` as the target type, then the object
|
460
507
|
* will be peeled until a non-tag object is met.
|
461
508
|
*
|
462
|
-
* @param
|
509
|
+
* @param out Pointer to the peeled git_object
|
463
510
|
* @param ref The reference to be processed
|
464
|
-
* @param
|
511
|
+
* @param type The type of the requested object (GIT_OBJ_COMMIT,
|
465
512
|
* GIT_OBJ_TAG, GIT_OBJ_TREE, GIT_OBJ_BLOB or GIT_OBJ_ANY).
|
466
513
|
* @return 0 on success, GIT_EAMBIGUOUS, GIT_ENOTFOUND or an error code
|
467
514
|
*/
|
@@ -486,6 +533,21 @@ GIT_EXTERN(int) git_reference_peel(
|
|
486
533
|
*/
|
487
534
|
GIT_EXTERN(int) git_reference_is_valid_name(const char *refname);
|
488
535
|
|
536
|
+
/**
|
537
|
+
* Get the reference's short name
|
538
|
+
*
|
539
|
+
* This will transform the reference name into a name "human-readable"
|
540
|
+
* version. If no shortname is appropriate, it will return the full
|
541
|
+
* name.
|
542
|
+
*
|
543
|
+
* The memory is owned by the reference and must not be freed.
|
544
|
+
*
|
545
|
+
* @param ref a reference
|
546
|
+
* @return the human-readable version of the name
|
547
|
+
*/
|
548
|
+
GIT_EXTERN(const char *) git_reference_shorthand(git_reference *ref);
|
549
|
+
|
550
|
+
|
489
551
|
/** @} */
|
490
552
|
GIT_END_DECL
|
491
553
|
#endif
|
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
#include "common.h"
|
11
11
|
#include "types.h"
|
12
|
+
#include "net.h"
|
12
13
|
|
13
14
|
/**
|
14
15
|
* @file git2/refspec.h
|
@@ -35,6 +36,14 @@ GIT_EXTERN(const char *) git_refspec_src(const git_refspec *refspec);
|
|
35
36
|
*/
|
36
37
|
GIT_EXTERN(const char *) git_refspec_dst(const git_refspec *refspec);
|
37
38
|
|
39
|
+
/**
|
40
|
+
* Get the refspec's string
|
41
|
+
*
|
42
|
+
* @param refspec the refspec
|
43
|
+
* @returns the refspec's original string
|
44
|
+
*/
|
45
|
+
GIT_EXTERN(const char *) git_refspec_string(const git_refspec *refspec);
|
46
|
+
|
38
47
|
/**
|
39
48
|
* Get the force update setting
|
40
49
|
*
|
@@ -43,6 +52,14 @@ GIT_EXTERN(const char *) git_refspec_dst(const git_refspec *refspec);
|
|
43
52
|
*/
|
44
53
|
GIT_EXTERN(int) git_refspec_force(const git_refspec *refspec);
|
45
54
|
|
55
|
+
/**
|
56
|
+
* Get the refspec's direction.
|
57
|
+
*
|
58
|
+
* @param spec refspec
|
59
|
+
* @return GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH
|
60
|
+
*/
|
61
|
+
GIT_EXTERN(git_direction) git_refspec_direction(const git_refspec *spec);
|
62
|
+
|
46
63
|
/**
|
47
64
|
* Check if a refspec's source descriptor matches a reference
|
48
65
|
*
|
@@ -142,39 +142,79 @@ GIT_EXTERN(int) git_remote_set_url(git_remote *remote, const char* url);
|
|
142
142
|
GIT_EXTERN(int) git_remote_set_pushurl(git_remote *remote, const char* url);
|
143
143
|
|
144
144
|
/**
|
145
|
-
*
|
145
|
+
* Add a fetch refspec to the remote
|
146
146
|
*
|
147
147
|
* @param remote the remote
|
148
|
-
* @apram
|
148
|
+
* @apram refspec the new fetch refspec
|
149
149
|
* @return 0 or an error value
|
150
150
|
*/
|
151
|
-
GIT_EXTERN(int)
|
151
|
+
GIT_EXTERN(int) git_remote_add_fetch(git_remote *remote, const char *refspec);
|
152
152
|
|
153
153
|
/**
|
154
|
-
* Get the fetch
|
154
|
+
* Get the remote's list of fetch refspecs
|
155
155
|
*
|
156
|
-
*
|
157
|
-
*
|
156
|
+
* The memory is owned by the user and should be freed with
|
157
|
+
* `git_strarray_free`.
|
158
|
+
*
|
159
|
+
* @param array pointer to the array in which to store the strings
|
160
|
+
* @param remote the remote to query
|
158
161
|
*/
|
159
|
-
GIT_EXTERN(
|
162
|
+
GIT_EXTERN(int) git_remote_get_fetch_refspecs(git_strarray *array, git_remote *remote);
|
160
163
|
|
161
164
|
/**
|
162
|
-
*
|
165
|
+
* Add a push refspec to the remote
|
163
166
|
*
|
164
167
|
* @param remote the remote
|
165
|
-
* @param
|
168
|
+
* @param refspec the new push refspec
|
166
169
|
* @return 0 or an error value
|
167
170
|
*/
|
168
|
-
GIT_EXTERN(int)
|
171
|
+
GIT_EXTERN(int) git_remote_add_push(git_remote *remote, const char *refspec);
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Get the remote's list of push refspecs
|
175
|
+
*
|
176
|
+
* The memory is owned by the user and should be freed with
|
177
|
+
* `git_strarray_free`.
|
178
|
+
*
|
179
|
+
* @param array pointer to the array in which to store the strings
|
180
|
+
* @param remote the remote to query
|
181
|
+
*/
|
182
|
+
GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, git_remote *remote);
|
183
|
+
|
184
|
+
/**
|
185
|
+
* Clear the refspecs
|
186
|
+
*
|
187
|
+
* Remove all configured fetch and push refspecs from the remote.
|
188
|
+
*
|
189
|
+
* @param remote the remote
|
190
|
+
*/
|
191
|
+
GIT_EXTERN(void) git_remote_clear_refspecs(git_remote *remote);
|
169
192
|
|
170
193
|
/**
|
171
|
-
* Get the
|
194
|
+
* Get the number of refspecs for a remote
|
172
195
|
*
|
173
196
|
* @param remote the remote
|
174
|
-
* @return
|
197
|
+
* @return the amount of refspecs configured in this remote
|
198
|
+
*/
|
199
|
+
GIT_EXTERN(size_t) git_remote_refspec_count(git_remote *remote);
|
200
|
+
|
201
|
+
/**
|
202
|
+
* Get a refspec from the remote
|
203
|
+
*
|
204
|
+
* @param remote the remote to query
|
205
|
+
* @param n the refspec to get
|
206
|
+
* @return the nth refspec
|
175
207
|
*/
|
208
|
+
GIT_EXTERN(const git_refspec *)git_remote_get_refspec(git_remote *remote, size_t n);
|
176
209
|
|
177
|
-
|
210
|
+
/**
|
211
|
+
* Remove a refspec from the remote
|
212
|
+
*
|
213
|
+
* @param remote the remote to query
|
214
|
+
* @param n the refspec to remove
|
215
|
+
* @return 0 or GIT_ENOTFOUND
|
216
|
+
*/
|
217
|
+
GIT_EXTERN(int) git_remote_remove_refspec(git_remote *remote, size_t n);
|
178
218
|
|
179
219
|
/**
|
180
220
|
* Open a connection to a remote
|
@@ -184,7 +224,8 @@ GIT_EXTERN(const git_refspec *) git_remote_pushspec(const git_remote *remote);
|
|
184
224
|
* starts up a specific binary which can only do the one or the other.
|
185
225
|
*
|
186
226
|
* @param remote the remote to connect to
|
187
|
-
* @param direction
|
227
|
+
* @param direction GIT_DIRECTION_FETCH if you want to fetch or
|
228
|
+
* GIT_DIRECTION_PUSH if you want to push
|
188
229
|
* @return 0 or an error code
|
189
230
|
*/
|
190
231
|
GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction);
|
@@ -218,7 +259,7 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void
|
|
218
259
|
* @param progress_cb function to call with progress information. Be aware that
|
219
260
|
* this is called inline with network and indexing operations, so performance
|
220
261
|
* may be affected.
|
221
|
-
* @param
|
262
|
+
* @param payload payload for the progress callback
|
222
263
|
* @return 0 or an error code
|
223
264
|
*/
|
224
265
|
GIT_EXTERN(int) git_remote_download(
|
@@ -279,7 +320,7 @@ GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
|
|
279
320
|
* Return whether a string is a valid remote URL
|
280
321
|
*
|
281
322
|
* @param url the url to check
|
282
|
-
* @
|
323
|
+
* @return 1 if the url is valid, 0 otherwise
|
283
324
|
*/
|
284
325
|
GIT_EXTERN(int) git_remote_valid_url(const char *url);
|
285
326
|
|
@@ -385,10 +426,9 @@ GIT_EXTERN(int) git_remote_set_callbacks(git_remote *remote, git_remote_callback
|
|
385
426
|
GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
|
386
427
|
|
387
428
|
typedef enum {
|
388
|
-
|
389
|
-
GIT_REMOTE_DOWNLOAD_TAGS_NONE,
|
390
|
-
|
391
|
-
GIT_REMOTE_DOWNLOAD_TAGS_ALL
|
429
|
+
GIT_REMOTE_DOWNLOAD_TAGS_AUTO = 0,
|
430
|
+
GIT_REMOTE_DOWNLOAD_TAGS_NONE = 1,
|
431
|
+
GIT_REMOTE_DOWNLOAD_TAGS_ALL = 2
|
392
432
|
} git_remote_autotag_option_t;
|
393
433
|
|
394
434
|
/**
|