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.
|
@@ -27,8 +27,10 @@ GIT_BEGIN_DECL
|
|
27
27
|
*
|
28
28
|
* If libgit2 has been built without GIT_THREADS
|
29
29
|
* support, this function is a no-op.
|
30
|
+
*
|
31
|
+
* @return 0 or an error code
|
30
32
|
*/
|
31
|
-
GIT_EXTERN(
|
33
|
+
GIT_EXTERN(int) git_threads_init(void);
|
32
34
|
|
33
35
|
/**
|
34
36
|
* Shutdown the threading system.
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
#ifndef INCLUDE_git_trace_h__
|
8
|
+
#define INCLUDE_git_trace_h__
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
#include "types.h"
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @file git2/trace.h
|
15
|
+
* @brief Git tracing configuration routines
|
16
|
+
* @defgroup git_trace Git tracing configuration routines
|
17
|
+
* @ingroup Git
|
18
|
+
* @{
|
19
|
+
*/
|
20
|
+
GIT_BEGIN_DECL
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Available tracing levels. When tracing is set to a particular level,
|
24
|
+
* callers will be provided tracing at the given level and all lower levels.
|
25
|
+
*/
|
26
|
+
typedef enum {
|
27
|
+
/** No tracing will be performed. */
|
28
|
+
GIT_TRACE_NONE = 0,
|
29
|
+
|
30
|
+
/** Severe errors that may impact the program's execution */
|
31
|
+
GIT_TRACE_FATAL = 1,
|
32
|
+
|
33
|
+
/** Errors that do not impact the program's execution */
|
34
|
+
GIT_TRACE_ERROR = 2,
|
35
|
+
|
36
|
+
/** Warnings that suggest abnormal data */
|
37
|
+
GIT_TRACE_WARN = 3,
|
38
|
+
|
39
|
+
/** Informational messages about program execution */
|
40
|
+
GIT_TRACE_INFO = 4,
|
41
|
+
|
42
|
+
/** Detailed data that allows for debugging */
|
43
|
+
GIT_TRACE_DEBUG = 5,
|
44
|
+
|
45
|
+
/** Exceptionally detailed debugging data */
|
46
|
+
GIT_TRACE_TRACE = 6
|
47
|
+
} git_trace_level_t;
|
48
|
+
|
49
|
+
/**
|
50
|
+
* An instance for a tracing function
|
51
|
+
*/
|
52
|
+
typedef void (*git_trace_callback)(git_trace_level_t level, const char *msg);
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Sets the system tracing configuration to the specified level with the
|
56
|
+
* specified callback. When system events occur at a level equal to, or
|
57
|
+
* lower than, the given level they will be reported to the given callback.
|
58
|
+
*
|
59
|
+
* @param level Level to set tracing to
|
60
|
+
* @param cb Function to call with trace data
|
61
|
+
* @return 0 or an error code
|
62
|
+
*/
|
63
|
+
GIT_EXTERN(int) git_trace_set(git_trace_level_t level, git_trace_callback cb);
|
64
|
+
|
65
|
+
/** @} */
|
66
|
+
GIT_END_DECL
|
67
|
+
#endif
|
68
|
+
|
@@ -0,0 +1,328 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
+
*
|
4
|
+
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
+
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
+
*/
|
7
|
+
#ifndef INCLUDE_git_transport_h__
|
8
|
+
#define INCLUDE_git_transport_h__
|
9
|
+
|
10
|
+
#include "indexer.h"
|
11
|
+
#include "net.h"
|
12
|
+
#include "types.h"
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @file git2/transport.h
|
16
|
+
* @brief Git transport interfaces and functions
|
17
|
+
* @defgroup git_transport interfaces and functions
|
18
|
+
* @ingroup Git
|
19
|
+
* @{
|
20
|
+
*/
|
21
|
+
GIT_BEGIN_DECL
|
22
|
+
|
23
|
+
/*
|
24
|
+
*** Begin interface for credentials acquisition ***
|
25
|
+
*/
|
26
|
+
|
27
|
+
typedef enum {
|
28
|
+
/* git_cred_userpass_plaintext */
|
29
|
+
GIT_CREDTYPE_USERPASS_PLAINTEXT = 1,
|
30
|
+
} git_credtype_t;
|
31
|
+
|
32
|
+
/* The base structure for all credential types */
|
33
|
+
typedef struct git_cred {
|
34
|
+
git_credtype_t credtype;
|
35
|
+
void (*free)(
|
36
|
+
struct git_cred *cred);
|
37
|
+
} git_cred;
|
38
|
+
|
39
|
+
/* A plaintext username and password */
|
40
|
+
typedef struct git_cred_userpass_plaintext {
|
41
|
+
git_cred parent;
|
42
|
+
char *username;
|
43
|
+
char *password;
|
44
|
+
} git_cred_userpass_plaintext;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Creates a new plain-text username and password credential object.
|
48
|
+
* The supplied credential parameter will be internally duplicated.
|
49
|
+
*
|
50
|
+
* @param out The newly created credential object.
|
51
|
+
* @param username The username of the credential.
|
52
|
+
* @param password The password of the credential.
|
53
|
+
* @return 0 for success or an error code for failure
|
54
|
+
*/
|
55
|
+
GIT_EXTERN(int) git_cred_userpass_plaintext_new(
|
56
|
+
git_cred **out,
|
57
|
+
const char *username,
|
58
|
+
const char *password);
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Signature of a function which acquires a credential object.
|
62
|
+
*
|
63
|
+
* @param cred The newly created credential object.
|
64
|
+
* @param url The resource for which we are demanding a credential.
|
65
|
+
* @param username_from_url The username that was embedded in a "user@host"
|
66
|
+
* remote url, or NULL if not included.
|
67
|
+
* @param allowed_types A bitmask stating which cred types are OK to return.
|
68
|
+
* @param payload The payload provided when specifying this callback.
|
69
|
+
* @return 0 for success or an error code for failure
|
70
|
+
*/
|
71
|
+
typedef int (*git_cred_acquire_cb)(
|
72
|
+
git_cred **cred,
|
73
|
+
const char *url,
|
74
|
+
const char *username_from_url,
|
75
|
+
unsigned int allowed_types,
|
76
|
+
void *payload);
|
77
|
+
|
78
|
+
/*
|
79
|
+
*** End interface for credentials acquisition ***
|
80
|
+
*** Begin base transport interface ***
|
81
|
+
*/
|
82
|
+
|
83
|
+
typedef enum {
|
84
|
+
GIT_TRANSPORTFLAGS_NONE = 0,
|
85
|
+
/* If the connection is secured with SSL/TLS, the authenticity
|
86
|
+
* of the server certificate should not be verified. */
|
87
|
+
GIT_TRANSPORTFLAGS_NO_CHECK_CERT = 1
|
88
|
+
} git_transport_flags_t;
|
89
|
+
|
90
|
+
typedef void (*git_transport_message_cb)(const char *str, int len, void *data);
|
91
|
+
|
92
|
+
typedef struct git_transport {
|
93
|
+
unsigned int version;
|
94
|
+
/* Set progress and error callbacks */
|
95
|
+
int (*set_callbacks)(struct git_transport *transport,
|
96
|
+
git_transport_message_cb progress_cb,
|
97
|
+
git_transport_message_cb error_cb,
|
98
|
+
void *payload);
|
99
|
+
|
100
|
+
/* Connect the transport to the remote repository, using the given
|
101
|
+
* direction. */
|
102
|
+
int (*connect)(struct git_transport *transport,
|
103
|
+
const char *url,
|
104
|
+
git_cred_acquire_cb cred_acquire_cb,
|
105
|
+
void *cred_acquire_payload,
|
106
|
+
int direction,
|
107
|
+
int flags);
|
108
|
+
|
109
|
+
/* This function may be called after a successful call to connect(). The
|
110
|
+
* provided callback is invoked for each ref discovered on the remote
|
111
|
+
* end. */
|
112
|
+
int (*ls)(struct git_transport *transport,
|
113
|
+
git_headlist_cb list_cb,
|
114
|
+
void *payload);
|
115
|
+
|
116
|
+
/* Executes the push whose context is in the git_push object. */
|
117
|
+
int (*push)(struct git_transport *transport, git_push *push);
|
118
|
+
|
119
|
+
/* This function may be called after a successful call to connect(), when
|
120
|
+
* the direction is FETCH. The function performs a negotiation to calculate
|
121
|
+
* the wants list for the fetch. */
|
122
|
+
int (*negotiate_fetch)(struct git_transport *transport,
|
123
|
+
git_repository *repo,
|
124
|
+
const git_remote_head * const *refs,
|
125
|
+
size_t count);
|
126
|
+
|
127
|
+
/* This function may be called after a successful call to negotiate_fetch(),
|
128
|
+
* when the direction is FETCH. This function retrieves the pack file for
|
129
|
+
* the fetch from the remote end. */
|
130
|
+
int (*download_pack)(struct git_transport *transport,
|
131
|
+
git_repository *repo,
|
132
|
+
git_transfer_progress *stats,
|
133
|
+
git_transfer_progress_callback progress_cb,
|
134
|
+
void *progress_payload);
|
135
|
+
|
136
|
+
/* Checks to see if the transport is connected */
|
137
|
+
int (*is_connected)(struct git_transport *transport);
|
138
|
+
|
139
|
+
/* Reads the flags value previously passed into connect() */
|
140
|
+
int (*read_flags)(struct git_transport *transport, int *flags);
|
141
|
+
|
142
|
+
/* Cancels any outstanding transport operation */
|
143
|
+
void (*cancel)(struct git_transport *transport);
|
144
|
+
|
145
|
+
/* This function is the reverse of connect() -- it terminates the
|
146
|
+
* connection to the remote end. */
|
147
|
+
int (*close)(struct git_transport *transport);
|
148
|
+
|
149
|
+
/* Frees/destructs the git_transport object. */
|
150
|
+
void (*free)(struct git_transport *transport);
|
151
|
+
} git_transport;
|
152
|
+
|
153
|
+
#define GIT_TRANSPORT_VERSION 1
|
154
|
+
#define GIT_TRANSPORT_INIT {GIT_TRANSPORT_VERSION}
|
155
|
+
|
156
|
+
/**
|
157
|
+
* Function to use to create a transport from a URL. The transport database
|
158
|
+
* is scanned to find a transport that implements the scheme of the URI (i.e.
|
159
|
+
* git:// or http://) and a transport object is returned to the caller.
|
160
|
+
*
|
161
|
+
* @param out The newly created transport (out)
|
162
|
+
* @param owner The git_remote which will own this transport
|
163
|
+
* @param url The URL to connect to
|
164
|
+
* @return 0 or an error code
|
165
|
+
*/
|
166
|
+
GIT_EXTERN(int) git_transport_new(git_transport **out, git_remote *owner, const char *url);
|
167
|
+
|
168
|
+
/* Signature of a function which creates a transport */
|
169
|
+
typedef int (*git_transport_cb)(git_transport **out, git_remote *owner, void *param);
|
170
|
+
|
171
|
+
/* Transports which come with libgit2 (match git_transport_cb). The expected
|
172
|
+
* value for "param" is listed in-line below. */
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Create an instance of the dummy transport.
|
176
|
+
*
|
177
|
+
* @param out The newly created transport (out)
|
178
|
+
* @param owner The git_remote which will own this transport
|
179
|
+
* @param payload You must pass NULL for this parameter.
|
180
|
+
* @return 0 or an error code
|
181
|
+
*/
|
182
|
+
GIT_EXTERN(int) git_transport_dummy(
|
183
|
+
git_transport **out,
|
184
|
+
git_remote *owner,
|
185
|
+
/* NULL */ void *payload);
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Create an instance of the local transport.
|
189
|
+
*
|
190
|
+
* @param out The newly created transport (out)
|
191
|
+
* @param owner The git_remote which will own this transport
|
192
|
+
* @param payload You must pass NULL for this parameter.
|
193
|
+
* @return 0 or an error code
|
194
|
+
*/
|
195
|
+
GIT_EXTERN(int) git_transport_local(
|
196
|
+
git_transport **out,
|
197
|
+
git_remote *owner,
|
198
|
+
/* NULL */ void *payload);
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Create an instance of the smart transport.
|
202
|
+
*
|
203
|
+
* @param out The newly created transport (out)
|
204
|
+
* @param owner The git_remote which will own this transport
|
205
|
+
* @param payload A pointer to a git_smart_subtransport_definition
|
206
|
+
* @return 0 or an error code
|
207
|
+
*/
|
208
|
+
GIT_EXTERN(int) git_transport_smart(
|
209
|
+
git_transport **out,
|
210
|
+
git_remote *owner,
|
211
|
+
/* (git_smart_subtransport_definition *) */ void *payload);
|
212
|
+
|
213
|
+
/*
|
214
|
+
*** End of base transport interface ***
|
215
|
+
*** Begin interface for subtransports for the smart transport ***
|
216
|
+
*/
|
217
|
+
|
218
|
+
/* The smart transport knows how to speak the git protocol, but it has no
|
219
|
+
* knowledge of how to establish a connection between it and another endpoint,
|
220
|
+
* or how to move data back and forth. For this, a subtransport interface is
|
221
|
+
* declared, and the smart transport delegates this work to the subtransports.
|
222
|
+
* Three subtransports are implemented: git, http, and winhttp. (The http and
|
223
|
+
* winhttp transports each implement both http and https.) */
|
224
|
+
|
225
|
+
/* Subtransports can either be RPC = 0 (persistent connection) or RPC = 1
|
226
|
+
* (request/response). The smart transport handles the differences in its own
|
227
|
+
* logic. The git subtransport is RPC = 0, while http and winhttp are both
|
228
|
+
* RPC = 1. */
|
229
|
+
|
230
|
+
/* Actions that the smart transport can ask
|
231
|
+
* a subtransport to perform */
|
232
|
+
typedef enum {
|
233
|
+
GIT_SERVICE_UPLOADPACK_LS = 1,
|
234
|
+
GIT_SERVICE_UPLOADPACK = 2,
|
235
|
+
GIT_SERVICE_RECEIVEPACK_LS = 3,
|
236
|
+
GIT_SERVICE_RECEIVEPACK = 4,
|
237
|
+
} git_smart_service_t;
|
238
|
+
|
239
|
+
struct git_smart_subtransport;
|
240
|
+
|
241
|
+
/* A stream used by the smart transport to read and write data
|
242
|
+
* from a subtransport */
|
243
|
+
typedef struct git_smart_subtransport_stream {
|
244
|
+
/* The owning subtransport */
|
245
|
+
struct git_smart_subtransport *subtransport;
|
246
|
+
|
247
|
+
int (*read)(
|
248
|
+
struct git_smart_subtransport_stream *stream,
|
249
|
+
char *buffer,
|
250
|
+
size_t buf_size,
|
251
|
+
size_t *bytes_read);
|
252
|
+
|
253
|
+
int (*write)(
|
254
|
+
struct git_smart_subtransport_stream *stream,
|
255
|
+
const char *buffer,
|
256
|
+
size_t len);
|
257
|
+
|
258
|
+
void (*free)(
|
259
|
+
struct git_smart_subtransport_stream *stream);
|
260
|
+
} git_smart_subtransport_stream;
|
261
|
+
|
262
|
+
/* An implementation of a subtransport which carries data for the
|
263
|
+
* smart transport */
|
264
|
+
typedef struct git_smart_subtransport {
|
265
|
+
int (* action)(
|
266
|
+
git_smart_subtransport_stream **out,
|
267
|
+
struct git_smart_subtransport *transport,
|
268
|
+
const char *url,
|
269
|
+
git_smart_service_t action);
|
270
|
+
|
271
|
+
/* Subtransports are guaranteed a call to close() between
|
272
|
+
* calls to action(), except for the following two "natural" progressions
|
273
|
+
* of actions against a constant URL.
|
274
|
+
*
|
275
|
+
* 1. UPLOADPACK_LS -> UPLOADPACK
|
276
|
+
* 2. RECEIVEPACK_LS -> RECEIVEPACK */
|
277
|
+
int (* close)(struct git_smart_subtransport *transport);
|
278
|
+
|
279
|
+
void (* free)(struct git_smart_subtransport *transport);
|
280
|
+
} git_smart_subtransport;
|
281
|
+
|
282
|
+
/* A function which creates a new subtransport for the smart transport */
|
283
|
+
typedef int (*git_smart_subtransport_cb)(
|
284
|
+
git_smart_subtransport **out,
|
285
|
+
git_transport* owner);
|
286
|
+
|
287
|
+
typedef struct git_smart_subtransport_definition {
|
288
|
+
/* The function to use to create the git_smart_subtransport */
|
289
|
+
git_smart_subtransport_cb callback;
|
290
|
+
|
291
|
+
/* True if the protocol is stateless; false otherwise. For example,
|
292
|
+
* http:// is stateless, but git:// is not. */
|
293
|
+
unsigned rpc;
|
294
|
+
} git_smart_subtransport_definition;
|
295
|
+
|
296
|
+
/* Smart transport subtransports that come with libgit2 */
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Create an instance of the http subtransport. This subtransport
|
300
|
+
* also supports https. On Win32, this subtransport may be implemented
|
301
|
+
* using the WinHTTP library.
|
302
|
+
*
|
303
|
+
* @param out The newly created subtransport
|
304
|
+
* @param owner The smart transport to own this subtransport
|
305
|
+
* @return 0 or an error code
|
306
|
+
*/
|
307
|
+
GIT_EXTERN(int) git_smart_subtransport_http(
|
308
|
+
git_smart_subtransport **out,
|
309
|
+
git_transport* owner);
|
310
|
+
|
311
|
+
/**
|
312
|
+
* Create an instance of the git subtransport.
|
313
|
+
*
|
314
|
+
* @param out The newly created subtransport
|
315
|
+
* @param owner The smart transport to own this subtransport
|
316
|
+
* @return 0 or an error code
|
317
|
+
*/
|
318
|
+
GIT_EXTERN(int) git_smart_subtransport_git(
|
319
|
+
git_smart_subtransport **out,
|
320
|
+
git_transport* owner);
|
321
|
+
|
322
|
+
/*
|
323
|
+
*** End interface for subtransports for the smart transport ***
|
324
|
+
*/
|
325
|
+
|
326
|
+
/** @} */
|
327
|
+
GIT_END_DECL
|
328
|
+
#endif
|
@@ -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.
|
@@ -24,14 +24,15 @@ GIT_BEGIN_DECL
|
|
24
24
|
/**
|
25
25
|
* Lookup a tree object from the repository.
|
26
26
|
*
|
27
|
-
* @param
|
28
|
-
* @param repo
|
29
|
-
* @param id
|
27
|
+
* @param out Pointer to the looked up tree
|
28
|
+
* @param repo The repo to use when locating the tree.
|
29
|
+
* @param id Identity of the tree to locate.
|
30
30
|
* @return 0 or an error code
|
31
31
|
*/
|
32
|
-
GIT_INLINE(int) git_tree_lookup(
|
32
|
+
GIT_INLINE(int) git_tree_lookup(
|
33
|
+
git_tree **out, git_repository *repo, const git_oid *id)
|
33
34
|
{
|
34
|
-
return git_object_lookup((git_object **)
|
35
|
+
return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_TREE);
|
35
36
|
}
|
36
37
|
|
37
38
|
/**
|
@@ -47,53 +48,30 @@ GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git
|
|
47
48
|
* @return 0 or an error code
|
48
49
|
*/
|
49
50
|
GIT_INLINE(int) git_tree_lookup_prefix(
|
50
|
-
git_tree **
|
51
|
+
git_tree **out,
|
51
52
|
git_repository *repo,
|
52
53
|
const git_oid *id,
|
53
54
|
size_t len)
|
54
55
|
{
|
55
|
-
return git_object_lookup_prefix(
|
56
|
+
return git_object_lookup_prefix(
|
57
|
+
(git_object **)out, repo, id, len, GIT_OBJ_TREE);
|
56
58
|
}
|
57
59
|
|
58
60
|
/**
|
59
61
|
* Close an open tree
|
60
62
|
*
|
61
|
-
*
|
63
|
+
* You can no longer use the git_tree pointer after this call.
|
62
64
|
*
|
63
|
-
* IMPORTANT:
|
64
|
-
*
|
65
|
-
* using a tree. Failure to do so will cause a memory leak.
|
65
|
+
* IMPORTANT: You MUST call this method when you stop using a tree to
|
66
|
+
* release memory. Failure to do so will cause a memory leak.
|
66
67
|
*
|
67
|
-
* @param tree
|
68
|
+
* @param tree The tree to close
|
68
69
|
*/
|
69
70
|
GIT_INLINE(void) git_tree_free(git_tree *tree)
|
70
71
|
{
|
71
|
-
git_object_free((git_object *)
|
72
|
+
git_object_free((git_object *)tree);
|
72
73
|
}
|
73
74
|
|
74
|
-
/**
|
75
|
-
* Free a tree entry
|
76
|
-
*
|
77
|
-
* IMPORTANT: This function is only needed for tree
|
78
|
-
* entries owned by the user, such as the ones returned
|
79
|
-
* by `git_tree_entry_dup`.
|
80
|
-
*
|
81
|
-
* @param entry The entry to free
|
82
|
-
*/
|
83
|
-
GIT_EXTERN(void) git_tree_entry_free(git_tree_entry *entry);
|
84
|
-
|
85
|
-
/**
|
86
|
-
* Duplicate a tree entry
|
87
|
-
*
|
88
|
-
* Create a copy of a tree entry. The returned copy is owned
|
89
|
-
* by the user, and must be freed manually with
|
90
|
-
* `git_tree_entry_free`.
|
91
|
-
*
|
92
|
-
* @param entry A tree entry to duplicate
|
93
|
-
* @return a copy of the original entry
|
94
|
-
*/
|
95
|
-
GIT_EXTERN(git_tree_entry *) git_tree_entry_dup(const git_tree_entry *entry);
|
96
|
-
|
97
75
|
/**
|
98
76
|
* Get the id of a tree.
|
99
77
|
*
|
@@ -102,50 +80,101 @@ GIT_EXTERN(git_tree_entry *) git_tree_entry_dup(const git_tree_entry *entry);
|
|
102
80
|
*/
|
103
81
|
GIT_EXTERN(const git_oid *) git_tree_id(const git_tree *tree);
|
104
82
|
|
83
|
+
/**
|
84
|
+
* Get the repository that contains the tree.
|
85
|
+
*
|
86
|
+
* @param tree A previously loaded tree.
|
87
|
+
* @return Repository that contains this tree.
|
88
|
+
*/
|
89
|
+
GIT_EXTERN(git_repository *) git_tree_owner(const git_tree *tree);
|
90
|
+
|
105
91
|
/**
|
106
92
|
* Get the number of entries listed in a tree
|
107
93
|
*
|
108
94
|
* @param tree a previously loaded tree.
|
109
95
|
* @return the number of entries in the tree
|
110
96
|
*/
|
111
|
-
GIT_EXTERN(
|
97
|
+
GIT_EXTERN(size_t) git_tree_entrycount(const git_tree *tree);
|
112
98
|
|
113
99
|
/**
|
114
100
|
* Lookup a tree entry by its filename
|
115
101
|
*
|
102
|
+
* This returns a git_tree_entry that is owned by the git_tree. You don't
|
103
|
+
* have to free it, but you must not use it after the git_tree is released.
|
104
|
+
*
|
116
105
|
* @param tree a previously loaded tree.
|
117
106
|
* @param filename the filename of the desired entry
|
118
107
|
* @return the tree entry; NULL if not found
|
119
108
|
*/
|
120
|
-
GIT_EXTERN(const git_tree_entry *) git_tree_entry_byname(
|
109
|
+
GIT_EXTERN(const git_tree_entry *) git_tree_entry_byname(
|
110
|
+
git_tree *tree, const char *filename);
|
121
111
|
|
122
112
|
/**
|
123
113
|
* Lookup a tree entry by its position in the tree
|
124
114
|
*
|
115
|
+
* This returns a git_tree_entry that is owned by the git_tree. You don't
|
116
|
+
* have to free it, but you must not use it after the git_tree is released.
|
117
|
+
*
|
125
118
|
* @param tree a previously loaded tree.
|
126
119
|
* @param idx the position in the entry list
|
127
120
|
* @return the tree entry; NULL if not found
|
128
121
|
*/
|
129
|
-
GIT_EXTERN(const git_tree_entry *) git_tree_entry_byindex(
|
122
|
+
GIT_EXTERN(const git_tree_entry *) git_tree_entry_byindex(
|
123
|
+
git_tree *tree, size_t idx);
|
130
124
|
|
131
125
|
/**
|
132
126
|
* Lookup a tree entry by SHA value.
|
133
127
|
*
|
128
|
+
* This returns a git_tree_entry that is owned by the git_tree. You don't
|
129
|
+
* have to free it, but you must not use it after the git_tree is released.
|
130
|
+
*
|
134
131
|
* Warning: this must examine every entry in the tree, so it is not fast.
|
135
132
|
*
|
136
133
|
* @param tree a previously loaded tree.
|
137
134
|
* @param oid the sha being looked for
|
138
135
|
* @return the tree entry; NULL if not found
|
139
136
|
*/
|
140
|
-
GIT_EXTERN(const git_tree_entry *) git_tree_entry_byoid(
|
137
|
+
GIT_EXTERN(const git_tree_entry *) git_tree_entry_byoid(
|
138
|
+
const git_tree *tree, const git_oid *oid);
|
141
139
|
|
142
140
|
/**
|
143
|
-
*
|
141
|
+
* Retrieve a tree entry contained in a tree or in any of its subtrees,
|
142
|
+
* given its relative path.
|
144
143
|
*
|
145
|
-
*
|
146
|
-
*
|
144
|
+
* Unlike the other lookup functions, the returned tree entry is owned by
|
145
|
+
* the user and must be freed explicitly with `git_tree_entry_free()`.
|
146
|
+
*
|
147
|
+
* @param out Pointer where to store the tree entry
|
148
|
+
* @param root Previously loaded tree which is the root of the relative path
|
149
|
+
* @param subtree_path Path to the contained entry
|
150
|
+
* @return 0 on success; GIT_ENOTFOUND if the path does not exist
|
147
151
|
*/
|
148
|
-
GIT_EXTERN(
|
152
|
+
GIT_EXTERN(int) git_tree_entry_bypath(
|
153
|
+
git_tree_entry **out,
|
154
|
+
git_tree *root,
|
155
|
+
const char *path);
|
156
|
+
|
157
|
+
/**
|
158
|
+
* Duplicate a tree entry
|
159
|
+
*
|
160
|
+
* Create a copy of a tree entry. The returned copy is owned by the user,
|
161
|
+
* and must be freed explicitly with `git_tree_entry_free()`.
|
162
|
+
*
|
163
|
+
* @param entry A tree entry to duplicate
|
164
|
+
* @return a copy of the original entry or NULL on error (alloc failure)
|
165
|
+
*/
|
166
|
+
GIT_EXTERN(git_tree_entry *) git_tree_entry_dup(const git_tree_entry *entry);
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Free a user-owned tree entry
|
170
|
+
*
|
171
|
+
* IMPORTANT: This function is only needed for tree entries owned by the
|
172
|
+
* user, such as the ones returned by `git_tree_entry_dup()` or
|
173
|
+
* `git_tree_entry_bypath()`.
|
174
|
+
*
|
175
|
+
* @param entry The entry to free
|
176
|
+
*/
|
177
|
+
GIT_EXTERN(void) git_tree_entry_free(git_tree_entry *entry);
|
149
178
|
|
150
179
|
/**
|
151
180
|
* Get the filename of a tree entry
|
@@ -171,9 +200,28 @@ GIT_EXTERN(const git_oid *) git_tree_entry_id(const git_tree_entry *entry);
|
|
171
200
|
*/
|
172
201
|
GIT_EXTERN(git_otype) git_tree_entry_type(const git_tree_entry *entry);
|
173
202
|
|
203
|
+
/**
|
204
|
+
* Get the UNIX file attributes of a tree entry
|
205
|
+
*
|
206
|
+
* @param entry a tree entry
|
207
|
+
* @return filemode as an integer
|
208
|
+
*/
|
209
|
+
GIT_EXTERN(git_filemode_t) git_tree_entry_filemode(const git_tree_entry *entry);
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Compare two tree entries
|
213
|
+
*
|
214
|
+
* @param e1 first tree entry
|
215
|
+
* @param e2 second tree entry
|
216
|
+
* @return <0 if e1 is before e2, 0 if e1 == e2, >0 if e1 is after e2
|
217
|
+
*/
|
218
|
+
GIT_EXTERN(int) git_tree_entry_cmp(const git_tree_entry *e1, const git_tree_entry *e2);
|
219
|
+
|
174
220
|
/**
|
175
221
|
* Convert a tree entry to the git_object it points too.
|
176
222
|
*
|
223
|
+
* You must call `git_object_free()` on the object when you are done with it.
|
224
|
+
*
|
177
225
|
* @param object pointer to the converted object
|
178
226
|
* @param repo repository where to lookup the pointed object
|
179
227
|
* @param entry a tree entry
|
@@ -184,42 +232,24 @@ GIT_EXTERN(int) git_tree_entry_to_object(
|
|
184
232
|
git_repository *repo,
|
185
233
|
const git_tree_entry *entry);
|
186
234
|
|
187
|
-
/**
|
188
|
-
* Write a tree to the ODB from the index file
|
189
|
-
*
|
190
|
-
* This method will scan the index and write a representation
|
191
|
-
* of its current state back to disk; it recursively creates
|
192
|
-
* tree objects for each of the subtrees stored in the index,
|
193
|
-
* but only returns the OID of the root tree. This is the OID
|
194
|
-
* that can be used e.g. to create a commit.
|
195
|
-
*
|
196
|
-
* The index instance cannot be bare, and needs to be associated
|
197
|
-
* to an existing repository.
|
198
|
-
*
|
199
|
-
* @param oid Pointer where to store the written tree
|
200
|
-
* @param index Index to write
|
201
|
-
* @return 0 or an error code
|
202
|
-
*/
|
203
|
-
GIT_EXTERN(int) git_tree_create_fromindex(git_oid *oid, git_index *index);
|
204
|
-
|
205
235
|
/**
|
206
236
|
* Create a new tree builder.
|
207
237
|
*
|
208
|
-
* The tree builder can be used to create or modify
|
209
|
-
*
|
210
|
-
* database.
|
238
|
+
* The tree builder can be used to create or modify trees in memory and
|
239
|
+
* write them as tree objects to the database.
|
211
240
|
*
|
212
|
-
* If the `source` parameter is not NULL, the tree builder
|
213
|
-
*
|
241
|
+
* If the `source` parameter is not NULL, the tree builder will be
|
242
|
+
* initialized with the entries of the given tree.
|
214
243
|
*
|
215
|
-
* If the `source` parameter is NULL, the tree builder will
|
216
|
-
*
|
244
|
+
* If the `source` parameter is NULL, the tree builder will start with no
|
245
|
+
* entries and will have to be filled manually.
|
217
246
|
*
|
218
|
-
* @param
|
247
|
+
* @param out Pointer where to store the tree builder
|
219
248
|
* @param source Source tree to initialize the builder (optional)
|
220
249
|
* @return 0 on success; error code otherwise
|
221
250
|
*/
|
222
|
-
GIT_EXTERN(int) git_treebuilder_create(
|
251
|
+
GIT_EXTERN(int) git_treebuilder_create(
|
252
|
+
git_treebuilder **out, const git_tree *source);
|
223
253
|
|
224
254
|
/**
|
225
255
|
* Clear all the entires in the builder
|
@@ -228,6 +258,14 @@ GIT_EXTERN(int) git_treebuilder_create(git_treebuilder **builder_p, const git_tr
|
|
228
258
|
*/
|
229
259
|
GIT_EXTERN(void) git_treebuilder_clear(git_treebuilder *bld);
|
230
260
|
|
261
|
+
/**
|
262
|
+
* Get the number of entries listed in a treebuilder
|
263
|
+
*
|
264
|
+
* @param tree a previously loaded treebuilder.
|
265
|
+
* @return the number of entries in the treebuilder
|
266
|
+
*/
|
267
|
+
GIT_EXTERN(unsigned int) git_treebuilder_entrycount(git_treebuilder *bld);
|
268
|
+
|
231
269
|
/**
|
232
270
|
* Free a tree builder
|
233
271
|
*
|
@@ -249,7 +287,8 @@ GIT_EXTERN(void) git_treebuilder_free(git_treebuilder *bld);
|
|
249
287
|
* @param filename Name of the entry
|
250
288
|
* @return pointer to the entry; NULL if not found
|
251
289
|
*/
|
252
|
-
GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(
|
290
|
+
GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(
|
291
|
+
git_treebuilder *bld, const char *filename);
|
253
292
|
|
254
293
|
/**
|
255
294
|
* Add or update an entry to the builder
|
@@ -257,17 +296,17 @@ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(git_treebuilder *bld, con
|
|
257
296
|
* Insert a new entry for `filename` in the builder with the
|
258
297
|
* given attributes.
|
259
298
|
*
|
260
|
-
*
|
299
|
+
* If an entry named `filename` already exists, its attributes
|
261
300
|
* will be updated with the given ones.
|
262
301
|
*
|
263
|
-
* The optional pointer `
|
264
|
-
*
|
302
|
+
* The optional pointer `out` can be used to retrieve a pointer to
|
303
|
+
* the newly created/updated entry. Pass NULL if you do not need it.
|
265
304
|
*
|
266
305
|
* No attempt is being made to ensure that the provided oid points
|
267
306
|
* to an existing git object in the object database, nor that the
|
268
307
|
* attributes make sense regarding the type of the pointed at object.
|
269
308
|
*
|
270
|
-
* @param
|
309
|
+
* @param out Pointer to store the entry (optional)
|
271
310
|
* @param bld Tree builder
|
272
311
|
* @param filename Filename of the entry
|
273
312
|
* @param id SHA1 oid of the entry
|
@@ -277,7 +316,7 @@ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(git_treebuilder *bld, con
|
|
277
316
|
* @return 0 or an error code
|
278
317
|
*/
|
279
318
|
GIT_EXTERN(int) git_treebuilder_insert(
|
280
|
-
const git_tree_entry **
|
319
|
+
const git_tree_entry **out,
|
281
320
|
git_treebuilder *bld,
|
282
321
|
const char *filename,
|
283
322
|
const git_oid *id,
|
@@ -289,85 +328,75 @@ GIT_EXTERN(int) git_treebuilder_insert(
|
|
289
328
|
* @param bld Tree builder
|
290
329
|
* @param filename Filename of the entry to remove
|
291
330
|
*/
|
292
|
-
GIT_EXTERN(int) git_treebuilder_remove(
|
331
|
+
GIT_EXTERN(int) git_treebuilder_remove(
|
332
|
+
git_treebuilder *bld, const char *filename);
|
333
|
+
|
334
|
+
typedef int (*git_treebuilder_filter_cb)(
|
335
|
+
const git_tree_entry *entry, void *payload);
|
293
336
|
|
294
337
|
/**
|
295
338
|
* Filter the entries in the tree
|
296
339
|
*
|
297
|
-
* The `filter` callback will be called for each entry
|
298
|
-
*
|
299
|
-
*
|
300
|
-
* entry will be filtered (removed from the builder).
|
340
|
+
* The `filter` callback will be called for each entry in the tree with a
|
341
|
+
* pointer to the entry and the provided `payload`; if the callback returns
|
342
|
+
* non-zero, the entry will be filtered (removed from the builder).
|
301
343
|
*
|
302
344
|
* @param bld Tree builder
|
303
345
|
* @param filter Callback to filter entries
|
346
|
+
* @param payload Extra data to pass to filter
|
304
347
|
*/
|
305
348
|
GIT_EXTERN(void) git_treebuilder_filter(
|
306
349
|
git_treebuilder *bld,
|
307
|
-
|
350
|
+
git_treebuilder_filter_cb filter,
|
308
351
|
void *payload);
|
309
352
|
|
310
353
|
/**
|
311
354
|
* Write the contents of the tree builder as a tree object
|
312
355
|
*
|
313
|
-
* The tree builder will be written to the given `repo`, and
|
314
|
-
*
|
315
|
-
* pointer.
|
356
|
+
* The tree builder will be written to the given `repo`, and its
|
357
|
+
* identifying SHA1 hash will be stored in the `id` pointer.
|
316
358
|
*
|
317
|
-
* @param
|
318
|
-
* @param repo Repository
|
359
|
+
* @param id Pointer to store the OID of the newly written tree
|
360
|
+
* @param repo Repository in which to store the object
|
319
361
|
* @param bld Tree builder to write
|
320
362
|
* @return 0 or an error code
|
321
363
|
*/
|
322
|
-
GIT_EXTERN(int) git_treebuilder_write(
|
364
|
+
GIT_EXTERN(int) git_treebuilder_write(
|
365
|
+
git_oid *id, git_repository *repo, git_treebuilder *bld);
|
323
366
|
|
324
|
-
/**
|
325
|
-
* Retrieve a tree entry contained in a tree or in any
|
326
|
-
* of its subtrees, given its relative path.
|
327
|
-
*
|
328
|
-
* The returned tree entry is owned by the user and must
|
329
|
-
* be freed manually with `git_tree_entry_free`.
|
330
|
-
*
|
331
|
-
* @param entry Pointer where to store the tree entry
|
332
|
-
* @param root A previously loaded tree which will be the root of the relative path
|
333
|
-
* @param subtree_path Path to the contained entry
|
334
|
-
* @return 0 on success; GIT_ENOTFOUND if the path does not exist
|
335
|
-
*/
|
336
|
-
GIT_EXTERN(int) git_tree_entry_bypath(
|
337
|
-
git_tree_entry **entry,
|
338
|
-
git_tree *root,
|
339
|
-
const char *path);
|
340
367
|
|
341
368
|
/** Callback for the tree traversal method */
|
342
|
-
typedef int (*git_treewalk_cb)(
|
369
|
+
typedef int (*git_treewalk_cb)(
|
370
|
+
const char *root, const git_tree_entry *entry, void *payload);
|
343
371
|
|
344
372
|
/** Tree traversal modes */
|
345
|
-
enum
|
373
|
+
typedef enum {
|
346
374
|
GIT_TREEWALK_PRE = 0, /* Pre-order */
|
347
375
|
GIT_TREEWALK_POST = 1, /* Post-order */
|
348
|
-
};
|
376
|
+
} git_treewalk_mode;
|
349
377
|
|
350
378
|
/**
|
351
|
-
* Traverse the entries in a tree and its subtrees in
|
352
|
-
* post or pre order
|
379
|
+
* Traverse the entries in a tree and its subtrees in post or pre order.
|
353
380
|
*
|
354
|
-
* The entries will be traversed in the specified order,
|
355
|
-
*
|
356
|
-
*
|
357
|
-
* the
|
358
|
-
* data itself.
|
381
|
+
* The entries will be traversed in the specified order, children subtrees
|
382
|
+
* will be automatically loaded as required, and the `callback` will be
|
383
|
+
* called once per entry with the current (relative) root for the entry and
|
384
|
+
* the entry data itself.
|
359
385
|
*
|
360
386
|
* If the callback returns a positive value, the passed entry will be
|
361
|
-
* skipped on the traversal (in pre mode). A negative value stops the
|
362
|
-
* walk.
|
387
|
+
* skipped on the traversal (in pre mode). A negative value stops the walk.
|
363
388
|
*
|
364
389
|
* @param tree The tree to walk
|
365
|
-
* @param callback Function to call on each tree entry
|
366
390
|
* @param mode Traversal mode (pre or post-order)
|
391
|
+
* @param callback Function to call on each tree entry
|
367
392
|
* @param payload Opaque pointer to be passed on each callback
|
368
393
|
* @return 0 or an error code
|
369
394
|
*/
|
370
|
-
GIT_EXTERN(int) git_tree_walk(
|
395
|
+
GIT_EXTERN(int) git_tree_walk(
|
396
|
+
const git_tree *tree,
|
397
|
+
git_treewalk_mode mode,
|
398
|
+
git_treewalk_cb callback,
|
399
|
+
void *payload);
|
371
400
|
|
372
401
|
/** @} */
|
373
402
|
|