rugged 0.18.0.gh.de28323 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -4
- data/Rakefile +1 -1
- data/ext/rugged/extconf.rb +10 -0
- data/ext/rugged/rugged.c +153 -86
- data/ext/rugged/rugged.h +44 -33
- data/ext/rugged/rugged_blob.c +288 -60
- data/ext/rugged/rugged_branch.c +82 -57
- data/ext/rugged/rugged_commit.c +83 -86
- data/ext/rugged/rugged_config.c +68 -68
- data/ext/rugged/rugged_diff.c +509 -0
- data/ext/rugged/rugged_diff_delta.c +94 -0
- data/ext/rugged/rugged_diff_hunk.c +100 -0
- data/ext/rugged/rugged_diff_line.c +79 -0
- data/ext/rugged/rugged_diff_patch.c +169 -0
- data/ext/rugged/rugged_index.c +539 -8
- data/ext/rugged/rugged_note.c +74 -80
- data/ext/rugged/rugged_object.c +63 -8
- data/ext/rugged/rugged_reference.c +231 -145
- data/ext/rugged/rugged_remote.c +509 -53
- data/ext/rugged/rugged_repo.c +572 -236
- data/ext/rugged/rugged_revwalk.c +59 -36
- data/ext/rugged/rugged_settings.c +7 -9
- data/ext/rugged/rugged_signature.c +7 -11
- data/ext/rugged/rugged_tag.c +93 -39
- data/ext/rugged/rugged_tree.c +321 -58
- data/lib/rugged.rb +1 -0
- data/lib/rugged/commit.rb +16 -1
- data/lib/rugged/console.rb +9 -0
- data/lib/rugged/diff.rb +19 -0
- data/lib/rugged/diff/delta.rb +54 -0
- data/lib/rugged/diff/hunk.rb +23 -0
- data/lib/rugged/diff/line.rb +29 -0
- data/lib/rugged/diff/patch.rb +28 -0
- data/lib/rugged/repository.rb +36 -39
- data/lib/rugged/version.rb +1 -1
- data/test/blob_test.rb +308 -1
- data/test/branch_test.rb +7 -0
- data/test/commit_test.rb +7 -10
- data/test/coverage/cover.rb +9 -1
- data/test/diff_test.rb +777 -0
- data/test/fixtures/archive.tar.gz +0 -0
- data/test/fixtures/attr/attr0 +1 -0
- data/test/fixtures/attr/attr1 +29 -0
- data/test/fixtures/attr/attr2 +21 -0
- data/test/fixtures/attr/attr3 +4 -0
- data/test/fixtures/attr/binfile +1 -0
- data/test/fixtures/attr/dir/file +0 -0
- data/test/fixtures/attr/file +1 -0
- data/test/fixtures/attr/gitattributes +29 -0
- data/test/fixtures/attr/gitignore +2 -0
- data/test/fixtures/attr/ign +1 -0
- data/test/fixtures/attr/macro_bad +1 -0
- data/test/fixtures/attr/macro_test +1 -0
- data/test/fixtures/attr/root_test1 +1 -0
- data/test/fixtures/attr/root_test2 +6 -0
- data/test/fixtures/attr/root_test3 +19 -0
- data/test/fixtures/attr/root_test4.txt +14 -0
- data/test/fixtures/attr/sub/abc +37 -0
- data/test/fixtures/attr/sub/dir/file +0 -0
- data/test/fixtures/attr/sub/file +1 -0
- data/test/fixtures/attr/sub/ign/file +1 -0
- data/test/fixtures/attr/sub/ign/sub/file +1 -0
- data/test/fixtures/attr/sub/sub/dir +0 -0
- data/test/fixtures/attr/sub/sub/file +1 -0
- data/test/fixtures/attr/sub/sub/subsub.txt +1 -0
- data/test/fixtures/attr/sub/subdir_test1 +2 -0
- data/test/fixtures/attr/sub/subdir_test2.txt +1 -0
- data/test/fixtures/diff/another.txt +38 -0
- data/test/fixtures/diff/readme.txt +36 -0
- data/test/fixtures/mergedrepo/conflicts-one.txt +5 -0
- data/test/fixtures/mergedrepo/conflicts-two.txt +5 -0
- data/test/fixtures/mergedrepo/one.txt +10 -0
- data/test/fixtures/mergedrepo/two.txt +12 -0
- data/test/fixtures/status/current_file +1 -0
- data/test/fixtures/status/ignored_file +1 -0
- data/test/fixtures/status/modified_file +2 -0
- data/test/fixtures/status/new_file +1 -0
- data/test/fixtures/status/staged_changes +2 -0
- data/test/fixtures/status/staged_changes_modified_file +3 -0
- data/test/fixtures/status/staged_delete_modified_file +1 -0
- data/test/fixtures/status/staged_new_file +1 -0
- data/test/fixtures/status/staged_new_file_modified_file +2 -0
- data/test/fixtures/status/subdir.txt +2 -0
- data/test/fixtures/status/subdir/current_file +1 -0
- data/test/fixtures/status/subdir/modified_file +2 -0
- data/test/fixtures/status/subdir/new_file +1 -0
- data/test/fixtures/status//350/277/231 +1 -0
- data/test/fixtures/testrepo.git/config +5 -0
- data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
- data/test/fixtures/text_file.md +464 -0
- data/test/fixtures/unsymlinked.git/HEAD +1 -0
- data/test/fixtures/unsymlinked.git/config +6 -0
- data/test/fixtures/unsymlinked.git/description +1 -0
- data/test/fixtures/unsymlinked.git/info/exclude +2 -0
- data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
- data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
- data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
- data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
- data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
- data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
- data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
- data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
- data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
- data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +2 -0
- data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
- data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
- data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
- data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
- data/test/fixtures/unsymlinked.git/refs/heads/exe-file +1 -0
- data/test/fixtures/unsymlinked.git/refs/heads/master +1 -0
- data/test/fixtures/unsymlinked.git/refs/heads/reg-file +1 -0
- data/test/index_test.rb +120 -0
- data/test/reference_test.rb +38 -3
- data/test/remote_test.rb +224 -3
- data/test/repo_reset_test.rb +2 -0
- data/test/repo_test.rb +147 -10
- data/test/test_helper.rb +5 -2
- data/vendor/libgit2/include/git2/attr.h +3 -3
- data/vendor/libgit2/include/git2/blob.h +11 -17
- data/vendor/libgit2/include/git2/branch.h +3 -2
- data/vendor/libgit2/include/git2/checkout.h +7 -0
- data/vendor/libgit2/include/git2/clone.h +3 -0
- data/vendor/libgit2/include/git2/commit.h +61 -66
- data/vendor/libgit2/include/git2/common.h +73 -42
- data/vendor/libgit2/include/git2/config.h +57 -71
- data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
- data/vendor/libgit2/include/git2/diff.h +179 -30
- data/vendor/libgit2/include/git2/errors.h +3 -3
- data/vendor/libgit2/include/git2/index.h +225 -146
- data/vendor/libgit2/include/git2/indexer.h +2 -22
- data/vendor/libgit2/include/git2/inttypes.h +9 -9
- data/vendor/libgit2/include/git2/merge.h +123 -5
- data/vendor/libgit2/include/git2/odb.h +59 -38
- data/vendor/libgit2/include/git2/odb_backend.h +45 -104
- data/vendor/libgit2/include/git2/oid.h +30 -19
- data/vendor/libgit2/include/git2/pack.h +21 -3
- data/vendor/libgit2/include/git2/refdb.h +0 -35
- data/vendor/libgit2/include/git2/refs.h +93 -31
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +60 -20
- data/vendor/libgit2/include/git2/repository.h +48 -70
- data/vendor/libgit2/include/git2/reset.h +3 -3
- data/vendor/libgit2/include/git2/revparse.h +22 -0
- data/vendor/libgit2/include/git2/stash.h +1 -1
- data/vendor/libgit2/include/git2/status.h +131 -56
- data/vendor/libgit2/include/git2/strarray.h +2 -2
- data/vendor/libgit2/include/git2/submodule.h +16 -16
- data/vendor/libgit2/include/git2/sys/commit.h +46 -0
- data/vendor/libgit2/include/git2/sys/config.h +71 -0
- data/vendor/libgit2/include/git2/sys/index.h +179 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +86 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +158 -0
- data/vendor/libgit2/include/git2/sys/refs.h +38 -0
- data/vendor/libgit2/include/git2/sys/repository.h +106 -0
- data/vendor/libgit2/include/git2/tag.h +44 -18
- data/vendor/libgit2/include/git2/trace.h +1 -2
- data/vendor/libgit2/include/git2/transport.h +74 -0
- data/vendor/libgit2/include/git2/tree.h +12 -22
- data/vendor/libgit2/include/git2/types.h +33 -0
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/array.h +66 -0
- data/vendor/libgit2/src/attr.c +26 -13
- data/vendor/libgit2/src/attr_file.c +3 -2
- data/vendor/libgit2/src/attr_file.h +3 -3
- data/vendor/libgit2/src/attrcache.h +4 -4
- data/vendor/libgit2/src/blob.c +13 -9
- data/vendor/libgit2/src/blob.h +2 -2
- data/vendor/libgit2/src/branch.c +67 -49
- data/vendor/libgit2/src/cache.c +224 -54
- data/vendor/libgit2/src/cache.h +33 -20
- data/vendor/libgit2/src/checkout.c +145 -85
- data/vendor/libgit2/src/clone.c +62 -50
- data/vendor/libgit2/src/commit.c +74 -40
- data/vendor/libgit2/src/commit.h +2 -3
- data/vendor/libgit2/src/commit_list.c +14 -8
- data/vendor/libgit2/src/config.c +119 -36
- data/vendor/libgit2/src/config.h +3 -0
- data/vendor/libgit2/src/config_cache.c +24 -7
- data/vendor/libgit2/src/config_file.c +9 -6
- data/vendor/libgit2/src/crlf.c +4 -2
- data/vendor/libgit2/src/date.c +3 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/diff.c +681 -303
- data/vendor/libgit2/src/diff.h +34 -2
- data/vendor/libgit2/src/diff_driver.c +405 -0
- data/vendor/libgit2/src/diff_driver.h +49 -0
- data/vendor/libgit2/src/diff_file.c +447 -0
- data/vendor/libgit2/src/diff_file.h +58 -0
- data/vendor/libgit2/src/diff_patch.c +995 -0
- data/vendor/libgit2/src/diff_patch.h +46 -0
- data/vendor/libgit2/src/diff_print.c +430 -0
- data/vendor/libgit2/src/diff_tform.c +464 -203
- data/vendor/libgit2/src/diff_xdiff.c +166 -0
- data/vendor/libgit2/src/diff_xdiff.h +28 -0
- data/vendor/libgit2/src/fetch.c +11 -4
- data/vendor/libgit2/src/fileops.c +85 -61
- data/vendor/libgit2/src/fileops.h +4 -0
- data/vendor/libgit2/src/global.c +10 -2
- data/vendor/libgit2/src/global.h +0 -8
- data/vendor/libgit2/src/hash/hash_generic.h +3 -3
- data/vendor/libgit2/src/hash/hash_win32.h +4 -4
- data/vendor/libgit2/src/hashsig.c +0 -1
- data/vendor/libgit2/src/ignore.c +68 -28
- data/vendor/libgit2/src/ignore.h +10 -1
- data/vendor/libgit2/src/index.c +666 -84
- data/vendor/libgit2/src/index.h +6 -0
- data/vendor/libgit2/src/indexer.c +10 -28
- data/vendor/libgit2/src/iterator.c +427 -283
- data/vendor/libgit2/src/iterator.h +58 -4
- data/vendor/libgit2/src/merge.c +1892 -32
- data/vendor/libgit2/src/merge.h +132 -5
- data/vendor/libgit2/src/merge_file.c +174 -0
- data/vendor/libgit2/src/merge_file.h +71 -0
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/notes.c +45 -48
- data/vendor/libgit2/src/object.c +89 -127
- data/vendor/libgit2/src/object.h +0 -1
- data/vendor/libgit2/src/object_api.c +129 -0
- data/vendor/libgit2/src/odb.c +156 -59
- data/vendor/libgit2/src/odb.h +5 -2
- data/vendor/libgit2/src/odb_loose.c +31 -17
- data/vendor/libgit2/src/odb_pack.c +39 -43
- data/vendor/libgit2/src/oid.c +62 -27
- data/vendor/libgit2/src/oid.h +33 -0
- data/vendor/libgit2/src/oidmap.h +4 -6
- data/vendor/libgit2/src/pack-objects.c +54 -22
- data/vendor/libgit2/src/pack.c +98 -56
- data/vendor/libgit2/src/pack.h +3 -1
- data/vendor/libgit2/src/pathspec.c +26 -1
- data/vendor/libgit2/src/pathspec.h +14 -0
- data/vendor/libgit2/src/pool.c +5 -0
- data/vendor/libgit2/src/posix.c +2 -2
- data/vendor/libgit2/src/posix.h +3 -0
- data/vendor/libgit2/src/push.c +13 -10
- data/vendor/libgit2/src/refdb.c +82 -62
- data/vendor/libgit2/src/refdb.h +16 -16
- data/vendor/libgit2/src/refdb_fs.c +386 -133
- data/vendor/libgit2/src/reflog.c +3 -1
- data/vendor/libgit2/src/refs.c +247 -221
- data/vendor/libgit2/src/refs.h +2 -1
- data/vendor/libgit2/src/refspec.c +18 -1
- data/vendor/libgit2/src/refspec.h +3 -1
- data/vendor/libgit2/src/remote.c +434 -253
- data/vendor/libgit2/src/remote.h +5 -3
- data/vendor/libgit2/src/repository.c +197 -111
- data/vendor/libgit2/src/repository.h +26 -5
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revparse.c +84 -79
- data/vendor/libgit2/src/revwalk.c +1 -1
- data/vendor/libgit2/src/signature.c +22 -10
- data/vendor/libgit2/src/stash.c +5 -2
- data/vendor/libgit2/src/status.c +311 -107
- data/vendor/libgit2/src/status.h +23 -0
- data/vendor/libgit2/src/submodule.c +21 -13
- data/vendor/libgit2/src/tag.c +42 -31
- data/vendor/libgit2/src/tag.h +2 -3
- data/vendor/libgit2/src/thread-utils.h +105 -3
- data/vendor/libgit2/src/trace.c +1 -2
- data/vendor/libgit2/src/trace.h +3 -3
- data/vendor/libgit2/src/transport.c +18 -6
- data/vendor/libgit2/src/transports/cred.c +103 -1
- data/vendor/libgit2/src/transports/local.c +19 -9
- data/vendor/libgit2/src/transports/smart_protocol.c +32 -12
- data/vendor/libgit2/src/transports/ssh.c +519 -0
- data/vendor/libgit2/src/transports/winhttp.c +3 -1
- data/vendor/libgit2/src/tree.c +26 -28
- data/vendor/libgit2/src/tree.h +3 -3
- data/vendor/libgit2/src/unix/posix.h +2 -0
- data/vendor/libgit2/src/util.c +43 -6
- data/vendor/libgit2/src/util.h +40 -12
- data/vendor/libgit2/src/vector.c +3 -5
- data/vendor/libgit2/src/vector.h +9 -0
- data/vendor/libgit2/src/win32/dir.c +1 -1
- data/vendor/libgit2/src/win32/error.c +2 -0
- data/vendor/libgit2/src/win32/findfile.c +3 -6
- data/vendor/libgit2/src/win32/posix_w32.c +85 -59
- data/vendor/libgit2/src/win32/pthread.c +16 -8
- data/vendor/libgit2/src/win32/pthread.h +7 -4
- metadata +407 -306
- data/test/coverage/HEAD.json +0 -1
- data/vendor/libgit2/include/git2/refdb_backend.h +0 -109
- data/vendor/libgit2/src/diff_output.c +0 -1819
- data/vendor/libgit2/src/diff_output.h +0 -93
@@ -0,0 +1,158 @@
|
|
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_sys_git_refdb_backend_h__
|
8
|
+
#define INCLUDE_sys_git_refdb_backend_h__
|
9
|
+
|
10
|
+
#include "git2/common.h"
|
11
|
+
#include "git2/types.h"
|
12
|
+
#include "git2/oid.h"
|
13
|
+
|
14
|
+
/**
|
15
|
+
* @file git2/refdb_backend.h
|
16
|
+
* @brief Git custom refs backend functions
|
17
|
+
* @defgroup git_refdb_backend Git custom refs backend API
|
18
|
+
* @ingroup Git
|
19
|
+
* @{
|
20
|
+
*/
|
21
|
+
GIT_BEGIN_DECL
|
22
|
+
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Every backend's iterator must have a pointer to itself as the first
|
26
|
+
* element, so the API can talk to it. You'd define your iterator as
|
27
|
+
*
|
28
|
+
* struct my_iterator {
|
29
|
+
* git_reference_iterator parent;
|
30
|
+
* ...
|
31
|
+
* }
|
32
|
+
*
|
33
|
+
* and assign `iter->parent.backend` to your `git_refdb_backend`.
|
34
|
+
*/
|
35
|
+
struct git_reference_iterator {
|
36
|
+
git_refdb *db;
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Return the current reference and advance the iterator.
|
40
|
+
*/
|
41
|
+
int (*next)(
|
42
|
+
git_reference **ref,
|
43
|
+
git_reference_iterator *iter);
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Return the name of the current reference and advance the iterator
|
47
|
+
*/
|
48
|
+
int (*next_name)(
|
49
|
+
const char **ref_name,
|
50
|
+
git_reference_iterator *iter);
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Free the iterator
|
54
|
+
*/
|
55
|
+
void (*free)(
|
56
|
+
git_reference_iterator *iter);
|
57
|
+
};
|
58
|
+
|
59
|
+
/** An instance for a custom backend */
|
60
|
+
struct git_refdb_backend {
|
61
|
+
unsigned int version;
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Queries the refdb backend to determine if the given ref_name
|
65
|
+
* exists. A refdb implementation must provide this function.
|
66
|
+
*/
|
67
|
+
int (*exists)(
|
68
|
+
int *exists,
|
69
|
+
git_refdb_backend *backend,
|
70
|
+
const char *ref_name);
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Queries the refdb backend for a given reference. A refdb
|
74
|
+
* implementation must provide this function.
|
75
|
+
*/
|
76
|
+
int (*lookup)(
|
77
|
+
git_reference **out,
|
78
|
+
git_refdb_backend *backend,
|
79
|
+
const char *ref_name);
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Allocate an iterator object for the backend.
|
83
|
+
*
|
84
|
+
* A refdb implementation must provide this function.
|
85
|
+
*/
|
86
|
+
int (*iterator)(
|
87
|
+
git_reference_iterator **iter,
|
88
|
+
struct git_refdb_backend *backend,
|
89
|
+
const char *glob);
|
90
|
+
|
91
|
+
/*
|
92
|
+
* Writes the given reference to the refdb. A refdb implementation
|
93
|
+
* must provide this function.
|
94
|
+
*/
|
95
|
+
int (*write)(git_refdb_backend *backend,
|
96
|
+
const git_reference *ref, int force);
|
97
|
+
|
98
|
+
int (*rename)(
|
99
|
+
git_reference **out, git_refdb_backend *backend,
|
100
|
+
const char *old_name, const char *new_name, int force);
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Deletes the given reference from the refdb. A refdb implementation
|
104
|
+
* must provide this function.
|
105
|
+
*/
|
106
|
+
int (*delete)(git_refdb_backend *backend, const char *ref_name);
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Suggests that the given refdb compress or optimize its references.
|
110
|
+
* This mechanism is implementation specific. (For on-disk reference
|
111
|
+
* databases, this may pack all loose references.) A refdb
|
112
|
+
* implementation may provide this function; if it is not provided,
|
113
|
+
* nothing will be done.
|
114
|
+
*/
|
115
|
+
int (*compress)(git_refdb_backend *backend);
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Frees any resources held by the refdb. A refdb implementation may
|
119
|
+
* provide this function; if it is not provided, nothing will be done.
|
120
|
+
*/
|
121
|
+
void (*free)(git_refdb_backend *backend);
|
122
|
+
};
|
123
|
+
|
124
|
+
#define GIT_ODB_BACKEND_VERSION 1
|
125
|
+
#define GIT_ODB_BACKEND_INIT {GIT_ODB_BACKEND_VERSION}
|
126
|
+
|
127
|
+
/**
|
128
|
+
* Constructors for default filesystem-based refdb backend
|
129
|
+
*
|
130
|
+
* Under normal usage, this is called for you when the repository is
|
131
|
+
* opened / created, but you can use this to explicitly construct a
|
132
|
+
* filesystem refdb backend for a repository.
|
133
|
+
*
|
134
|
+
* @param backend_out Output pointer to the git_refdb_backend object
|
135
|
+
* @param repo Git repository to access
|
136
|
+
* @return 0 on success, <0 error code on failure
|
137
|
+
*/
|
138
|
+
GIT_EXTERN(int) git_refdb_backend_fs(
|
139
|
+
git_refdb_backend **backend_out,
|
140
|
+
git_repository *repo);
|
141
|
+
|
142
|
+
/**
|
143
|
+
* Sets the custom backend to an existing reference DB
|
144
|
+
*
|
145
|
+
* The `git_refdb` will take ownership of the `git_refdb_backend` so you
|
146
|
+
* should NOT free it after calling this function.
|
147
|
+
*
|
148
|
+
* @param refdb database to add the backend to
|
149
|
+
* @param backend pointer to a git_refdb_backend instance
|
150
|
+
* @return 0 on success; error code otherwise
|
151
|
+
*/
|
152
|
+
GIT_EXTERN(int) git_refdb_set_backend(
|
153
|
+
git_refdb *refdb,
|
154
|
+
git_refdb_backend *backend);
|
155
|
+
|
156
|
+
GIT_END_DECL
|
157
|
+
|
158
|
+
#endif
|
@@ -0,0 +1,38 @@
|
|
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_sys_git_refdb_h__
|
8
|
+
#define INCLUDE_sys_git_refdb_h__
|
9
|
+
|
10
|
+
#include "git2/common.h"
|
11
|
+
#include "git2/types.h"
|
12
|
+
#include "git2/oid.h"
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Create a new direct reference from an OID.
|
16
|
+
*
|
17
|
+
* @param name the reference name
|
18
|
+
* @param oid the object id for a direct reference
|
19
|
+
* @param symbolic the target for a symbolic reference
|
20
|
+
* @return the created git_reference or NULL on error
|
21
|
+
*/
|
22
|
+
GIT_EXTERN(git_reference *) git_reference__alloc(
|
23
|
+
const char *name,
|
24
|
+
const git_oid *oid,
|
25
|
+
const git_oid *peel);
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Create a new symbolic reference.
|
29
|
+
*
|
30
|
+
* @param name the reference name
|
31
|
+
* @param symbolic the target for a symbolic reference
|
32
|
+
* @return the created git_reference or NULL on error
|
33
|
+
*/
|
34
|
+
GIT_EXTERN(git_reference *) git_reference__alloc_symbolic(
|
35
|
+
const char *name,
|
36
|
+
const char *target);
|
37
|
+
|
38
|
+
#endif
|
@@ -0,0 +1,106 @@
|
|
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_sys_git_repository_h__
|
8
|
+
#define INCLUDE_sys_git_repository_h__
|
9
|
+
|
10
|
+
/**
|
11
|
+
* @file git2/sys/repository.h
|
12
|
+
* @brief Git repository custom implementation routines
|
13
|
+
* @defgroup git_backend Git custom backend APIs
|
14
|
+
* @ingroup Git
|
15
|
+
* @{
|
16
|
+
*/
|
17
|
+
GIT_BEGIN_DECL
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Create a new repository with neither backends nor config object
|
21
|
+
*
|
22
|
+
* Note that this is only useful if you wish to associate the repository
|
23
|
+
* with a non-filesystem-backed object database and config store.
|
24
|
+
*
|
25
|
+
* @param out The blank repository
|
26
|
+
* @return 0 on success, or an error code
|
27
|
+
*/
|
28
|
+
GIT_EXTERN(int) git_repository_new(git_repository **out);
|
29
|
+
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Reset all the internal state in a repository.
|
33
|
+
*
|
34
|
+
* This will free all the mapped memory and internal objects
|
35
|
+
* of the repository and leave it in a "blank" state.
|
36
|
+
*
|
37
|
+
* There's no need to call this function directly unless you're
|
38
|
+
* trying to aggressively cleanup the repo before its
|
39
|
+
* deallocation. `git_repository_free` already performs this operation
|
40
|
+
* before deallocation the repo.
|
41
|
+
*/
|
42
|
+
GIT_EXTERN(void) git_repository__cleanup(git_repository *repo);
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Set the configuration file for this repository
|
46
|
+
*
|
47
|
+
* This configuration file will be used for all configuration
|
48
|
+
* queries involving this repository.
|
49
|
+
*
|
50
|
+
* The repository will keep a reference to the config file;
|
51
|
+
* the user must still free the config after setting it
|
52
|
+
* to the repository, or it will leak.
|
53
|
+
*
|
54
|
+
* @param repo A repository object
|
55
|
+
* @param config A Config object
|
56
|
+
*/
|
57
|
+
GIT_EXTERN(void) git_repository_set_config(git_repository *repo, git_config *config);
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Set the Object Database for this repository
|
61
|
+
*
|
62
|
+
* The ODB will be used for all object-related operations
|
63
|
+
* involving this repository.
|
64
|
+
*
|
65
|
+
* The repository will keep a reference to the ODB; the user
|
66
|
+
* must still free the ODB object after setting it to the
|
67
|
+
* repository, or it will leak.
|
68
|
+
*
|
69
|
+
* @param repo A repository object
|
70
|
+
* @param odb An ODB object
|
71
|
+
*/
|
72
|
+
GIT_EXTERN(void) git_repository_set_odb(git_repository *repo, git_odb *odb);
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Set the Reference Database Backend for this repository
|
76
|
+
*
|
77
|
+
* The refdb will be used for all reference related operations
|
78
|
+
* involving this repository.
|
79
|
+
*
|
80
|
+
* The repository will keep a reference to the refdb; the user
|
81
|
+
* must still free the refdb object after setting it to the
|
82
|
+
* repository, or it will leak.
|
83
|
+
*
|
84
|
+
* @param repo A repository object
|
85
|
+
* @param refdb An refdb object
|
86
|
+
*/
|
87
|
+
GIT_EXTERN(void) git_repository_set_refdb(git_repository *repo, git_refdb *refdb);
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Set the index file for this repository
|
91
|
+
*
|
92
|
+
* This index will be used for all index-related operations
|
93
|
+
* involving this repository.
|
94
|
+
*
|
95
|
+
* The repository will keep a reference to the index file;
|
96
|
+
* the user must still free the index after setting it
|
97
|
+
* to the repository, or it will leak.
|
98
|
+
*
|
99
|
+
* @param repo A repository object
|
100
|
+
* @param index An index object
|
101
|
+
*/
|
102
|
+
GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
|
103
|
+
|
104
|
+
/** @} */
|
105
|
+
GIT_END_DECL
|
106
|
+
#endif
|
@@ -30,12 +30,8 @@ GIT_BEGIN_DECL
|
|
30
30
|
* @param id identity of the tag to locate.
|
31
31
|
* @return 0 or an error code
|
32
32
|
*/
|
33
|
-
|
34
|
-
git_tag **out, git_repository *repo, const git_oid *id)
|
35
|
-
{
|
36
|
-
return git_object_lookup(
|
37
|
-
(git_object **)out, repo, id, (git_otype)GIT_OBJ_TAG);
|
38
|
-
}
|
33
|
+
GIT_EXTERN(int) git_tag_lookup(
|
34
|
+
git_tag **out, git_repository *repo, const git_oid *id);
|
39
35
|
|
40
36
|
/**
|
41
37
|
* Lookup a tag object from the repository,
|
@@ -49,12 +45,8 @@ GIT_INLINE(int) git_tag_lookup(
|
|
49
45
|
* @param len the length of the short identifier
|
50
46
|
* @return 0 or an error code
|
51
47
|
*/
|
52
|
-
|
53
|
-
git_tag **out, git_repository *repo, const git_oid *id, size_t len)
|
54
|
-
{
|
55
|
-
return git_object_lookup_prefix(
|
56
|
-
(git_object **)out, repo, id, len, (git_otype)GIT_OBJ_TAG);
|
57
|
-
}
|
48
|
+
GIT_EXTERN(int) git_tag_lookup_prefix(
|
49
|
+
git_tag **out, git_repository *repo, const git_oid *id, size_t len);
|
58
50
|
|
59
51
|
/**
|
60
52
|
* Close an open tag
|
@@ -66,12 +58,7 @@ GIT_INLINE(int) git_tag_lookup_prefix(
|
|
66
58
|
*
|
67
59
|
* @param tag the tag to close
|
68
60
|
*/
|
69
|
-
|
70
|
-
GIT_INLINE(void) git_tag_free(git_tag *tag)
|
71
|
-
{
|
72
|
-
git_object_free((git_object *)tag);
|
73
|
-
}
|
74
|
-
|
61
|
+
GIT_EXTERN(void) git_tag_free(git_tag *tag);
|
75
62
|
|
76
63
|
/**
|
77
64
|
* Get the id of a tag.
|
@@ -81,6 +68,14 @@ GIT_INLINE(void) git_tag_free(git_tag *tag)
|
|
81
68
|
*/
|
82
69
|
GIT_EXTERN(const git_oid *) git_tag_id(const git_tag *tag);
|
83
70
|
|
71
|
+
/**
|
72
|
+
* Get the repository that contains the tag.
|
73
|
+
*
|
74
|
+
* @param tag A previously loaded tag.
|
75
|
+
* @return Repository that contains this tag.
|
76
|
+
*/
|
77
|
+
GIT_EXTERN(git_repository *) git_tag_owner(const git_tag *tag);
|
78
|
+
|
84
79
|
/**
|
85
80
|
* Get the tagged object of a tag
|
86
81
|
*
|
@@ -182,6 +177,37 @@ GIT_EXTERN(int) git_tag_create(
|
|
182
177
|
const char *message,
|
183
178
|
int force);
|
184
179
|
|
180
|
+
/**
|
181
|
+
* Create a new tag in the object database pointing to a git_object
|
182
|
+
*
|
183
|
+
* The message will not be cleaned up. This can be achieved
|
184
|
+
* through `git_message_prettify()`.
|
185
|
+
*
|
186
|
+
* @param oid Pointer where to store the OID of the
|
187
|
+
* newly created tag
|
188
|
+
*
|
189
|
+
* @param repo Repository where to store the tag
|
190
|
+
*
|
191
|
+
* @param tag_name Name for the tag
|
192
|
+
*
|
193
|
+
* @param target Object to which this tag points. This object
|
194
|
+
* must belong to the given `repo`.
|
195
|
+
*
|
196
|
+
* @param tagger Signature of the tagger for this tag, and
|
197
|
+
* of the tagging time
|
198
|
+
*
|
199
|
+
* @param message Full message for this tag
|
200
|
+
*
|
201
|
+
* @return 0 on success or an error code
|
202
|
+
*/
|
203
|
+
GIT_EXTERN(int) git_tag_annotation_create(
|
204
|
+
git_oid *oid,
|
205
|
+
git_repository *repo,
|
206
|
+
const char *tag_name,
|
207
|
+
const git_object *target,
|
208
|
+
const git_signature *tagger,
|
209
|
+
const char *message);
|
210
|
+
|
185
211
|
/**
|
186
212
|
* Create a new tag in the repository from a buffer
|
187
213
|
*
|
@@ -32,7 +32,7 @@ typedef enum {
|
|
32
32
|
|
33
33
|
/** Errors that do not impact the program's execution */
|
34
34
|
GIT_TRACE_ERROR = 2,
|
35
|
-
|
35
|
+
|
36
36
|
/** Warnings that suggest abnormal data */
|
37
37
|
GIT_TRACE_WARN = 3,
|
38
38
|
|
@@ -65,4 +65,3 @@ GIT_EXTERN(int) git_trace_set(git_trace_level_t level, git_trace_callback cb);
|
|
65
65
|
/** @} */
|
66
66
|
GIT_END_DECL
|
67
67
|
#endif
|
68
|
-
|
@@ -11,6 +11,10 @@
|
|
11
11
|
#include "net.h"
|
12
12
|
#include "types.h"
|
13
13
|
|
14
|
+
#ifdef GIT_SSH
|
15
|
+
#include <libssh2.h>
|
16
|
+
#endif
|
17
|
+
|
14
18
|
/**
|
15
19
|
* @file git2/transport.h
|
16
20
|
* @brief Git transport interfaces and functions
|
@@ -27,6 +31,8 @@ GIT_BEGIN_DECL
|
|
27
31
|
typedef enum {
|
28
32
|
/* git_cred_userpass_plaintext */
|
29
33
|
GIT_CREDTYPE_USERPASS_PLAINTEXT = 1,
|
34
|
+
GIT_CREDTYPE_SSH_KEYFILE_PASSPHRASE = 2,
|
35
|
+
GIT_CREDTYPE_SSH_PUBLICKEY = 3,
|
30
36
|
} git_credtype_t;
|
31
37
|
|
32
38
|
/* The base structure for all credential types */
|
@@ -43,6 +49,27 @@ typedef struct git_cred_userpass_plaintext {
|
|
43
49
|
char *password;
|
44
50
|
} git_cred_userpass_plaintext;
|
45
51
|
|
52
|
+
#ifdef GIT_SSH
|
53
|
+
typedef LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*git_cred_sign_callback));
|
54
|
+
|
55
|
+
/* A ssh key file and passphrase */
|
56
|
+
typedef struct git_cred_ssh_keyfile_passphrase {
|
57
|
+
git_cred parent;
|
58
|
+
char *publickey;
|
59
|
+
char *privatekey;
|
60
|
+
char *passphrase;
|
61
|
+
} git_cred_ssh_keyfile_passphrase;
|
62
|
+
|
63
|
+
/* A ssh public key and authentication callback */
|
64
|
+
typedef struct git_cred_ssh_publickey {
|
65
|
+
git_cred parent;
|
66
|
+
char *publickey;
|
67
|
+
size_t publickey_len;
|
68
|
+
void *sign_callback;
|
69
|
+
void *sign_data;
|
70
|
+
} git_cred_ssh_publickey;
|
71
|
+
#endif
|
72
|
+
|
46
73
|
/**
|
47
74
|
* Creates a new plain-text username and password credential object.
|
48
75
|
* The supplied credential parameter will be internally duplicated.
|
@@ -57,6 +84,42 @@ GIT_EXTERN(int) git_cred_userpass_plaintext_new(
|
|
57
84
|
const char *username,
|
58
85
|
const char *password);
|
59
86
|
|
87
|
+
#ifdef GIT_SSH
|
88
|
+
/**
|
89
|
+
* Creates a new ssh key file and passphrase credential object.
|
90
|
+
* The supplied credential parameter will be internally duplicated.
|
91
|
+
*
|
92
|
+
* @param out The newly created credential object.
|
93
|
+
* @param publickey The path to the public key of the credential.
|
94
|
+
* @param privatekey The path to the private key of the credential.
|
95
|
+
* @param passphrase The passphrase of the credential.
|
96
|
+
* @return 0 for success or an error code for failure
|
97
|
+
*/
|
98
|
+
GIT_EXTERN(int) git_cred_ssh_keyfile_passphrase_new(
|
99
|
+
git_cred **out,
|
100
|
+
const char *publickey,
|
101
|
+
const char *privatekey,
|
102
|
+
const char *passphrase);
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Creates a new ssh public key credential object.
|
106
|
+
* The supplied credential parameter will be internally duplicated.
|
107
|
+
*
|
108
|
+
* @param out The newly created credential object.
|
109
|
+
* @param publickey The bytes of the public key.
|
110
|
+
* @param publickey_len The length of the public key in bytes.
|
111
|
+
* @param sign_callback The callback method for authenticating.
|
112
|
+
* @param sign_data The abstract data sent to the sign_callback method.
|
113
|
+
* @return 0 for success or an error code for failure
|
114
|
+
*/
|
115
|
+
GIT_EXTERN(int) git_cred_ssh_publickey_new(
|
116
|
+
git_cred **out,
|
117
|
+
const char *publickey,
|
118
|
+
size_t publickey_len,
|
119
|
+
git_cred_sign_callback,
|
120
|
+
void *sign_data);
|
121
|
+
#endif
|
122
|
+
|
60
123
|
/**
|
61
124
|
* Signature of a function which acquires a credential object.
|
62
125
|
*
|
@@ -319,6 +382,17 @@ GIT_EXTERN(int) git_smart_subtransport_git(
|
|
319
382
|
git_smart_subtransport **out,
|
320
383
|
git_transport* owner);
|
321
384
|
|
385
|
+
/**
|
386
|
+
* Create an instance of the ssh subtransport.
|
387
|
+
*
|
388
|
+
* @param out The newly created subtransport
|
389
|
+
* @param owner The smart transport to own this subtransport
|
390
|
+
* @return 0 or an error code
|
391
|
+
*/
|
392
|
+
GIT_EXTERN(int) git_smart_subtransport_ssh(
|
393
|
+
git_smart_subtransport **out,
|
394
|
+
git_transport* owner);
|
395
|
+
|
322
396
|
/*
|
323
397
|
*** End interface for subtransports for the smart transport ***
|
324
398
|
*/
|