rugged 0.17.0.b7 → 0.18.0.b1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +88 -32
- data/ext/rugged/extconf.rb +4 -2
- data/ext/rugged/rugged.c +72 -10
- data/ext/rugged/rugged.h +14 -10
- data/ext/rugged/rugged_blob.c +8 -10
- data/ext/rugged/rugged_branch.c +11 -14
- data/ext/rugged/rugged_commit.c +31 -24
- data/ext/rugged/rugged_config.c +2 -2
- data/ext/rugged/rugged_index.c +133 -198
- data/ext/rugged/rugged_note.c +372 -0
- data/ext/rugged/rugged_object.c +50 -22
- data/ext/rugged/rugged_reference.c +122 -130
- data/ext/rugged/rugged_remote.c +72 -29
- data/ext/rugged/rugged_repo.c +402 -20
- data/ext/rugged/rugged_revwalk.c +7 -3
- data/ext/rugged/rugged_settings.c +110 -0
- data/ext/rugged/rugged_signature.c +23 -7
- data/ext/rugged/rugged_tag.c +32 -16
- data/ext/rugged/rugged_tree.c +44 -15
- data/lib/rugged.rb +1 -0
- data/lib/rugged/index.rb +8 -0
- data/lib/rugged/remote.rb +13 -0
- data/lib/rugged/repository.rb +3 -3
- data/lib/rugged/version.rb +1 -1
- data/test/blob_test.rb +13 -15
- data/test/branch_test.rb +32 -67
- data/test/commit_test.rb +50 -12
- data/test/config_test.rb +12 -11
- data/test/coverage/HEAD.json +1 -1
- data/test/coverage/cover.rb +40 -21
- data/test/errors_test.rb +34 -0
- data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
- data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
- data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
- data/test/fixtures/testrepo.git/logs/refs/notes/commits +1 -0
- data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +1 -0
- data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
- data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +1 -0
- data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
- data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
- data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +3 -0
- data/test/fixtures/testrepo.git/refs/notes/commits +1 -0
- data/test/index_test.rb +65 -69
- data/test/lib_test.rb +76 -11
- data/test/note_test.rb +158 -0
- data/test/object_test.rb +8 -11
- data/test/reference_test.rb +77 -85
- data/test/remote_test.rb +86 -8
- data/test/repo_pack_test.rb +9 -7
- data/test/repo_reset_test.rb +80 -0
- data/test/repo_test.rb +176 -53
- data/test/tag_test.rb +44 -7
- data/test/test_helper.rb +63 -35
- data/test/tree_test.rb +34 -13
- data/test/walker_test.rb +14 -14
- data/vendor/libgit2/Makefile.embed +1 -1
- data/vendor/libgit2/deps/http-parser/http_parser.c +974 -578
- data/vendor/libgit2/deps/http-parser/http_parser.h +106 -70
- data/vendor/libgit2/deps/regex/regcomp.c +7 -6
- data/vendor/libgit2/deps/regex/regex_internal.c +1 -1
- data/vendor/libgit2/deps/regex/regex_internal.h +12 -3
- data/vendor/libgit2/deps/regex/regexec.c +5 -5
- data/vendor/libgit2/include/git2.h +5 -1
- data/vendor/libgit2/include/git2/attr.h +4 -2
- data/vendor/libgit2/include/git2/blob.h +39 -12
- data/vendor/libgit2/include/git2/branch.h +123 -35
- data/vendor/libgit2/include/git2/checkout.h +206 -48
- data/vendor/libgit2/include/git2/clone.h +72 -27
- data/vendor/libgit2/include/git2/commit.h +20 -17
- data/vendor/libgit2/include/git2/common.h +67 -1
- data/vendor/libgit2/include/git2/config.h +81 -60
- data/vendor/libgit2/include/git2/cred_helpers.h +53 -0
- data/vendor/libgit2/include/git2/diff.h +459 -150
- data/vendor/libgit2/include/git2/errors.h +9 -1
- data/vendor/libgit2/include/git2/graph.h +41 -0
- data/vendor/libgit2/include/git2/ignore.h +7 -6
- data/vendor/libgit2/include/git2/index.h +323 -97
- data/vendor/libgit2/include/git2/indexer.h +27 -59
- data/vendor/libgit2/include/git2/inttypes.h +4 -0
- data/vendor/libgit2/include/git2/merge.h +13 -3
- data/vendor/libgit2/include/git2/message.h +14 -8
- data/vendor/libgit2/include/git2/net.h +9 -7
- data/vendor/libgit2/include/git2/notes.h +88 -29
- data/vendor/libgit2/include/git2/object.h +16 -6
- data/vendor/libgit2/include/git2/odb.h +80 -17
- data/vendor/libgit2/include/git2/odb_backend.h +47 -11
- data/vendor/libgit2/include/git2/oid.h +26 -17
- data/vendor/libgit2/include/git2/pack.h +62 -8
- data/vendor/libgit2/include/git2/push.h +131 -0
- data/vendor/libgit2/include/git2/refdb.h +103 -0
- data/vendor/libgit2/include/git2/refdb_backend.h +109 -0
- data/vendor/libgit2/include/git2/reflog.h +30 -21
- data/vendor/libgit2/include/git2/refs.h +215 -193
- data/vendor/libgit2/include/git2/refspec.h +22 -2
- data/vendor/libgit2/include/git2/remote.h +158 -37
- data/vendor/libgit2/include/git2/repository.h +150 -31
- data/vendor/libgit2/include/git2/reset.h +43 -9
- data/vendor/libgit2/include/git2/revparse.h +48 -4
- data/vendor/libgit2/include/git2/revwalk.h +25 -10
- data/vendor/libgit2/include/git2/signature.h +20 -12
- data/vendor/libgit2/include/git2/stash.h +121 -0
- data/vendor/libgit2/include/git2/status.h +122 -53
- data/vendor/libgit2/include/git2/strarray.h +17 -11
- data/vendor/libgit2/include/git2/submodule.h +42 -7
- data/vendor/libgit2/include/git2/tag.h +72 -59
- data/vendor/libgit2/include/git2/threads.h +4 -2
- data/vendor/libgit2/include/git2/trace.h +68 -0
- data/vendor/libgit2/include/git2/transport.h +328 -0
- data/vendor/libgit2/include/git2/tree.h +149 -120
- data/vendor/libgit2/include/git2/types.h +13 -12
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/src/amiga/map.c +2 -2
- data/vendor/libgit2/src/attr.c +58 -48
- data/vendor/libgit2/src/attr.h +4 -18
- data/vendor/libgit2/src/attr_file.c +30 -6
- data/vendor/libgit2/src/attr_file.h +6 -8
- data/vendor/libgit2/src/attrcache.h +24 -0
- data/vendor/libgit2/src/blob.c +30 -7
- data/vendor/libgit2/src/blob.h +1 -1
- data/vendor/libgit2/src/branch.c +361 -68
- data/vendor/libgit2/src/branch.h +17 -0
- data/vendor/libgit2/src/bswap.h +1 -1
- data/vendor/libgit2/src/buf_text.c +291 -0
- data/vendor/libgit2/src/buf_text.h +122 -0
- data/vendor/libgit2/src/buffer.c +27 -101
- data/vendor/libgit2/src/buffer.h +54 -39
- data/vendor/libgit2/src/cache.c +15 -6
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +3 -1
- data/vendor/libgit2/src/checkout.c +1165 -222
- data/vendor/libgit2/src/checkout.h +24 -0
- data/vendor/libgit2/src/clone.c +171 -86
- data/vendor/libgit2/src/commit.c +44 -45
- data/vendor/libgit2/src/commit.h +3 -3
- data/vendor/libgit2/src/commit_list.c +194 -0
- data/vendor/libgit2/src/commit_list.h +49 -0
- data/vendor/libgit2/src/common.h +44 -10
- data/vendor/libgit2/src/compress.c +1 -1
- data/vendor/libgit2/src/compress.h +1 -1
- data/vendor/libgit2/src/config.c +211 -124
- data/vendor/libgit2/src/config.h +23 -4
- data/vendor/libgit2/src/config_cache.c +2 -2
- data/vendor/libgit2/src/config_file.c +129 -53
- data/vendor/libgit2/src/config_file.h +10 -8
- data/vendor/libgit2/src/crlf.c +66 -67
- data/vendor/libgit2/src/date.c +12 -12
- data/vendor/libgit2/src/delta-apply.c +14 -1
- data/vendor/libgit2/src/delta-apply.h +18 -1
- data/vendor/libgit2/src/delta.c +40 -107
- data/vendor/libgit2/src/delta.h +19 -17
- data/vendor/libgit2/src/diff.c +347 -496
- data/vendor/libgit2/src/diff.h +27 -1
- data/vendor/libgit2/src/diff_output.c +564 -249
- data/vendor/libgit2/src/diff_output.h +15 -8
- data/vendor/libgit2/src/diff_tform.c +687 -0
- data/vendor/libgit2/src/errors.c +27 -36
- data/vendor/libgit2/src/fetch.c +13 -351
- data/vendor/libgit2/src/fetch.h +13 -3
- data/vendor/libgit2/src/fetchhead.c +295 -0
- data/vendor/libgit2/src/fetchhead.h +34 -0
- data/vendor/libgit2/src/filebuf.c +42 -15
- data/vendor/libgit2/src/filebuf.h +4 -2
- data/vendor/libgit2/src/fileops.c +466 -113
- data/vendor/libgit2/src/fileops.h +154 -28
- data/vendor/libgit2/src/filter.c +3 -75
- data/vendor/libgit2/src/filter.h +1 -29
- data/vendor/libgit2/src/fnmatch.c +1 -1
- data/vendor/libgit2/src/fnmatch.h +1 -1
- data/vendor/libgit2/src/global.c +54 -10
- data/vendor/libgit2/src/global.h +10 -1
- data/vendor/libgit2/src/graph.c +178 -0
- data/vendor/libgit2/src/hash.c +25 -52
- data/vendor/libgit2/src/hash.h +21 -9
- data/vendor/libgit2/src/{sha1/sha1.c → hash/hash_generic.c} +20 -12
- data/vendor/libgit2/src/hash/hash_generic.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +45 -0
- data/vendor/libgit2/src/hash/hash_win32.c +291 -0
- data/vendor/libgit2/src/hash/hash_win32.h +140 -0
- data/vendor/libgit2/src/hashsig.c +368 -0
- data/vendor/libgit2/src/hashsig.h +72 -0
- data/vendor/libgit2/src/ignore.c +22 -15
- data/vendor/libgit2/src/ignore.h +6 -1
- data/vendor/libgit2/src/index.c +770 -171
- data/vendor/libgit2/src/index.h +13 -5
- data/vendor/libgit2/src/indexer.c +286 -431
- data/vendor/libgit2/src/iterator.c +854 -466
- data/vendor/libgit2/src/iterator.h +134 -109
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +296 -0
- data/vendor/libgit2/src/merge.h +22 -0
- data/vendor/libgit2/src/message.c +1 -1
- data/vendor/libgit2/src/message.h +1 -1
- data/vendor/libgit2/src/mwindow.c +35 -30
- data/vendor/libgit2/src/mwindow.h +2 -2
- data/vendor/libgit2/src/netops.c +162 -98
- data/vendor/libgit2/src/netops.h +50 -15
- data/vendor/libgit2/src/notes.c +109 -58
- data/vendor/libgit2/src/notes.h +2 -1
- data/vendor/libgit2/src/object.c +46 -57
- data/vendor/libgit2/src/object.h +1 -8
- data/vendor/libgit2/src/odb.c +151 -40
- data/vendor/libgit2/src/odb.h +5 -1
- data/vendor/libgit2/src/odb_loose.c +4 -5
- data/vendor/libgit2/src/odb_pack.c +122 -80
- data/vendor/libgit2/src/offmap.h +65 -0
- data/vendor/libgit2/src/oid.c +12 -4
- data/vendor/libgit2/src/oidmap.h +1 -1
- data/vendor/libgit2/src/pack-objects.c +88 -61
- data/vendor/libgit2/src/pack-objects.h +8 -8
- data/vendor/libgit2/src/pack.c +293 -28
- data/vendor/libgit2/src/pack.h +49 -4
- data/vendor/libgit2/src/path.c +103 -14
- data/vendor/libgit2/src/path.h +23 -7
- data/vendor/libgit2/src/pathspec.c +168 -0
- data/vendor/libgit2/src/pathspec.h +40 -0
- data/vendor/libgit2/src/pool.c +29 -4
- data/vendor/libgit2/src/pool.h +8 -1
- data/vendor/libgit2/src/posix.c +26 -27
- data/vendor/libgit2/src/posix.h +2 -3
- data/vendor/libgit2/src/pqueue.c +23 -1
- data/vendor/libgit2/src/pqueue.h +23 -1
- data/vendor/libgit2/src/push.c +653 -0
- data/vendor/libgit2/src/push.h +51 -0
- data/vendor/libgit2/src/refdb.c +185 -0
- data/vendor/libgit2/src/refdb.h +46 -0
- data/vendor/libgit2/src/refdb_fs.c +1024 -0
- data/vendor/libgit2/src/refdb_fs.h +15 -0
- data/vendor/libgit2/src/reflog.c +77 -45
- data/vendor/libgit2/src/reflog.h +1 -3
- data/vendor/libgit2/src/refs.c +366 -1326
- data/vendor/libgit2/src/refs.h +22 -13
- data/vendor/libgit2/src/refspec.c +46 -7
- data/vendor/libgit2/src/refspec.h +11 -1
- data/vendor/libgit2/src/remote.c +758 -120
- data/vendor/libgit2/src/remote.h +10 -5
- data/vendor/libgit2/src/repo_template.h +6 -6
- data/vendor/libgit2/src/repository.c +315 -96
- data/vendor/libgit2/src/repository.h +5 -3
- data/vendor/libgit2/src/reset.c +99 -81
- data/vendor/libgit2/src/revparse.c +157 -84
- data/vendor/libgit2/src/revwalk.c +68 -470
- data/vendor/libgit2/src/revwalk.h +44 -0
- data/vendor/libgit2/src/sha1_lookup.c +1 -1
- data/vendor/libgit2/src/sha1_lookup.h +1 -1
- data/vendor/libgit2/src/signature.c +68 -200
- data/vendor/libgit2/src/signature.h +1 -1
- data/vendor/libgit2/src/stash.c +663 -0
- data/vendor/libgit2/src/status.c +101 -79
- data/vendor/libgit2/src/strmap.h +1 -1
- data/vendor/libgit2/src/submodule.c +67 -51
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/tag.c +35 -29
- data/vendor/libgit2/src/tag.h +1 -1
- data/vendor/libgit2/src/thread-utils.c +1 -1
- data/vendor/libgit2/src/thread-utils.h +2 -2
- data/vendor/libgit2/src/trace.c +39 -0
- data/vendor/libgit2/src/trace.h +56 -0
- data/vendor/libgit2/src/transport.c +81 -34
- data/vendor/libgit2/src/transports/cred.c +60 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +49 -0
- data/vendor/libgit2/src/transports/git.c +234 -127
- data/vendor/libgit2/src/transports/http.c +761 -433
- data/vendor/libgit2/src/transports/local.c +460 -64
- data/vendor/libgit2/src/transports/smart.c +345 -0
- data/vendor/libgit2/src/transports/smart.h +179 -0
- data/vendor/libgit2/src/{pkt.c → transports/smart_pkt.c} +131 -12
- data/vendor/libgit2/src/transports/smart_protocol.c +856 -0
- data/vendor/libgit2/src/transports/winhttp.c +1136 -0
- data/vendor/libgit2/src/tree-cache.c +2 -2
- data/vendor/libgit2/src/tree-cache.h +1 -1
- data/vendor/libgit2/src/tree.c +239 -166
- data/vendor/libgit2/src/tree.h +11 -2
- data/vendor/libgit2/src/tsort.c +39 -23
- data/vendor/libgit2/src/unix/map.c +1 -1
- data/vendor/libgit2/src/unix/posix.h +12 -2
- data/vendor/libgit2/src/unix/realpath.c +30 -0
- data/vendor/libgit2/src/util.c +250 -13
- data/vendor/libgit2/src/util.h +71 -14
- data/vendor/libgit2/src/vector.c +123 -60
- data/vendor/libgit2/src/vector.h +24 -22
- data/vendor/libgit2/src/win32/dir.c +1 -1
- data/vendor/libgit2/src/win32/dir.h +1 -1
- data/vendor/libgit2/src/win32/error.c +77 -0
- data/vendor/libgit2/src/win32/error.h +13 -0
- data/vendor/libgit2/src/win32/findfile.c +143 -54
- data/vendor/libgit2/src/win32/findfile.h +10 -6
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/mingw-compat.h +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +10 -1
- data/vendor/libgit2/src/win32/posix.h +10 -1
- data/vendor/libgit2/src/win32/posix_w32.c +132 -63
- data/vendor/libgit2/src/win32/precompiled.c +1 -1
- data/vendor/libgit2/src/win32/pthread.c +1 -1
- data/vendor/libgit2/src/win32/pthread.h +1 -1
- data/vendor/libgit2/src/win32/utf-conv.c +5 -5
- data/vendor/libgit2/src/win32/utf-conv.h +3 -3
- data/vendor/libgit2/src/win32/version.h +20 -0
- metadata +308 -252
- data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
- data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
- data/test/index_test.rb~ +0 -218
- data/vendor/libgit2/src/pkt.h +0 -91
- data/vendor/libgit2/src/ppc/sha1.c +0 -70
- data/vendor/libgit2/src/ppc/sha1.h +0 -26
- data/vendor/libgit2/src/protocol.c +0 -110
- data/vendor/libgit2/src/protocol.h +0 -21
- data/vendor/libgit2/src/sha1.h +0 -33
- data/vendor/libgit2/src/transport.h +0 -148
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C)
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
3
|
*
|
4
4
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
@@ -30,11 +30,11 @@ GIT_BEGIN_DECL
|
|
30
30
|
* The reflog must be freed manually by using
|
31
31
|
* git_reflog_free().
|
32
32
|
*
|
33
|
-
* @param
|
33
|
+
* @param out pointer to reflog
|
34
34
|
* @param ref reference to read the reflog for
|
35
35
|
* @return 0 or an error code
|
36
36
|
*/
|
37
|
-
GIT_EXTERN(int) git_reflog_read(git_reflog **
|
37
|
+
GIT_EXTERN(int) git_reflog_read(git_reflog **out, const git_reference *ref);
|
38
38
|
|
39
39
|
/**
|
40
40
|
* Write an existing in-memory reflog object back to disk
|
@@ -51,23 +51,26 @@ GIT_EXTERN(int) git_reflog_write(git_reflog *reflog);
|
|
51
51
|
* `msg` is optional and can be NULL.
|
52
52
|
*
|
53
53
|
* @param reflog an existing reflog object
|
54
|
-
* @param
|
54
|
+
* @param id the OID the reference is now pointing to
|
55
55
|
* @param committer the signature of the committer
|
56
56
|
* @param msg the reflog message
|
57
57
|
* @return 0 or an error code
|
58
58
|
*/
|
59
|
-
GIT_EXTERN(int) git_reflog_append(git_reflog *reflog, const git_oid *
|
59
|
+
GIT_EXTERN(int) git_reflog_append(git_reflog *reflog, const git_oid *id, const git_signature *committer, const char *msg);
|
60
60
|
|
61
61
|
/**
|
62
62
|
* Rename the reflog for the given reference
|
63
63
|
*
|
64
64
|
* The reflog to be renamed is expected to already exist
|
65
65
|
*
|
66
|
+
* The new name will be checked for validity.
|
67
|
+
* See `git_reference_create_symbolic()` for rules about valid names.
|
68
|
+
*
|
66
69
|
* @param ref the reference
|
67
|
-
* @param
|
68
|
-
* @return 0 or an error code
|
70
|
+
* @param name the new name of the reference
|
71
|
+
* @return 0 on success, GIT_EINVALIDSPEC or an error code
|
69
72
|
*/
|
70
|
-
GIT_EXTERN(int) git_reflog_rename(git_reference *ref, const char *
|
73
|
+
GIT_EXTERN(int) git_reflog_rename(git_reference *ref, const char *name);
|
71
74
|
|
72
75
|
/**
|
73
76
|
* Delete the reflog for the given reference
|
@@ -83,13 +86,17 @@ GIT_EXTERN(int) git_reflog_delete(git_reference *ref);
|
|
83
86
|
* @param reflog the previously loaded reflog
|
84
87
|
* @return the number of log entries
|
85
88
|
*/
|
86
|
-
GIT_EXTERN(
|
89
|
+
GIT_EXTERN(size_t) git_reflog_entrycount(git_reflog *reflog);
|
87
90
|
|
88
91
|
/**
|
89
92
|
* Lookup an entry by its index
|
90
93
|
*
|
94
|
+
* Requesting the reflog entry with an index of 0 (zero) will
|
95
|
+
* return the most recently created entry.
|
96
|
+
*
|
91
97
|
* @param reflog a previously loaded reflog
|
92
|
-
* @param idx the position to lookup
|
98
|
+
* @param idx the position of the entry to lookup. Should be greater than or
|
99
|
+
* equal to 0 (zero) and less than `git_reflog_entrycount()`.
|
93
100
|
* @return the entry; NULL if not found
|
94
101
|
*/
|
95
102
|
GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(git_reflog *reflog, size_t idx);
|
@@ -97,21 +104,23 @@ GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(git_reflog *reflog
|
|
97
104
|
/**
|
98
105
|
* Remove an entry from the reflog by its index
|
99
106
|
*
|
100
|
-
* To ensure there's no gap in the log history, set
|
101
|
-
* When deleting entry `n`, member old_oid of entry `n-1`
|
102
|
-
* the value of
|
107
|
+
* To ensure there's no gap in the log history, set `rewrite_previous_entry`
|
108
|
+
* param value to 1. When deleting entry `n`, member old_oid of entry `n-1`
|
109
|
+
* (if any) will be updated with the value of member new_oid of entry `n+1`.
|
103
110
|
*
|
104
111
|
* @param reflog a previously loaded reflog.
|
105
112
|
*
|
106
|
-
* @param idx the position of the entry to remove.
|
113
|
+
* @param idx the position of the entry to remove. Should be greater than or
|
114
|
+
* equal to 0 (zero) and less than `git_reflog_entrycount()`.
|
107
115
|
*
|
108
116
|
* @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise.
|
109
117
|
*
|
110
|
-
* @return 0 on success
|
118
|
+
* @return 0 on success, GIT_ENOTFOUND if the entry doesn't exist
|
119
|
+
* or an error code.
|
111
120
|
*/
|
112
121
|
GIT_EXTERN(int) git_reflog_drop(
|
113
122
|
git_reflog *reflog,
|
114
|
-
|
123
|
+
size_t idx,
|
115
124
|
int rewrite_previous_entry);
|
116
125
|
|
117
126
|
/**
|
@@ -120,7 +129,7 @@ GIT_EXTERN(int) git_reflog_drop(
|
|
120
129
|
* @param entry a reflog entry
|
121
130
|
* @return the old oid
|
122
131
|
*/
|
123
|
-
GIT_EXTERN(const git_oid *)
|
132
|
+
GIT_EXTERN(const git_oid *) git_reflog_entry_id_old(const git_reflog_entry *entry);
|
124
133
|
|
125
134
|
/**
|
126
135
|
* Get the new oid
|
@@ -128,7 +137,7 @@ GIT_EXTERN(const git_oid *) git_reflog_entry_oidold(const git_reflog_entry *entr
|
|
128
137
|
* @param entry a reflog entry
|
129
138
|
* @return the new oid at this time
|
130
139
|
*/
|
131
|
-
GIT_EXTERN(const git_oid *)
|
140
|
+
GIT_EXTERN(const git_oid *) git_reflog_entry_id_new(const git_reflog_entry *entry);
|
132
141
|
|
133
142
|
/**
|
134
143
|
* Get the committer of this entry
|
@@ -136,15 +145,15 @@ GIT_EXTERN(const git_oid *) git_reflog_entry_oidnew(const git_reflog_entry *entr
|
|
136
145
|
* @param entry a reflog entry
|
137
146
|
* @return the committer
|
138
147
|
*/
|
139
|
-
GIT_EXTERN(git_signature *) git_reflog_entry_committer(const git_reflog_entry *entry);
|
148
|
+
GIT_EXTERN(const git_signature *) git_reflog_entry_committer(const git_reflog_entry *entry);
|
140
149
|
|
141
150
|
/**
|
142
|
-
* Get the log
|
151
|
+
* Get the log message
|
143
152
|
*
|
144
153
|
* @param entry a reflog entry
|
145
154
|
* @return the log msg
|
146
155
|
*/
|
147
|
-
GIT_EXTERN(char *)
|
156
|
+
GIT_EXTERN(const char *) git_reflog_entry_message(const git_reflog_entry *entry);
|
148
157
|
|
149
158
|
/**
|
150
159
|
* Free the reflog
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (C)
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
3
|
*
|
4
4
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
5
|
* a Linking Exception. For full terms see the included COPYING file.
|
@@ -22,175 +22,232 @@
|
|
22
22
|
GIT_BEGIN_DECL
|
23
23
|
|
24
24
|
/**
|
25
|
-
* Lookup a reference by
|
25
|
+
* Lookup a reference by name in a repository.
|
26
26
|
*
|
27
|
-
* The
|
27
|
+
* The returned reference must be freed by the user.
|
28
28
|
*
|
29
|
-
*
|
29
|
+
* The name will be checked for validity.
|
30
|
+
* See `git_reference_create_symbolic()` for rules about valid names.
|
31
|
+
*
|
32
|
+
* @param out pointer to the looked-up reference
|
30
33
|
* @param repo the repository to look up the reference
|
31
|
-
* @param name the long name for the reference (e.g. HEAD,
|
32
|
-
* @return 0 or an error code
|
34
|
+
* @param name the long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...)
|
35
|
+
* @return 0 on success, ENOTFOUND, EINVALIDSPEC or an error code.
|
33
36
|
*/
|
34
|
-
GIT_EXTERN(int) git_reference_lookup(git_reference **
|
37
|
+
GIT_EXTERN(int) git_reference_lookup(git_reference **out, git_repository *repo, const char *name);
|
35
38
|
|
36
39
|
/**
|
37
40
|
* Lookup a reference by name and resolve immediately to OID.
|
38
41
|
*
|
39
|
-
*
|
42
|
+
* This function provides a quick way to resolve a reference name straight
|
43
|
+
* through to the object id that it refers to. This avoids having to
|
44
|
+
* allocate or free any `git_reference` objects for simple situations.
|
45
|
+
*
|
46
|
+
* The name will be checked for validity.
|
47
|
+
* See `git_reference_symbolic_create()` for rules about valid names.
|
48
|
+
*
|
49
|
+
* @param out Pointer to oid to be filled in
|
40
50
|
* @param repo The repository in which to look up the reference
|
41
51
|
* @param name The long name for the reference
|
42
|
-
* @return 0 on success,
|
52
|
+
* @return 0 on success, ENOTFOUND, EINVALIDSPEC or an error code.
|
43
53
|
*/
|
44
|
-
GIT_EXTERN(int)
|
54
|
+
GIT_EXTERN(int) git_reference_name_to_id(
|
45
55
|
git_oid *out, git_repository *repo, const char *name);
|
46
56
|
|
47
57
|
/**
|
48
58
|
* Create a new symbolic reference.
|
49
59
|
*
|
50
|
-
*
|
51
|
-
*
|
60
|
+
* A symbolic reference is a reference name that refers to another
|
61
|
+
* reference name. If the other name moves, the symbolic name will move,
|
62
|
+
* too. As a simple example, the "HEAD" reference might refer to
|
63
|
+
* "refs/heads/master" while on the "master" branch of a repository.
|
52
64
|
*
|
53
|
-
* The
|
65
|
+
* The symbolic reference will be created in the repository and written to
|
66
|
+
* the disk. The generated reference object must be freed by the user.
|
54
67
|
*
|
55
|
-
*
|
56
|
-
* with the same name, it will be overwritten.
|
68
|
+
* Valid reference names must follow one of two patterns:
|
57
69
|
*
|
58
|
-
*
|
70
|
+
* 1. Top-level names must contain only capital letters and underscores,
|
71
|
+
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
72
|
+
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
|
73
|
+
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
|
74
|
+
* sequences ".." and "@{" which have special meaning to revparse.
|
75
|
+
*
|
76
|
+
* This function will return an error if a reference already exists with the
|
77
|
+
* given name unless `force` is true, in which case it will be overwritten.
|
78
|
+
*
|
79
|
+
* @param out Pointer to the newly created reference
|
59
80
|
* @param repo Repository where that reference will live
|
60
81
|
* @param name The name of the reference
|
61
82
|
* @param target The target of the reference
|
62
83
|
* @param force Overwrite existing references
|
63
|
-
* @return 0 or an error code
|
84
|
+
* @return 0 on success, EEXISTS, EINVALIDSPEC or an error code
|
64
85
|
*/
|
65
|
-
GIT_EXTERN(int)
|
86
|
+
GIT_EXTERN(int) git_reference_symbolic_create(git_reference **out, git_repository *repo, const char *name, const char *target, int force);
|
66
87
|
|
67
88
|
/**
|
68
|
-
* Create a new
|
89
|
+
* Create a new direct reference.
|
90
|
+
*
|
91
|
+
* A direct reference (also called an object id reference) refers directly
|
92
|
+
* to a specific object id (a.k.a. OID or SHA) in the repository. The id
|
93
|
+
* permanently refers to the object (although the reference itself can be
|
94
|
+
* moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0"
|
95
|
+
* refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977.
|
69
96
|
*
|
70
|
-
* The reference will be created in the repository and written
|
71
|
-
*
|
97
|
+
* The direct reference will be created in the repository and written to
|
98
|
+
* the disk. The generated reference object must be freed by the user.
|
72
99
|
*
|
73
|
-
*
|
100
|
+
* Valid reference names must follow one of two patterns:
|
74
101
|
*
|
75
|
-
*
|
76
|
-
*
|
102
|
+
* 1. Top-level names must contain only capital letters and underscores,
|
103
|
+
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
104
|
+
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
|
105
|
+
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
|
106
|
+
* sequences ".." and "@{" which have special meaning to revparse.
|
77
107
|
*
|
78
|
-
*
|
108
|
+
* This function will return an error if a reference already exists with the
|
109
|
+
* given name unless `force` is true, in which case it will be overwritten.
|
110
|
+
*
|
111
|
+
* @param out Pointer to the newly created reference
|
79
112
|
* @param repo Repository where that reference will live
|
80
113
|
* @param name The name of the reference
|
81
114
|
* @param id The object id pointed to by the reference.
|
82
115
|
* @param force Overwrite existing references
|
83
|
-
* @return 0 or an error code
|
116
|
+
* @return 0 on success, EEXISTS, EINVALIDSPEC or an error code
|
117
|
+
*/
|
118
|
+
GIT_EXTERN(int) git_reference_create(git_reference **out, git_repository *repo, const char *name, const git_oid *id, int force);
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Get the OID pointed to by a direct reference.
|
122
|
+
*
|
123
|
+
* Only available if the reference is direct (i.e. an object id reference,
|
124
|
+
* not a symbolic one).
|
125
|
+
*
|
126
|
+
* To find the OID of a symbolic ref, call `git_reference_resolve()` and
|
127
|
+
* then this function (or maybe use `git_reference_name_to_id()` to
|
128
|
+
* directly resolve a reference name all the way through to an OID).
|
129
|
+
*
|
130
|
+
* @param ref The reference
|
131
|
+
* @return a pointer to the oid if available, NULL otherwise
|
84
132
|
*/
|
85
|
-
GIT_EXTERN(
|
133
|
+
GIT_EXTERN(const git_oid *) git_reference_target(const git_reference *ref);
|
86
134
|
|
87
135
|
/**
|
88
|
-
*
|
136
|
+
* Return the peeled OID target of this reference.
|
89
137
|
*
|
90
|
-
*
|
138
|
+
* This peeled OID only applies to direct references that point to
|
139
|
+
* a hard Tag object: it is the result of peeling such Tag.
|
91
140
|
*
|
92
141
|
* @param ref The reference
|
93
142
|
* @return a pointer to the oid if available, NULL otherwise
|
94
143
|
*/
|
95
|
-
GIT_EXTERN(const git_oid *)
|
144
|
+
GIT_EXTERN(const git_oid *) git_reference_target_peel(const git_reference *ref);
|
96
145
|
|
97
146
|
/**
|
98
|
-
* Get full name to the reference pointed by
|
147
|
+
* Get full name to the reference pointed to by a symbolic reference.
|
99
148
|
*
|
100
|
-
* Only available if the reference is symbolic
|
149
|
+
* Only available if the reference is symbolic.
|
101
150
|
*
|
102
151
|
* @param ref The reference
|
103
152
|
* @return a pointer to the name if available, NULL otherwise
|
104
153
|
*/
|
105
|
-
GIT_EXTERN(const char *)
|
154
|
+
GIT_EXTERN(const char *) git_reference_symbolic_target(const git_reference *ref);
|
106
155
|
|
107
156
|
/**
|
108
|
-
* Get the type of a reference
|
157
|
+
* Get the type of a reference.
|
109
158
|
*
|
110
159
|
* Either direct (GIT_REF_OID) or symbolic (GIT_REF_SYMBOLIC)
|
111
160
|
*
|
112
161
|
* @param ref The reference
|
113
162
|
* @return the type
|
114
163
|
*/
|
115
|
-
GIT_EXTERN(git_ref_t) git_reference_type(git_reference *ref);
|
164
|
+
GIT_EXTERN(git_ref_t) git_reference_type(const git_reference *ref);
|
116
165
|
|
117
166
|
/**
|
118
|
-
* Get the full name of a reference
|
167
|
+
* Get the full name of a reference.
|
168
|
+
*
|
169
|
+
* See `git_reference_create_symbolic()` for rules about valid names.
|
119
170
|
*
|
120
171
|
* @param ref The reference
|
121
172
|
* @return the full name for the ref
|
122
173
|
*/
|
123
|
-
GIT_EXTERN(const char *) git_reference_name(git_reference *ref);
|
174
|
+
GIT_EXTERN(const char *) git_reference_name(const git_reference *ref);
|
124
175
|
|
125
176
|
/**
|
126
|
-
* Resolve a symbolic reference
|
177
|
+
* Resolve a symbolic reference to a direct reference.
|
127
178
|
*
|
128
|
-
* This method iteratively peels a symbolic reference
|
129
|
-
*
|
179
|
+
* This method iteratively peels a symbolic reference until it resolves to
|
180
|
+
* a direct reference to an OID.
|
130
181
|
*
|
131
|
-
* The peeled reference is returned in the `resolved_ref`
|
132
|
-
*
|
133
|
-
* needed.
|
182
|
+
* The peeled reference is returned in the `resolved_ref` argument, and
|
183
|
+
* must be freed manually once it's no longer needed.
|
134
184
|
*
|
135
|
-
* If a direct reference is passed as an argument,
|
136
|
-
*
|
137
|
-
* be manually freed too.
|
185
|
+
* If a direct reference is passed as an argument, a copy of that
|
186
|
+
* reference is returned. This copy must be manually freed too.
|
138
187
|
*
|
139
188
|
* @param resolved_ref Pointer to the peeled reference
|
140
189
|
* @param ref The reference
|
141
190
|
* @return 0 or an error code
|
142
191
|
*/
|
143
|
-
GIT_EXTERN(int) git_reference_resolve(git_reference **
|
192
|
+
GIT_EXTERN(int) git_reference_resolve(git_reference **out, const git_reference *ref);
|
144
193
|
|
145
194
|
/**
|
146
|
-
* Get the repository where a reference resides
|
195
|
+
* Get the repository where a reference resides.
|
147
196
|
*
|
148
197
|
* @param ref The reference
|
149
198
|
* @return a pointer to the repo
|
150
199
|
*/
|
151
|
-
GIT_EXTERN(git_repository *) git_reference_owner(git_reference *ref);
|
200
|
+
GIT_EXTERN(git_repository *) git_reference_owner(const git_reference *ref);
|
152
201
|
|
153
202
|
/**
|
154
|
-
*
|
203
|
+
* Create a new reference with the same name as the given reference but a
|
204
|
+
* different symbolic target. The reference must be a symbolic reference,
|
205
|
+
* otherwise this will fail.
|
155
206
|
*
|
156
|
-
* The reference
|
157
|
-
* this method will fail.
|
207
|
+
* The new reference will be written to disk, overwriting the given reference.
|
158
208
|
*
|
159
|
-
* The
|
160
|
-
*
|
209
|
+
* The target name will be checked for validity.
|
210
|
+
* See `git_reference_create_symbolic()` for rules about valid names.
|
161
211
|
*
|
212
|
+
* @param out Pointer to the newly created reference
|
162
213
|
* @param ref The reference
|
163
214
|
* @param target The new target for the reference
|
164
|
-
* @return 0 or an error code
|
215
|
+
* @return 0 on success, EINVALIDSPEC or an error code
|
165
216
|
*/
|
166
|
-
GIT_EXTERN(int)
|
217
|
+
GIT_EXTERN(int) git_reference_symbolic_set_target(
|
218
|
+
git_reference **out,
|
219
|
+
git_reference *ref,
|
220
|
+
const char *target);
|
167
221
|
|
168
222
|
/**
|
169
|
-
*
|
170
|
-
*
|
171
|
-
*
|
172
|
-
* this method will fail.
|
223
|
+
* Create a new reference with the same name as the given reference but a
|
224
|
+
* different OID target. The reference must be a direct reference, otherwise
|
225
|
+
* this will fail.
|
173
226
|
*
|
174
|
-
* The reference will be
|
175
|
-
* memory and on disk.
|
227
|
+
* The new reference will be written to disk, overwriting the given reference.
|
176
228
|
*
|
229
|
+
* @param out Pointer to the newly created reference
|
177
230
|
* @param ref The reference
|
178
231
|
* @param id The new target OID for the reference
|
179
232
|
* @return 0 or an error code
|
180
233
|
*/
|
181
|
-
GIT_EXTERN(int)
|
234
|
+
GIT_EXTERN(int) git_reference_set_target(
|
235
|
+
git_reference **out,
|
236
|
+
git_reference *ref,
|
237
|
+
const git_oid *id);
|
182
238
|
|
183
239
|
/**
|
184
|
-
* Rename an existing reference
|
240
|
+
* Rename an existing reference.
|
185
241
|
*
|
186
242
|
* This method works for both direct and symbolic references.
|
187
|
-
* The new name will be checked for validity and may be
|
188
|
-
* modified into a normalized form.
|
189
243
|
*
|
190
|
-
* The
|
244
|
+
* The new name will be checked for validity.
|
245
|
+
* See `git_reference_create_symbolic()` for rules about valid names.
|
246
|
+
*
|
247
|
+
* On success, the given git_reference will be deleted from disk and a
|
248
|
+
* new `git_reference` will be returned.
|
191
249
|
*
|
192
|
-
* The reference will be immediately renamed in-memory
|
193
|
-
* and on disk.
|
250
|
+
* The reference will be immediately renamed in-memory and on disk.
|
194
251
|
*
|
195
252
|
* If the `force` flag is not enabled, and there's already
|
196
253
|
* a reference with the given name, the renaming will fail.
|
@@ -201,20 +258,23 @@ GIT_EXTERN(int) git_reference_set_oid(git_reference *ref, const git_oid *id);
|
|
201
258
|
* the reflog if it exists.
|
202
259
|
*
|
203
260
|
* @param ref The reference to rename
|
204
|
-
* @param
|
261
|
+
* @param name The new name for the reference
|
205
262
|
* @param force Overwrite an existing reference
|
206
|
-
* @return 0 or an error code
|
263
|
+
* @return 0 on success, EINVALIDSPEC, EEXISTS or an error code
|
207
264
|
*
|
208
265
|
*/
|
209
|
-
GIT_EXTERN(int) git_reference_rename(
|
266
|
+
GIT_EXTERN(int) git_reference_rename(
|
267
|
+
git_reference **out,
|
268
|
+
git_reference *ref,
|
269
|
+
const char *new_name,
|
270
|
+
int force);
|
210
271
|
|
211
272
|
/**
|
212
|
-
* Delete an existing reference
|
213
|
-
*
|
214
|
-
* This method works for both direct and symbolic references.
|
273
|
+
* Delete an existing reference.
|
215
274
|
*
|
216
|
-
*
|
217
|
-
*
|
275
|
+
* This method works for both direct and symbolic references. The reference
|
276
|
+
* will be immediately removed on disk but the memory will not be freed.
|
277
|
+
* Callers must call `git_reference_free`.
|
218
278
|
*
|
219
279
|
* @param ref The reference to remove
|
220
280
|
* @return 0 or an error code
|
@@ -222,95 +282,56 @@ GIT_EXTERN(int) git_reference_rename(git_reference *ref, const char *new_name, i
|
|
222
282
|
GIT_EXTERN(int) git_reference_delete(git_reference *ref);
|
223
283
|
|
224
284
|
/**
|
225
|
-
*
|
285
|
+
* Fill a list with all the references that can be found in a repository.
|
226
286
|
*
|
227
|
-
*
|
228
|
-
*
|
229
|
-
* `packed
|
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.
|
230
292
|
*
|
231
|
-
*
|
232
|
-
* the
|
233
|
-
*
|
234
|
-
* @param repo Repository where the loose refs will be packed
|
235
|
-
* @return 0 or an error code
|
236
|
-
*/
|
237
|
-
GIT_EXTERN(int) git_reference_packall(git_repository *repo);
|
238
|
-
|
239
|
-
/**
|
240
|
-
* Fill a list with all the references that can be found
|
241
|
-
* in a repository.
|
242
|
-
*
|
243
|
-
* The listed references may be filtered by type, or using
|
244
|
-
* a bitwise OR of several types. Use the magic value
|
245
|
-
* `GIT_REF_LISTALL` to obtain all references, including
|
246
|
-
* packed ones.
|
247
|
-
*
|
248
|
-
* The string array will be filled with the names of all
|
249
|
-
* references; these values are owned by the user and
|
250
|
-
* should be free'd manually when no longer needed, using
|
251
|
-
* `git_strarray_free`.
|
293
|
+
* The string array will be filled with the names of all references; these
|
294
|
+
* values are owned by the user and should be free'd manually when no
|
295
|
+
* longer needed, using `git_strarray_free()`.
|
252
296
|
*
|
253
297
|
* @param array Pointer to a git_strarray structure where
|
254
298
|
* the reference names will be stored
|
255
299
|
* @param repo Repository where to find the refs
|
256
|
-
* @param list_flags Filtering flags for the reference
|
257
|
-
* listing.
|
300
|
+
* @param list_flags Filtering flags for the reference listing
|
258
301
|
* @return 0 or an error code
|
259
302
|
*/
|
260
303
|
GIT_EXTERN(int) git_reference_list(git_strarray *array, git_repository *repo, unsigned int list_flags);
|
261
304
|
|
305
|
+
typedef int (*git_reference_foreach_cb)(const char *refname, void *payload);
|
306
|
+
|
262
307
|
/**
|
263
|
-
* Perform
|
308
|
+
* Perform a callback on each reference in the repository.
|
264
309
|
*
|
265
|
-
*
|
266
|
-
*
|
267
|
-
* `
|
268
|
-
*
|
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.
|
269
315
|
*
|
270
|
-
* The `callback` function will be called for each
|
271
|
-
*
|
272
|
-
*
|
273
|
-
*
|
316
|
+
* The `callback` function will be called for each reference in the
|
317
|
+
* repository, receiving the name of the reference and the `payload` value
|
318
|
+
* passed to this method. Returning a non-zero value from the callback
|
319
|
+
* will terminate the iteration.
|
274
320
|
*
|
275
321
|
* @param repo Repository where to find the refs
|
276
|
-
* @param list_flags Filtering flags for the reference
|
277
|
-
* listing.
|
322
|
+
* @param list_flags Filtering flags for the reference listing.
|
278
323
|
* @param callback Function which will be called for every listed ref
|
279
324
|
* @param payload Additional data to pass to the callback
|
280
325
|
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
|
281
326
|
*/
|
282
|
-
GIT_EXTERN(int) git_reference_foreach(
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
*
|
287
|
-
* @param ref A git reference
|
288
|
-
* @return 0 in case it's not packed; 1 otherwise
|
289
|
-
*/
|
290
|
-
GIT_EXTERN(int) git_reference_is_packed(git_reference *ref);
|
291
|
-
|
292
|
-
/**
|
293
|
-
* Reload a reference from disk
|
294
|
-
*
|
295
|
-
* Reference pointers may become outdated if the Git
|
296
|
-
* repository is accessed simultaneously by other clients
|
297
|
-
* while the library is open.
|
298
|
-
*
|
299
|
-
* This method forces a reload of the reference from disk,
|
300
|
-
* to ensure that the provided information is still
|
301
|
-
* reliable.
|
302
|
-
*
|
303
|
-
* If the reload fails (e.g. the reference no longer exists
|
304
|
-
* on disk, or has become corrupted), an error code will be
|
305
|
-
* returned and the reference pointer will be invalidated.
|
306
|
-
*
|
307
|
-
* @param ref The reference to reload
|
308
|
-
* @return 0 on success, or an error code
|
309
|
-
*/
|
310
|
-
GIT_EXTERN(int) git_reference_reload(git_reference *ref);
|
327
|
+
GIT_EXTERN(int) git_reference_foreach(
|
328
|
+
git_repository *repo,
|
329
|
+
unsigned int list_flags,
|
330
|
+
git_reference_foreach_cb callback,
|
331
|
+
void *payload);
|
311
332
|
|
312
333
|
/**
|
313
|
-
* Free the given reference
|
334
|
+
* Free the given reference.
|
314
335
|
*
|
315
336
|
* @param ref git_reference
|
316
337
|
*/
|
@@ -326,36 +347,30 @@ GIT_EXTERN(void) git_reference_free(git_reference *ref);
|
|
326
347
|
GIT_EXTERN(int) git_reference_cmp(git_reference *ref1, git_reference *ref2);
|
327
348
|
|
328
349
|
/**
|
329
|
-
*
|
330
|
-
*
|
350
|
+
* Perform a callback on each reference in the repository whose name
|
351
|
+
* matches the given pattern.
|
331
352
|
*
|
332
|
-
*
|
333
|
-
*
|
334
|
-
*
|
335
|
-
* packed ones.
|
353
|
+
* This function acts like `git_reference_foreach()` with an additional
|
354
|
+
* pattern match being applied to the reference name before issuing the
|
355
|
+
* callback function. See that function for more information.
|
336
356
|
*
|
337
|
-
*
|
357
|
+
* The pattern is matched using fnmatch or "glob" style where a '*' matches
|
358
|
+
* any sequence of letters, a '?' matches any letter, and square brackets
|
359
|
+
* can be used to define character ranges (such as "[0-9]" for digits).
|
338
360
|
*
|
339
|
-
* @param
|
340
|
-
*
|
341
|
-
* @param list_flags Filtering flags for the reference
|
342
|
-
*
|
343
|
-
*
|
344
|
-
* @
|
345
|
-
*
|
346
|
-
* @param payload Extra parameter to callback function.
|
347
|
-
*
|
348
|
-
* @return 0 or an error code.
|
361
|
+
* @param repo Repository where to find the refs
|
362
|
+
* @param glob Pattern to match (fnmatch-style) against reference name.
|
363
|
+
* @param list_flags Filtering flags for the reference listing.
|
364
|
+
* @param callback Function which will be called for every listed ref
|
365
|
+
* @param payload Additional data to pass to the callback
|
366
|
+
* @return 0 on success, GIT_EUSER on non-zero callback, or error code
|
349
367
|
*/
|
350
368
|
GIT_EXTERN(int) git_reference_foreach_glob(
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
void *payload),
|
357
|
-
void *payload
|
358
|
-
);
|
369
|
+
git_repository *repo,
|
370
|
+
const char *glob,
|
371
|
+
unsigned int list_flags,
|
372
|
+
git_reference_foreach_cb callback,
|
373
|
+
void *payload);
|
359
374
|
|
360
375
|
/**
|
361
376
|
* Check if a reflog exists for the specified reference.
|
@@ -387,7 +402,8 @@ GIT_EXTERN(int) git_reference_is_branch(git_reference *ref);
|
|
387
402
|
*/
|
388
403
|
GIT_EXTERN(int) git_reference_is_remote(git_reference *ref);
|
389
404
|
|
390
|
-
|
405
|
+
|
406
|
+
typedef enum {
|
391
407
|
GIT_REF_FORMAT_NORMAL = 0,
|
392
408
|
|
393
409
|
/**
|
@@ -406,27 +422,27 @@ enum {
|
|
406
422
|
* (e.g., foo/<star>/bar but not foo/bar<star>).
|
407
423
|
*/
|
408
424
|
GIT_REF_FORMAT_REFSPEC_PATTERN = (1 << 1),
|
409
|
-
};
|
425
|
+
} git_reference_normalize_t;
|
410
426
|
|
411
427
|
/**
|
412
|
-
* Normalize
|
413
|
-
* slash (/) characters and collapsing runs of adjacent slashes
|
414
|
-
* between name components into a single slash.
|
415
|
-
*
|
416
|
-
* Once normalized, if the reference name is valid, it will be
|
417
|
-
* returned in the user allocated buffer.
|
428
|
+
* Normalize reference name and check validity.
|
418
429
|
*
|
419
|
-
*
|
420
|
-
*
|
430
|
+
* This will normalize the reference name by removing any leading slash
|
431
|
+
* '/' characters and collapsing runs of adjacent slashes between name
|
432
|
+
* components into a single slash.
|
421
433
|
*
|
422
|
-
*
|
434
|
+
* Once normalized, if the reference name is valid, it will be returned in
|
435
|
+
* the user allocated buffer.
|
423
436
|
*
|
424
|
-
*
|
437
|
+
* See `git_reference_create_symbolic()` for rules about valid names.
|
425
438
|
*
|
426
|
-
* @param
|
427
|
-
*
|
428
|
-
*
|
429
|
-
* @
|
439
|
+
* @param buffer_out User allocated buffer to store normalized name
|
440
|
+
* @param buffer_size Size of buffer_out
|
441
|
+
* @param name Reference name to be checked.
|
442
|
+
* @param flags Flags to constrain name validation rules - see the
|
443
|
+
* GIT_REF_FORMAT constants above.
|
444
|
+
* @return 0 on success, GIT_EBUFS if buffer is too small, EINVALIDSPEC
|
445
|
+
* or an error code.
|
430
446
|
*/
|
431
447
|
GIT_EXTERN(int) git_reference_normalize_name(
|
432
448
|
char *buffer_out,
|
@@ -435,8 +451,7 @@ GIT_EXTERN(int) git_reference_normalize_name(
|
|
435
451
|
unsigned int flags);
|
436
452
|
|
437
453
|
/**
|
438
|
-
* Recursively peel
|
439
|
-
* specified type is met.
|
454
|
+
* Recursively peel reference until object of the specified type is found.
|
440
455
|
*
|
441
456
|
* The retrieved `peeled` object is owned by the repository
|
442
457
|
* and should be closed with the `git_object_free` method.
|
@@ -446,8 +461,9 @@ GIT_EXTERN(int) git_reference_normalize_name(
|
|
446
461
|
*
|
447
462
|
* @param peeled Pointer to the peeled git_object
|
448
463
|
* @param ref The reference to be processed
|
449
|
-
* @param target_type The type of the requested object
|
450
|
-
*
|
464
|
+
* @param target_type The type of the requested object (GIT_OBJ_COMMIT,
|
465
|
+
* GIT_OBJ_TAG, GIT_OBJ_TREE, GIT_OBJ_BLOB or GIT_OBJ_ANY).
|
466
|
+
* @return 0 on success, GIT_EAMBIGUOUS, GIT_ENOTFOUND or an error code
|
451
467
|
*/
|
452
468
|
GIT_EXTERN(int) git_reference_peel(
|
453
469
|
git_object **out,
|
@@ -457,12 +473,18 @@ GIT_EXTERN(int) git_reference_peel(
|
|
457
473
|
/**
|
458
474
|
* Ensure the reference name is well-formed.
|
459
475
|
*
|
460
|
-
*
|
476
|
+
* Valid reference names must follow one of two patterns:
|
477
|
+
*
|
478
|
+
* 1. Top-level names must contain only capital letters and underscores,
|
479
|
+
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
|
480
|
+
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
|
481
|
+
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
|
482
|
+
* sequences ".." and "@{" which have special meaning to revparse.
|
461
483
|
*
|
484
|
+
* @param refname name to be checked.
|
462
485
|
* @return 1 if the reference name is acceptable; 0 if it isn't
|
463
486
|
*/
|
464
|
-
GIT_EXTERN(int) git_reference_is_valid_name(
|
465
|
-
const char *refname);
|
487
|
+
GIT_EXTERN(int) git_reference_is_valid_name(const char *refname);
|
466
488
|
|
467
489
|
/** @} */
|
468
490
|
GIT_END_DECL
|