rugged 0.17.0.b6 → 0.17.0.b7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/Rakefile +3 -1
- data/ext/rugged/rugged.c +30 -0
- data/ext/rugged/rugged.h +9 -0
- data/ext/rugged/rugged_branch.c +306 -0
- data/ext/rugged/rugged_config.c +16 -13
- data/ext/rugged/rugged_index.c +25 -0
- data/ext/rugged/rugged_object.c +6 -2
- data/ext/rugged/rugged_reference.c +11 -18
- data/ext/rugged/rugged_revwalk.c +1 -1
- data/lib/rugged.rb +1 -0
- data/lib/rugged/branch.rb +28 -0
- data/lib/rugged/commit.rb +5 -5
- data/lib/rugged/repository.rb +32 -7
- data/lib/rugged/tag.rb +5 -1
- data/lib/rugged/version.rb +1 -1
- data/test/branch_test.rb +227 -0
- data/test/config_test.rb +1 -1
- data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
- data/test/index_test.rb +31 -0
- data/test/index_test.rb~ +218 -0
- data/test/lib_test.rb +22 -0
- data/test/reference_test.rb +5 -3
- data/vendor/libgit2/Makefile.embed +1 -1
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/include/git2/branch.h +17 -13
- data/vendor/libgit2/include/git2/checkout.h +83 -22
- data/vendor/libgit2/include/git2/clone.h +6 -3
- data/vendor/libgit2/include/git2/common.h +1 -8
- data/vendor/libgit2/include/git2/config.h +185 -26
- data/vendor/libgit2/include/git2/diff.h +229 -17
- data/vendor/libgit2/include/git2/errors.h +39 -1
- data/vendor/libgit2/include/git2/ignore.h +6 -3
- data/vendor/libgit2/include/git2/indexer.h +1 -0
- data/vendor/libgit2/include/git2/merge.h +1 -1
- data/vendor/libgit2/include/git2/object.h +7 -4
- data/vendor/libgit2/include/git2/odb.h +4 -2
- data/vendor/libgit2/include/git2/odb_backend.h +6 -0
- data/vendor/libgit2/include/git2/oid.h +2 -0
- data/vendor/libgit2/include/git2/pack.h +89 -0
- data/vendor/libgit2/include/git2/refs.h +88 -0
- data/vendor/libgit2/include/git2/refspec.h +0 -8
- data/vendor/libgit2/include/git2/remote.h +34 -1
- data/vendor/libgit2/include/git2/repository.h +238 -6
- data/vendor/libgit2/include/git2/reset.h +4 -1
- data/vendor/libgit2/include/git2/revwalk.h +1 -1
- data/vendor/libgit2/include/git2/status.h +19 -14
- data/vendor/libgit2/include/git2/strarray.h +54 -0
- data/vendor/libgit2/include/git2/submodule.h +451 -45
- data/vendor/libgit2/include/git2/tag.h +16 -0
- data/vendor/libgit2/include/git2/tree.h +2 -2
- data/vendor/libgit2/include/git2/types.h +4 -0
- data/vendor/libgit2/src/amiga/map.c +4 -7
- data/vendor/libgit2/src/attr.c +21 -13
- data/vendor/libgit2/src/attr.h +3 -1
- data/vendor/libgit2/src/attr_file.c +14 -14
- data/vendor/libgit2/src/attr_file.h +6 -5
- data/vendor/libgit2/src/blob.c +22 -12
- data/vendor/libgit2/src/branch.c +62 -66
- data/vendor/libgit2/src/buffer.c +63 -14
- data/vendor/libgit2/src/buffer.h +4 -0
- data/vendor/libgit2/src/cache.c +5 -4
- data/vendor/libgit2/src/checkout.c +381 -159
- data/vendor/libgit2/src/clone.c +221 -94
- data/vendor/libgit2/src/common.h +13 -3
- data/vendor/libgit2/src/compress.c +53 -0
- data/vendor/libgit2/src/compress.h +16 -0
- data/vendor/libgit2/src/config.c +380 -175
- data/vendor/libgit2/src/config.h +2 -5
- data/vendor/libgit2/src/config_file.c +63 -46
- data/vendor/libgit2/src/config_file.h +16 -4
- data/vendor/libgit2/src/crlf.c +4 -3
- data/vendor/libgit2/src/delta.c +491 -0
- data/vendor/libgit2/src/delta.h +112 -0
- data/vendor/libgit2/src/diff.c +310 -67
- data/vendor/libgit2/src/diff.h +10 -1
- data/vendor/libgit2/src/diff_output.c +1030 -337
- data/vendor/libgit2/src/diff_output.h +86 -0
- data/vendor/libgit2/src/errors.c +10 -1
- data/vendor/libgit2/src/fetch.c +108 -24
- data/vendor/libgit2/src/filebuf.c +8 -2
- data/vendor/libgit2/src/fileops.c +342 -177
- data/vendor/libgit2/src/fileops.h +84 -7
- data/vendor/libgit2/src/filter.c +0 -35
- data/vendor/libgit2/src/filter.h +0 -12
- data/vendor/libgit2/src/{compat/fnmatch.c → fnmatch.c} +16 -4
- data/vendor/libgit2/src/{compat/fnmatch.h → fnmatch.h} +4 -3
- data/vendor/libgit2/src/global.c +4 -0
- data/vendor/libgit2/src/ignore.c +122 -23
- data/vendor/libgit2/src/ignore.h +1 -0
- data/vendor/libgit2/src/index.c +56 -10
- data/vendor/libgit2/src/index.h +2 -0
- data/vendor/libgit2/src/indexer.c +8 -9
- data/vendor/libgit2/src/iterator.c +244 -31
- data/vendor/libgit2/src/iterator.h +30 -1
- data/vendor/libgit2/src/message.c +1 -1
- data/vendor/libgit2/src/netops.c +44 -4
- data/vendor/libgit2/src/object.c +80 -69
- data/vendor/libgit2/src/object.h +39 -0
- data/vendor/libgit2/src/odb.c +79 -15
- data/vendor/libgit2/src/odb.h +20 -5
- data/vendor/libgit2/src/odb_pack.c +65 -33
- data/vendor/libgit2/src/oid.c +0 -3
- data/vendor/libgit2/src/pack-objects.c +1315 -0
- data/vendor/libgit2/src/pack-objects.h +87 -0
- data/vendor/libgit2/src/pack.c +36 -12
- data/vendor/libgit2/src/pack.h +1 -0
- data/vendor/libgit2/src/path.c +42 -9
- data/vendor/libgit2/src/path.h +14 -0
- data/vendor/libgit2/src/pkt.c +52 -2
- data/vendor/libgit2/src/pkt.h +10 -0
- data/vendor/libgit2/src/pool.h +11 -0
- data/vendor/libgit2/src/posix.h +8 -0
- data/vendor/libgit2/src/protocol.c +24 -2
- data/vendor/libgit2/src/protocol.h +4 -0
- data/vendor/libgit2/src/reflog.c +1 -1
- data/vendor/libgit2/src/refs.c +292 -124
- data/vendor/libgit2/src/refs.h +4 -2
- data/vendor/libgit2/src/refspec.c +117 -19
- data/vendor/libgit2/src/refspec.h +19 -0
- data/vendor/libgit2/src/remote.c +152 -48
- data/vendor/libgit2/src/remote.h +4 -1
- data/vendor/libgit2/src/repo_template.h +58 -0
- data/vendor/libgit2/src/repository.c +594 -179
- data/vendor/libgit2/src/repository.h +23 -22
- data/vendor/libgit2/src/reset.c +71 -29
- data/vendor/libgit2/src/revparse.c +26 -17
- data/vendor/libgit2/src/revwalk.c +36 -19
- data/vendor/libgit2/src/sha1.h +7 -0
- data/vendor/libgit2/src/{sha1.c → sha1/sha1.c} +0 -0
- data/vendor/libgit2/src/signature.c +12 -10
- data/vendor/libgit2/src/status.c +52 -6
- data/vendor/libgit2/src/submodule.c +1363 -255
- data/vendor/libgit2/src/submodule.h +102 -0
- data/vendor/libgit2/src/tag.c +42 -26
- data/vendor/libgit2/src/thread-utils.h +7 -7
- data/vendor/libgit2/src/transport.h +15 -1
- data/vendor/libgit2/src/transports/git.c +1 -1
- data/vendor/libgit2/src/transports/http.c +197 -36
- data/vendor/libgit2/src/tree.c +3 -3
- data/vendor/libgit2/src/unix/map.c +2 -0
- data/vendor/libgit2/src/unix/posix.h +1 -8
- data/vendor/libgit2/src/util.c +6 -1
- data/vendor/libgit2/src/util.h +7 -0
- data/vendor/libgit2/src/vector.c +16 -0
- data/vendor/libgit2/src/vector.h +1 -0
- data/vendor/libgit2/src/win32/dir.c +8 -21
- data/vendor/libgit2/src/win32/findfile.c +149 -0
- data/vendor/libgit2/src/win32/findfile.h +23 -0
- data/vendor/libgit2/src/win32/posix.h +3 -7
- data/vendor/libgit2/src/win32/posix_w32.c +44 -102
- data/vendor/libgit2/src/win32/pthread.c +68 -0
- data/vendor/libgit2/src/win32/pthread.h +7 -0
- data/vendor/libgit2/src/win32/utf-conv.c +60 -71
- data/vendor/libgit2/src/win32/utf-conv.h +4 -3
- metadata +70 -71
- data/vendor/libgit2/include/git2/windows.h +0 -59
@@ -26,9 +26,11 @@ enum {
|
|
26
26
|
GIT_EAMBIGUOUS = -5,
|
27
27
|
GIT_EBUFS = -6,
|
28
28
|
GIT_EUSER = -7,
|
29
|
+
GIT_EBAREREPO = -8,
|
30
|
+
GIT_EORPHANEDHEAD = -9,
|
29
31
|
|
30
32
|
GIT_PASSTHROUGH = -30,
|
31
|
-
|
33
|
+
GIT_ITEROVER = -31,
|
32
34
|
};
|
33
35
|
|
34
36
|
typedef struct {
|
@@ -54,6 +56,8 @@ typedef enum {
|
|
54
56
|
GITERR_TREE,
|
55
57
|
GITERR_INDEXER,
|
56
58
|
GITERR_SSL,
|
59
|
+
GITERR_SUBMODULE,
|
60
|
+
GITERR_THREAD,
|
57
61
|
} git_error_t;
|
58
62
|
|
59
63
|
/**
|
@@ -69,6 +73,40 @@ GIT_EXTERN(const git_error *) giterr_last(void);
|
|
69
73
|
*/
|
70
74
|
GIT_EXTERN(void) giterr_clear(void);
|
71
75
|
|
76
|
+
/**
|
77
|
+
* Set the error message string for this thread.
|
78
|
+
*
|
79
|
+
* This function is public so that custom ODB backends and the like can
|
80
|
+
* relay an error message through libgit2. Most regular users of libgit2
|
81
|
+
* will never need to call this function -- actually, calling it in most
|
82
|
+
* circumstances (for example, calling from within a callback function)
|
83
|
+
* will just end up having the value overwritten by libgit2 internals.
|
84
|
+
*
|
85
|
+
* This error message is stored in thread-local storage and only applies
|
86
|
+
* to the particular thread that this libgit2 call is made from.
|
87
|
+
*
|
88
|
+
* NOTE: Passing the `error_class` as GITERR_OS has a special behavior: we
|
89
|
+
* attempt to append the system default error message for the last OS error
|
90
|
+
* that occurred and then clear the last error. The specific implementation
|
91
|
+
* of looking up and clearing this last OS error will vary by platform.
|
92
|
+
*
|
93
|
+
* @param error_class One of the `git_error_t` enum above describing the
|
94
|
+
* general subsystem that is responsible for the error.
|
95
|
+
* @param message The formatted error message to keep
|
96
|
+
*/
|
97
|
+
GIT_EXTERN(void) giterr_set_str(int error_class, const char *string);
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Set the error message to a special value for memory allocation failure.
|
101
|
+
*
|
102
|
+
* The normal `giterr_set_str()` function attempts to `strdup()` the string
|
103
|
+
* that is passed in. This is not a good idea when the error in question
|
104
|
+
* is a memory allocation failure. That circumstance has a special setter
|
105
|
+
* function that sets the error string to a known and statically allocated
|
106
|
+
* internal value.
|
107
|
+
*/
|
108
|
+
GIT_EXTERN(void) giterr_set_oom(void);
|
109
|
+
|
72
110
|
/** @} */
|
73
111
|
GIT_END_DECL
|
74
112
|
#endif
|
@@ -54,9 +54,12 @@ GIT_EXTERN(int) git_ignore_clear_internal_rules(
|
|
54
54
|
/**
|
55
55
|
* Test if the ignore rules apply to a given path.
|
56
56
|
*
|
57
|
-
* This function
|
58
|
-
*
|
59
|
-
*
|
57
|
+
* This function checks the ignore rules to see if they would apply to the
|
58
|
+
* given file. This indicates if the file would be ignored regardless of
|
59
|
+
* whether the file is already in the index or commited to the repository.
|
60
|
+
*
|
61
|
+
* One way to think of this is if you were to do "git add ." on the
|
62
|
+
* directory containing the file, would it be added or not?
|
60
63
|
*
|
61
64
|
* @param ignored boolean returning 0 if the file is not ignored, 1 if it is
|
62
65
|
* @param repo a repository object
|
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
|
|
28
28
|
* @param one one of the commits
|
29
29
|
* @param two the other commit
|
30
30
|
*/
|
31
|
-
GIT_EXTERN(int) git_merge_base(git_oid *out, git_repository *repo, git_oid *one, git_oid *two);
|
31
|
+
GIT_EXTERN(int) git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const git_oid *two);
|
32
32
|
|
33
33
|
/**
|
34
34
|
* Find a merge base given a list of commits
|
@@ -168,11 +168,14 @@ GIT_EXTERN(int) git_object_typeisloose(git_otype type);
|
|
168
168
|
GIT_EXTERN(size_t) git_object__size(git_otype type);
|
169
169
|
|
170
170
|
/**
|
171
|
-
* Recursively peel an object until an object of the specified
|
172
|
-
* type is met
|
171
|
+
* Recursively peel an object until an object of the specified type is met.
|
173
172
|
*
|
174
|
-
* The retrieved `peeled` object is owned by the repository
|
175
|
-
*
|
173
|
+
* The retrieved `peeled` object is owned by the repository and should be
|
174
|
+
* closed with the `git_object_free` method.
|
175
|
+
*
|
176
|
+
* If you pass `GIT_OBJ_ANY` as the target type, then the object will be
|
177
|
+
* peeled until the type changes (e.g. a tag will be chased until the
|
178
|
+
* referenced object is no longer a tag).
|
176
179
|
*
|
177
180
|
* @param peeled Pointer to the peeled git_object
|
178
181
|
* @param object The object to be processed
|
@@ -279,8 +279,10 @@ GIT_EXTERN(int) git_odb_hash(git_oid *id, const void *data, size_t len, git_otyp
|
|
279
279
|
/**
|
280
280
|
* Read a file from disk and fill a git_oid with the object id
|
281
281
|
* that the file would have if it were written to the Object
|
282
|
-
* Database as an object of the given type
|
283
|
-
* to git.git's `git hash-object` without
|
282
|
+
* Database as an object of the given type (w/o applying filters).
|
283
|
+
* Similar functionality to git.git's `git hash-object` without
|
284
|
+
* the `-w` flag, however, with the --no-filters flag.
|
285
|
+
* If you need filters, see git_repository_hashfile.
|
284
286
|
*
|
285
287
|
* @param out oid structure the result is written into.
|
286
288
|
* @param path file to read and determine object id for
|
@@ -26,6 +26,10 @@ struct git_odb_stream;
|
|
26
26
|
struct git_odb_backend {
|
27
27
|
git_odb *odb;
|
28
28
|
|
29
|
+
/* read and read_prefix each return to libgit2 a buffer which
|
30
|
+
* will be freed later. The buffer should be allocated using
|
31
|
+
* the function git_odb_backend_malloc to ensure that it can
|
32
|
+
* be safely freed later. */
|
29
33
|
int (* read)(
|
30
34
|
void **, size_t *, git_otype *,
|
31
35
|
struct git_odb_backend *,
|
@@ -102,6 +106,8 @@ GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **backend_out, const char *
|
|
102
106
|
GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **backend_out, const char *objects_dir, int compression_level, int do_fsync);
|
103
107
|
GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **backend_out, const char *index_file);
|
104
108
|
|
109
|
+
GIT_EXTERN(void *) git_odb_backend_malloc(git_odb_backend *backend, size_t len);
|
110
|
+
|
105
111
|
GIT_END_DECL
|
106
112
|
|
107
113
|
#endif
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 2009-2012 the libgit2 contributors
|
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_pack_h__
|
8
|
+
#define INCLUDE_git_pack_h__
|
9
|
+
|
10
|
+
#include "common.h"
|
11
|
+
#include "oid.h"
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @file git2/pack.h
|
15
|
+
* @brief Git pack management routines
|
16
|
+
* @defgroup git_pack Git pack management routines
|
17
|
+
* @ingroup Git
|
18
|
+
* @{
|
19
|
+
*/
|
20
|
+
GIT_BEGIN_DECL
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Initialize a new packbuilder
|
24
|
+
*
|
25
|
+
* @param out The new packbuilder object
|
26
|
+
* @param repo The repository
|
27
|
+
*
|
28
|
+
* @return 0 or an error code
|
29
|
+
*/
|
30
|
+
GIT_EXTERN(int) git_packbuilder_new(git_packbuilder **out, git_repository *repo);
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Set number of threads to spawn
|
34
|
+
*
|
35
|
+
* By default, libgit2 won't spawn any threads at all;
|
36
|
+
* when set to 0, libgit2 will autodetect the number of
|
37
|
+
* CPUs.
|
38
|
+
*
|
39
|
+
* @param pb The packbuilder
|
40
|
+
* @param n Number of threads to spawn
|
41
|
+
*/
|
42
|
+
GIT_EXTERN(void) git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n);
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Insert a single object
|
46
|
+
*
|
47
|
+
* For an optimal pack it's mandatory to insert objects in recency order,
|
48
|
+
* commits followed by trees and blobs.
|
49
|
+
*
|
50
|
+
* @param pb The packbuilder
|
51
|
+
* @param oid The oid of the commit
|
52
|
+
* @param oid The name; might be NULL
|
53
|
+
*
|
54
|
+
* @return 0 or an error code
|
55
|
+
*/
|
56
|
+
GIT_EXTERN(int) git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid, const char *name);
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Insert a root tree object
|
60
|
+
*
|
61
|
+
* This will add the tree as well as all referenced trees and blobs.
|
62
|
+
*
|
63
|
+
* @param pb The packbuilder
|
64
|
+
* @param oid The oid of the root tree
|
65
|
+
*
|
66
|
+
* @return 0 or an error code
|
67
|
+
*/
|
68
|
+
GIT_EXTERN(int) git_packbuilder_insert_tree(git_packbuilder *pb, const git_oid *oid);
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Write the new pack and the corresponding index to path
|
72
|
+
*
|
73
|
+
* @param pb The packbuilder
|
74
|
+
* @param path Directory to store the new pack and index
|
75
|
+
*
|
76
|
+
* @return 0 or an error code
|
77
|
+
*/
|
78
|
+
GIT_EXTERN(int) git_packbuilder_write(git_packbuilder *pb, const char *file);
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Free the packbuilder and all associated data
|
82
|
+
*
|
83
|
+
* @param pb The packbuilder
|
84
|
+
*/
|
85
|
+
GIT_EXTERN(void) git_packbuilder_free(git_packbuilder *pb);
|
86
|
+
|
87
|
+
/** @} */
|
88
|
+
GIT_END_DECL
|
89
|
+
#endif
|
@@ -10,6 +10,7 @@
|
|
10
10
|
#include "common.h"
|
11
11
|
#include "types.h"
|
12
12
|
#include "oid.h"
|
13
|
+
#include "strarray.h"
|
13
14
|
|
14
15
|
/**
|
15
16
|
* @file git2/refs.h
|
@@ -376,6 +377,93 @@ GIT_EXTERN(int) git_reference_has_log(git_reference *ref);
|
|
376
377
|
*/
|
377
378
|
GIT_EXTERN(int) git_reference_is_branch(git_reference *ref);
|
378
379
|
|
380
|
+
/**
|
381
|
+
* Check if a reference is a remote tracking branch
|
382
|
+
*
|
383
|
+
* @param ref A git reference
|
384
|
+
*
|
385
|
+
* @return 1 when the reference lives in the refs/remotes
|
386
|
+
* namespace; 0 otherwise.
|
387
|
+
*/
|
388
|
+
GIT_EXTERN(int) git_reference_is_remote(git_reference *ref);
|
389
|
+
|
390
|
+
enum {
|
391
|
+
GIT_REF_FORMAT_NORMAL = 0,
|
392
|
+
|
393
|
+
/**
|
394
|
+
* Control whether one-level refnames are accepted
|
395
|
+
* (i.e., refnames that do not contain multiple /-separated
|
396
|
+
* components). Those are expected to be written only using
|
397
|
+
* uppercase letters and underscore (FETCH_HEAD, ...)
|
398
|
+
*/
|
399
|
+
GIT_REF_FORMAT_ALLOW_ONELEVEL = (1 << 0),
|
400
|
+
|
401
|
+
/**
|
402
|
+
* Interpret the provided name as a reference pattern for a
|
403
|
+
* refspec (as used with remote repositories). If this option
|
404
|
+
* is enabled, the name is allowed to contain a single * (<star>)
|
405
|
+
* in place of a one full pathname component
|
406
|
+
* (e.g., foo/<star>/bar but not foo/bar<star>).
|
407
|
+
*/
|
408
|
+
GIT_REF_FORMAT_REFSPEC_PATTERN = (1 << 1),
|
409
|
+
};
|
410
|
+
|
411
|
+
/**
|
412
|
+
* Normalize the reference name by removing any leading
|
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.
|
418
|
+
*
|
419
|
+
* @param buffer_out The user allocated buffer where the
|
420
|
+
* normalized name will be stored.
|
421
|
+
*
|
422
|
+
* @param buffer_size buffer_out size
|
423
|
+
*
|
424
|
+
* @param name name to be checked.
|
425
|
+
*
|
426
|
+
* @param flags Flags to determine the options to be applied while
|
427
|
+
* checking the validatity of the name.
|
428
|
+
*
|
429
|
+
* @return 0 or an error code.
|
430
|
+
*/
|
431
|
+
GIT_EXTERN(int) git_reference_normalize_name(
|
432
|
+
char *buffer_out,
|
433
|
+
size_t buffer_size,
|
434
|
+
const char *name,
|
435
|
+
unsigned int flags);
|
436
|
+
|
437
|
+
/**
|
438
|
+
* Recursively peel an reference until an object of the
|
439
|
+
* specified type is met.
|
440
|
+
*
|
441
|
+
* The retrieved `peeled` object is owned by the repository
|
442
|
+
* and should be closed with the `git_object_free` method.
|
443
|
+
*
|
444
|
+
* If you pass `GIT_OBJ_ANY` as the target type, then the object
|
445
|
+
* will be peeled until a non-tag object is met.
|
446
|
+
*
|
447
|
+
* @param peeled Pointer to the peeled git_object
|
448
|
+
* @param ref The reference to be processed
|
449
|
+
* @param target_type The type of the requested object
|
450
|
+
* @return 0 or an error code
|
451
|
+
*/
|
452
|
+
GIT_EXTERN(int) git_reference_peel(
|
453
|
+
git_object **out,
|
454
|
+
git_reference *ref,
|
455
|
+
git_otype type);
|
456
|
+
|
457
|
+
/**
|
458
|
+
* Ensure the reference name is well-formed.
|
459
|
+
*
|
460
|
+
* @param refname name to be checked.
|
461
|
+
*
|
462
|
+
* @return 1 if the reference name is acceptable; 0 if it isn't
|
463
|
+
*/
|
464
|
+
GIT_EXTERN(int) git_reference_is_valid_name(
|
465
|
+
const char *refname);
|
466
|
+
|
379
467
|
/** @} */
|
380
468
|
GIT_END_DECL
|
381
469
|
#endif
|
@@ -19,14 +19,6 @@
|
|
19
19
|
*/
|
20
20
|
GIT_BEGIN_DECL
|
21
21
|
|
22
|
-
/**
|
23
|
-
* Parse a refspec string and create a refspec object
|
24
|
-
*
|
25
|
-
* @param refspec pointer to the refspec structure to be used
|
26
|
-
* @param str the refspec as a string
|
27
|
-
*/
|
28
|
-
GIT_EXTERN(int) git_refspec_parse(git_refspec *refspec, const char *str);
|
29
|
-
|
30
22
|
/**
|
31
23
|
* Get the source specifier
|
32
24
|
*
|
@@ -12,6 +12,7 @@
|
|
12
12
|
#include "refspec.h"
|
13
13
|
#include "net.h"
|
14
14
|
#include "indexer.h"
|
15
|
+
#include "strarray.h"
|
15
16
|
|
16
17
|
/**
|
17
18
|
* @file git2/remote.h
|
@@ -197,6 +198,14 @@ GIT_EXTERN(int) git_remote_download(git_remote *remote, git_off_t *bytes, git_in
|
|
197
198
|
*/
|
198
199
|
GIT_EXTERN(int) git_remote_connected(git_remote *remote);
|
199
200
|
|
201
|
+
/**
|
202
|
+
* Cancel the operation
|
203
|
+
*
|
204
|
+
* At certain points in its operation, the network code checks whether
|
205
|
+
* the operation has been cancelled and if so stops the operation.
|
206
|
+
*/
|
207
|
+
GIT_EXTERN(void) git_remote_stop(git_remote *remote);
|
208
|
+
|
200
209
|
/**
|
201
210
|
* Disconnect from the remote
|
202
211
|
*
|
@@ -287,7 +296,7 @@ typedef enum git_remote_completion_type {
|
|
287
296
|
* Set the calbacks to be called by the remote.
|
288
297
|
*/
|
289
298
|
struct git_remote_callbacks {
|
290
|
-
|
299
|
+
void (*progress)(const char *str, int len, void *data);
|
291
300
|
int (*completion)(git_remote_completion_type type, void *data);
|
292
301
|
int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
|
293
302
|
void *data;
|
@@ -304,6 +313,30 @@ struct git_remote_callbacks {
|
|
304
313
|
*/
|
305
314
|
GIT_EXTERN(void) git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callbacks);
|
306
315
|
|
316
|
+
enum {
|
317
|
+
GIT_REMOTE_DOWNLOAD_TAGS_UNSET,
|
318
|
+
GIT_REMOTE_DOWNLOAD_TAGS_NONE,
|
319
|
+
GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
|
320
|
+
GIT_REMOTE_DOWNLOAD_TAGS_ALL
|
321
|
+
};
|
322
|
+
|
323
|
+
/**
|
324
|
+
* Retrieve the tag auto-follow setting
|
325
|
+
*
|
326
|
+
* @param remote the remote to query
|
327
|
+
* @return the auto-follow setting
|
328
|
+
*/
|
329
|
+
GIT_EXTERN(int) git_remote_autotag(git_remote *remote);
|
330
|
+
|
331
|
+
/**
|
332
|
+
* Set the tag auto-follow setting
|
333
|
+
*
|
334
|
+
* @param remote the remote to configure
|
335
|
+
* @param value a GIT_REMOTE_DOWNLOAD_TAGS value
|
336
|
+
*/
|
337
|
+
GIT_EXTERN(void) git_remote_set_autotag(git_remote *remote, int value);
|
338
|
+
|
339
|
+
|
307
340
|
/** @} */
|
308
341
|
GIT_END_DECL
|
309
342
|
#endif
|
@@ -83,6 +83,18 @@ GIT_EXTERN(int) git_repository_discover(
|
|
83
83
|
int across_fs,
|
84
84
|
const char *ceiling_dirs);
|
85
85
|
|
86
|
+
/**
|
87
|
+
* Option flags for `git_repository_open_ext`.
|
88
|
+
*
|
89
|
+
* * GIT_REPOSITORY_OPEN_NO_SEARCH - Only open the repository if it can be
|
90
|
+
* immediately found in the start_path. Do not walk up from the
|
91
|
+
* start_path looking at parent directories.
|
92
|
+
* * GIT_REPOSITORY_OPEN_CROSS_FS - Unless this flag is set, open will not
|
93
|
+
* continue searching across filesystem boundaries (i.e. when `st_dev`
|
94
|
+
* changes from the `stat` system call). (E.g. Searching in a user's home
|
95
|
+
* directory "/home/user/source/" will not return "/.git/" as the found
|
96
|
+
* repo if "/" is a different filesystem than "/home".)
|
97
|
+
*/
|
86
98
|
enum {
|
87
99
|
GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0),
|
88
100
|
GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1),
|
@@ -90,6 +102,20 @@ enum {
|
|
90
102
|
|
91
103
|
/**
|
92
104
|
* Find and open a repository with extended controls.
|
105
|
+
*
|
106
|
+
* @param repo_out Pointer to the repo which will be opened. This can
|
107
|
+
* actually be NULL if you only want to use the error code to
|
108
|
+
* see if a repo at this path could be opened.
|
109
|
+
* @param start_path Path to open as git repository. If the flags
|
110
|
+
* permit "searching", then this can be a path to a subdirectory
|
111
|
+
* inside the working directory of the repository.
|
112
|
+
* @param flags A combination of the GIT_REPOSITORY_OPEN flags above.
|
113
|
+
* @param ceiling_dirs A GIT_PATH_LIST_SEPARATOR delimited list of path
|
114
|
+
* prefixes at which the search for a containing repository should
|
115
|
+
* terminate.
|
116
|
+
* @return 0 on success, GIT_ENOTFOUND if no repository could be found,
|
117
|
+
* or -1 if there was a repository but open failed for some reason
|
118
|
+
* (such as repo corruption or system errors).
|
93
119
|
*/
|
94
120
|
GIT_EXTERN(int) git_repository_open_ext(
|
95
121
|
git_repository **repo,
|
@@ -118,13 +144,127 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
|
|
118
144
|
*
|
119
145
|
* @param repo_out pointer to the repo which will be created or reinitialized
|
120
146
|
* @param path the path to the repository
|
121
|
-
* @param is_bare if true, a Git repository without a working directory is
|
122
|
-
* at the pointed path. If false, provided path will be
|
123
|
-
* directory into which the .git directory
|
147
|
+
* @param is_bare if true, a Git repository without a working directory is
|
148
|
+
* created at the pointed path. If false, provided path will be
|
149
|
+
* considered as the working directory into which the .git directory
|
150
|
+
* will be created.
|
124
151
|
*
|
125
152
|
* @return 0 or an error code
|
126
153
|
*/
|
127
|
-
GIT_EXTERN(int) git_repository_init(
|
154
|
+
GIT_EXTERN(int) git_repository_init(
|
155
|
+
git_repository **repo_out,
|
156
|
+
const char *path,
|
157
|
+
unsigned is_bare);
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Option flags for `git_repository_init_ext`.
|
161
|
+
*
|
162
|
+
* These flags configure extra behaviors to `git_repository_init_ext`.
|
163
|
+
* In every case, the default behavior is the zero value (i.e. flag is
|
164
|
+
* not set). Just OR the flag values together for the `flags` parameter
|
165
|
+
* when initializing a new repo. Details of individual values are:
|
166
|
+
*
|
167
|
+
* * BARE - Create a bare repository with no working directory.
|
168
|
+
* * NO_REINIT - Return an EEXISTS error if the repo_path appears to
|
169
|
+
* already be an git repository.
|
170
|
+
* * NO_DOTGIT_DIR - Normally a "/.git/" will be appended to the repo
|
171
|
+
* path for non-bare repos (if it is not already there), but
|
172
|
+
* passing this flag prevents that behavior.
|
173
|
+
* * MKDIR - Make the repo_path (and workdir_path) as needed. Init is
|
174
|
+
* always willing to create the ".git" directory even without this
|
175
|
+
* flag. This flag tells init to create the trailing component of
|
176
|
+
* the repo and workdir paths as needed.
|
177
|
+
* * MKPATH - Recursively make all components of the repo and workdir
|
178
|
+
* paths as necessary.
|
179
|
+
* * EXTERNAL_TEMPLATE - libgit2 normally uses internal templates to
|
180
|
+
* initialize a new repo. This flags enables external templates,
|
181
|
+
* looking the "template_path" from the options if set, or the
|
182
|
+
* `init.templatedir` global config if not, or falling back on
|
183
|
+
* "/usr/share/git-core/templates" if it exists.
|
184
|
+
*/
|
185
|
+
enum {
|
186
|
+
GIT_REPOSITORY_INIT_BARE = (1u << 0),
|
187
|
+
GIT_REPOSITORY_INIT_NO_REINIT = (1u << 1),
|
188
|
+
GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1u << 2),
|
189
|
+
GIT_REPOSITORY_INIT_MKDIR = (1u << 3),
|
190
|
+
GIT_REPOSITORY_INIT_MKPATH = (1u << 4),
|
191
|
+
GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1u << 5),
|
192
|
+
};
|
193
|
+
|
194
|
+
/**
|
195
|
+
* Mode options for `git_repository_init_ext`.
|
196
|
+
*
|
197
|
+
* Set the mode field of the `git_repository_init_options` structure
|
198
|
+
* either to the custom mode that you would like, or to one of the
|
199
|
+
* following modes:
|
200
|
+
*
|
201
|
+
* * SHARED_UMASK - Use permissions configured by umask - the default.
|
202
|
+
* * SHARED_GROUP - Use "--shared=group" behavior, chmod'ing the new repo
|
203
|
+
* to be group writable and "g+sx" for sticky group assignment.
|
204
|
+
* * SHARED_ALL - Use "--shared=all" behavior, adding world readability.
|
205
|
+
* * Anything else - Set to custom value.
|
206
|
+
*/
|
207
|
+
enum {
|
208
|
+
GIT_REPOSITORY_INIT_SHARED_UMASK = 0,
|
209
|
+
GIT_REPOSITORY_INIT_SHARED_GROUP = 0002775,
|
210
|
+
GIT_REPOSITORY_INIT_SHARED_ALL = 0002777,
|
211
|
+
};
|
212
|
+
|
213
|
+
/**
|
214
|
+
* Extended options structure for `git_repository_init_ext`.
|
215
|
+
*
|
216
|
+
* This contains extra options for `git_repository_init_ext` that enable
|
217
|
+
* additional initialization features. The fields are:
|
218
|
+
*
|
219
|
+
* * flags - Combination of GIT_REPOSITORY_INIT flags above.
|
220
|
+
* * mode - Set to one of the standard GIT_REPOSITORY_INIT_SHARED_...
|
221
|
+
* constants above, or to a custom value that you would like.
|
222
|
+
* * workdir_path - The path to the working dir or NULL for default (i.e.
|
223
|
+
* repo_path parent on non-bare repos). IF THIS IS RELATIVE PATH,
|
224
|
+
* IT WILL BE EVALUATED RELATIVE TO THE REPO_PATH. If this is not
|
225
|
+
* the "natural" working directory, a .git gitlink file will be
|
226
|
+
* created here linking to the repo_path.
|
227
|
+
* * description - If set, this will be used to initialize the "description"
|
228
|
+
* file in the repository, instead of using the template content.
|
229
|
+
* * template_path - When GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE is set,
|
230
|
+
* this contains the path to use for the template directory. If
|
231
|
+
* this is NULL, the config or default directory options will be
|
232
|
+
* used instead.
|
233
|
+
* * initial_head - The name of the head to point HEAD at. If NULL, then
|
234
|
+
* this will be treated as "master" and the HEAD ref will be set
|
235
|
+
* to "refs/heads/master". If this begins with "refs/" it will be
|
236
|
+
* used verbatim; otherwise "refs/heads/" will be prefixed.
|
237
|
+
* * origin_url - If this is non-NULL, then after the rest of the
|
238
|
+
* repository initialization is completed, an "origin" remote
|
239
|
+
* will be added pointing to this URL.
|
240
|
+
*/
|
241
|
+
typedef struct {
|
242
|
+
uint32_t flags;
|
243
|
+
uint32_t mode;
|
244
|
+
const char *workdir_path;
|
245
|
+
const char *description;
|
246
|
+
const char *template_path;
|
247
|
+
const char *initial_head;
|
248
|
+
const char *origin_url;
|
249
|
+
} git_repository_init_options;
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Create a new Git repository in the given folder with extended controls.
|
253
|
+
*
|
254
|
+
* This will initialize a new git repository (creating the repo_path
|
255
|
+
* if requested by flags) and working directory as needed. It will
|
256
|
+
* auto-detect the case sensitivity of the file system and if the
|
257
|
+
* file system supports file mode bits correctly.
|
258
|
+
*
|
259
|
+
* @param repo_out Pointer to the repo which will be created or reinitialized.
|
260
|
+
* @param repo_path The path to the repository.
|
261
|
+
* @param opts Pointer to git_repository_init_options struct.
|
262
|
+
* @return 0 or an error code on failure.
|
263
|
+
*/
|
264
|
+
GIT_EXTERN(int) git_repository_init_ext(
|
265
|
+
git_repository **repo_out,
|
266
|
+
const char *repo_path,
|
267
|
+
git_repository_init_options *opts);
|
128
268
|
|
129
269
|
/**
|
130
270
|
* Retrieve and resolve the reference pointed at by HEAD.
|
@@ -132,7 +272,8 @@ GIT_EXTERN(int) git_repository_init(git_repository **repo_out, const char *path,
|
|
132
272
|
* @param head_out pointer to the reference which will be retrieved
|
133
273
|
* @param repo a repository object
|
134
274
|
*
|
135
|
-
* @return 0 on success
|
275
|
+
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing
|
276
|
+
* branch, an error code otherwise
|
136
277
|
*/
|
137
278
|
GIT_EXTERN(int) git_repository_head(git_reference **head_out, git_repository *repo);
|
138
279
|
|
@@ -316,7 +457,7 @@ GIT_EXTERN(int) git_repository_index(git_index **out, git_repository *repo);
|
|
316
457
|
GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index);
|
317
458
|
|
318
459
|
/**
|
319
|
-
*
|
460
|
+
* Retrieve git's prepared message
|
320
461
|
*
|
321
462
|
* Operations such as git revert/cherry-pick/merge with the -n option
|
322
463
|
* stop just short of creating a commit with the changes and save
|
@@ -326,6 +467,11 @@ GIT_EXTERN(void) git_repository_set_index(git_repository *repo, git_index *index
|
|
326
467
|
*
|
327
468
|
* Use this function to get the contents of this file. Don't forget to
|
328
469
|
* remove the file after you create the commit.
|
470
|
+
*
|
471
|
+
* @param buffer Buffer to write data into or NULL to just read required size
|
472
|
+
* @param len Length of buffer in bytes
|
473
|
+
* @param repo Repository to read prepared message from
|
474
|
+
* @return Bytes written to buffer, GIT_ENOTFOUND if no message, or -1 on error
|
329
475
|
*/
|
330
476
|
GIT_EXTERN(int) git_repository_message(char *buffer, size_t len, git_repository *repo);
|
331
477
|
|
@@ -336,6 +482,92 @@ GIT_EXTERN(int) git_repository_message(char *buffer, size_t len, git_repository
|
|
336
482
|
*/
|
337
483
|
GIT_EXTERN(int) git_repository_message_remove(git_repository *repo);
|
338
484
|
|
485
|
+
/**
|
486
|
+
* Calculate hash of file using repository filtering rules.
|
487
|
+
*
|
488
|
+
* If you simply want to calculate the hash of a file on disk with no filters,
|
489
|
+
* you can just use the `git_odb_hashfile()` API. However, if you want to
|
490
|
+
* hash a file in the repository and you want to apply filtering rules (e.g.
|
491
|
+
* crlf filters) before generating the SHA, then use this function.
|
492
|
+
*
|
493
|
+
* @param out Output value of calculated SHA
|
494
|
+
* @param repo Repository pointer
|
495
|
+
* @param path Path to file on disk whose contents should be hashed. If the
|
496
|
+
* repository is not NULL, this can be a relative path.
|
497
|
+
* @param type The object type to hash as (e.g. GIT_OBJ_BLOB)
|
498
|
+
* @param as_path The path to use to look up filtering rules. If this is
|
499
|
+
* NULL, then the `path` parameter will be used instead. If
|
500
|
+
* this is passed as the empty string, then no filters will be
|
501
|
+
* applied when calculating the hash.
|
502
|
+
*/
|
503
|
+
GIT_EXTERN(int) git_repository_hashfile(
|
504
|
+
git_oid *out,
|
505
|
+
git_repository *repo,
|
506
|
+
const char *path,
|
507
|
+
git_otype type,
|
508
|
+
const char *as_path);
|
509
|
+
|
510
|
+
/**
|
511
|
+
* Make the repository HEAD point to the specified reference.
|
512
|
+
*
|
513
|
+
* If the provided reference points to a Tree or a Blob, the HEAD is
|
514
|
+
* unaltered and -1 is returned.
|
515
|
+
*
|
516
|
+
* If the provided reference points to a branch, the HEAD will point
|
517
|
+
* to that branch, staying attached, or become attached if it isn't yet.
|
518
|
+
* If the branch doesn't exist yet, no error will be return. The HEAD
|
519
|
+
* will then be attached to an unborn branch.
|
520
|
+
*
|
521
|
+
* Otherwise, the HEAD will be detached and will directly point to
|
522
|
+
* the Commit.
|
523
|
+
*
|
524
|
+
* @param repo Repository pointer
|
525
|
+
* @param refname Canonical name of the reference the HEAD should point at
|
526
|
+
* @return 0 on success, or an error code
|
527
|
+
*/
|
528
|
+
GIT_EXTERN(int) git_repository_set_head(
|
529
|
+
git_repository* repo,
|
530
|
+
const char* refname);
|
531
|
+
|
532
|
+
/**
|
533
|
+
* Make the repository HEAD directly point to the Commit.
|
534
|
+
*
|
535
|
+
* If the provided committish cannot be found in the repository, the HEAD
|
536
|
+
* is unaltered and GIT_ENOTFOUND is returned.
|
537
|
+
*
|
538
|
+
* If the provided commitish cannot be peeled into a commit, the HEAD
|
539
|
+
* is unaltered and -1 is returned.
|
540
|
+
*
|
541
|
+
* Otherwise, the HEAD will eventually be detached and will directly point to
|
542
|
+
* the peeled Commit.
|
543
|
+
*
|
544
|
+
* @param repo Repository pointer
|
545
|
+
* @param commitish Object id of the Commit the HEAD should point to
|
546
|
+
* @return 0 on success, or an error code
|
547
|
+
*/
|
548
|
+
GIT_EXTERN(int) git_repository_set_head_detached(
|
549
|
+
git_repository* repo,
|
550
|
+
const git_oid* commitish);
|
551
|
+
|
552
|
+
/**
|
553
|
+
* Detach the HEAD.
|
554
|
+
*
|
555
|
+
* If the HEAD is already detached and points to a Commit, 0 is returned.
|
556
|
+
*
|
557
|
+
* If the HEAD is already detached and points to a Tag, the HEAD is
|
558
|
+
* updated into making it point to the peeled Commit, and 0 is returned.
|
559
|
+
*
|
560
|
+
* If the HEAD is already detached and points to a non commitish, the HEAD is
|
561
|
+
* unaletered, and -1 is returned.
|
562
|
+
*
|
563
|
+
* Otherwise, the HEAD will be detached and point to the peeled Commit.
|
564
|
+
*
|
565
|
+
* @param repo Repository pointer
|
566
|
+
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing
|
567
|
+
* branch or an error code
|
568
|
+
*/
|
569
|
+
GIT_EXTERN(int) git_repository_detach_head(
|
570
|
+
git_repository* repo);
|
339
571
|
|
340
572
|
/** @} */
|
341
573
|
GIT_END_DECL
|