Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 72a3fe4

Browse files
committed
I broke your bindings
Hey. Apologies in advance -- I broke your bindings. This is a major commit that includes a long-overdue redesign of the whole object-database structure. This is expected to be the last major external API redesign of the library until the first non-alpha release. Please get your bindings up to date with these changes. They will be included in the next minor release. Sorry again! Major features include: - Real caching and refcounting on parsed objects - Real caching and refcounting on objects read from the ODB - Streaming writes & reads from the ODB - Single-method writes for all object types - The external API is now partially thread-safe The speed increases are significant in all aspects, specially when reading an object several times from the ODB (revwalking) and when writing big objects to the ODB. Here's a full changelog for the external API: blob.h ------ - Remove `git_blob_new` - Remove `git_blob_set_rawcontent` - Remove `git_blob_set_rawcontent_fromfile` - Rename `git_blob_writefile` -> `git_blob_create_fromfile` - Change `git_blob_create_fromfile`: The `path` argument is now relative to the repository's working dir - Add `git_blob_create_frombuffer` commit.h -------- - Remove `git_commit_new` - Remove `git_commit_add_parent` - Remove `git_commit_set_message` - Remove `git_commit_set_committer` - Remove `git_commit_set_author` - Remove `git_commit_set_tree` - Add `git_commit_create` - Add `git_commit_create_v` - Add `git_commit_create_o` - Add `git_commit_create_ov` tag.h ----- - Remove `git_tag_new` - Remove `git_tag_set_target` - Remove `git_tag_set_name` - Remove `git_tag_set_tagger` - Remove `git_tag_set_message` - Add `git_tag_create` - Add `git_tag_create_o` tree.h ------ - Change `git_tree_entry_2object`: New signature is `(git_object **object_out, git_repository *repo, git_tree_entry *entry)` - Remove `git_tree_new` - Remove `git_tree_add_entry` - Remove `git_tree_remove_entry_byindex` - Remove `git_tree_remove_entry_byname` - Remove `git_tree_clearentries` - Remove `git_tree_entry_set_id` - Remove `git_tree_entry_set_name` - Remove `git_tree_entry_set_attributes` object.h ------------ - Remove `git_object_new - Remove `git_object_write` - Change `git_object_close`: This method is now *mandatory*. Not closing an object causes a memory leak. odb.h ----- - Remove type `git_rawobj` - Remove `git_rawobj_close` - Rename `git_rawobj_hash` -> `git_odb_hash` - Change `git_odb_hash`: New signature is `(git_oid *id, const void *data, size_t len, git_otype type)` - Add type `git_odb_object` - Add `git_odb_object_close` - Change `git_odb_read`: New signature is `(git_odb_object **out, git_odb *db, const git_oid *id)` - Change `git_odb_read_header`: New signature is `(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)` - Remove `git_odb_write` - Add `git_odb_open_wstream` - Add `git_odb_open_rstream` odb_backend.h ------------- - Change type `git_odb_backend`: New internal signatures are as follows int (* read)(void **, size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* read_header)(size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* writestream)(struct git_odb_stream **, struct git_odb_backend *, size_t, git_otype) int (* readstream)( struct git_odb_stream **, struct git_odb_backend *, const git_oid *) - Add type `git_odb_stream` - Add enum `git_odb_streammode` Signed-off-by: Vicent Marti <[email protected]>
1 parent bb3de0c commit 72a3fe4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1429
-1643
lines changed

include/git2/blob.h

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ GIT_BEGIN_DECL
4141

4242
/**
4343
* Lookup a blob object from a repository.
44-
* The generated blob object is owned by the revision
45-
* repo and shall not be freed by the user.
4644
*
4745
* @param blob pointer to the looked up blob
4846
* @param repo the repo to use when locating the blob.
@@ -54,50 +52,13 @@ GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git
5452
return git_object_lookup((git_object **)blob, repo, id, GIT_OBJ_BLOB);
5553
}
5654

57-
/**
58-
* Create a new in-memory git_blob.
59-
*
60-
* The blob object must be manually filled using
61-
* the 'set_rawcontent' methods before it can
62-
* be written back to disk.
63-
*
64-
* @param blob pointer to the new blob
65-
* @param repo The repository where the object will reside
66-
* @return 0 on success; error code otherwise
67-
*/
68-
GIT_INLINE(int) git_blob_new(git_blob **blob, git_repository *repo)
69-
{
70-
return git_object_new((git_object **)blob, repo, GIT_OBJ_BLOB);
71-
}
72-
73-
/**
74-
* Fill a blob with the contents inside
75-
* the pointed file.
76-
*
77-
* @param blob pointer to the new blob
78-
* @param filename name of the file to read
79-
* @return 0 on success; error code otherwise
80-
*/
81-
GIT_EXTERN(int) git_blob_set_rawcontent_fromfile(git_blob *blob, const char *filename);
82-
83-
/**
84-
* Fill a blob with the contents inside
85-
* the pointed buffer
86-
*
87-
* @param blob pointer to the blob
88-
* @param buffer buffer with the contents for the blob
89-
* @param len size of the buffer
90-
* @return 0 on success; error code otherwise
91-
*/
92-
GIT_EXTERN(int) git_blob_set_rawcontent(git_blob *blob, const void *buffer, size_t len);
93-
9455
/**
9556
* Get a read-only buffer with the raw content of a blob.
9657
*
9758
* A pointer to the raw content of a blob is returned;
9859
* this pointer is owned internally by the object and shall
9960
* not be free'd. The pointer may be invalidated at a later
100-
* time (e.g. when changing the contents of the blob).
61+
* time.
10162
*
10263
* @param blob pointer to the blob
10364
* @return the pointer; NULL if the blob has no contents
@@ -114,14 +75,28 @@ GIT_EXTERN(int) git_blob_rawsize(git_blob *blob);
11475

11576
/**
11677
* Read a file from the working folder of a repository
117-
* and write it to the Object Database as a loose blob,
118-
* if such doesn't exist yet.
78+
* and write it to the Object Database as a loose blob
11979
*
120-
* @param written_id return the id of the written blob
121-
* @param repo repository where the blob will be written
122-
* @param path file from which the blob will be created
80+
* @param oid return the id of the written blob
81+
* @param repo repository where the blob will be written.
82+
* this repository cannot be bare
83+
* @param path file from which the blob will be created,
84+
* relative to the repository's working dir
85+
* @return 0 on success; error code otherwise
86+
*/
87+
GIT_EXTERN(int) git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *path);
88+
89+
90+
/**
91+
* Write an in-memory buffer to the ODB as a blob
92+
*
93+
* @param oid return the oid of the written blob
94+
* @param repo repository where to blob will be written
95+
* @param buffer data to be written into the blob
96+
* @param len length of the data
97+
* @return 0 on success; error code otherwise
12398
*/
124-
GIT_EXTERN(int) git_blob_writefile(git_oid *written_id, git_repository *repo, const char *path);
99+
GIT_EXTERN(int) git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *buffer, size_t len);
125100

126101
/** @} */
127102
GIT_END_DECL

include/git2/commit.h

Lines changed: 118 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ GIT_BEGIN_DECL
4141

4242
/**
4343
* Lookup a commit object from a repository.
44-
* The generated commit object is owned by the revision
45-
* repo and shall not be freed by the user.
4644
*
4745
* @param commit pointer to the looked up commit
4846
* @param repo the repo to use when locating the commit.
@@ -55,73 +53,65 @@ GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, con
5553
return git_object_lookup((git_object **)commit, repo, id, GIT_OBJ_COMMIT);
5654
}
5755

58-
/**
59-
* Create a new in-memory git_commit.
60-
*
61-
* The commit object must be manually filled using
62-
* setter methods before it can be written to its
63-
* repository.
64-
*
65-
* @param commit pointer to the new commit
66-
* @param repo The repository where the object will reside
67-
* @return 0 on success; error code otherwise
68-
*/
69-
GIT_INLINE(int) git_commit_new(git_commit **commit, git_repository *repo)
70-
{
71-
return git_object_new((git_object **)commit, repo, GIT_OBJ_COMMIT);
72-
}
73-
7456
/**
7557
* Get the id of a commit.
58+
*
7659
* @param commit a previously loaded commit.
7760
* @return object identity for the commit.
7861
*/
7962
GIT_EXTERN(const git_oid *) git_commit_id(git_commit *commit);
8063

8164
/**
8265
* Get the short (one line) message of a commit.
66+
*
8367
* @param commit a previously loaded commit.
8468
* @return the short message of a commit
8569
*/
8670
GIT_EXTERN(const char *) git_commit_message_short(git_commit *commit);
8771

8872
/**
8973
* Get the full message of a commit.
74+
*
9075
* @param commit a previously loaded commit.
9176
* @return the message of a commit
9277
*/
9378
GIT_EXTERN(const char *) git_commit_message(git_commit *commit);
9479

9580
/**
9681
* Get the commit time (i.e. committer time) of a commit.
82+
*
9783
* @param commit a previously loaded commit.
9884
* @return the time of a commit
9985
*/
10086
GIT_EXTERN(time_t) git_commit_time(git_commit *commit);
10187

10288
/**
10389
* Get the commit timezone offset (i.e. committer's preferred timezone) of a commit.
90+
*
10491
* @param commit a previously loaded commit.
10592
* @return positive or negative timezone offset, in minutes from UTC
10693
*/
10794
GIT_EXTERN(int) git_commit_time_offset(git_commit *commit);
10895

10996
/**
11097
* Get the committer of a commit.
98+
*
11199
* @param commit a previously loaded commit.
112100
* @return the committer of a commit
113101
*/
114102
GIT_EXTERN(const git_signature *) git_commit_committer(git_commit *commit);
115103

116104
/**
117105
* Get the author of a commit.
106+
*
118107
* @param commit a previously loaded commit.
119108
* @return the author of a commit
120109
*/
121110
GIT_EXTERN(const git_signature *) git_commit_author(git_commit *commit);
122111

123112
/**
124113
* Get the tree pointed to by a commit.
114+
*
125115
* @param tree_out pointer where to store the tree object
126116
* @param commit a previously loaded commit.
127117
* @return 0 on success; error code otherwise
@@ -146,42 +136,129 @@ GIT_EXTERN(unsigned int) git_commit_parentcount(git_commit *commit);
146136
*/
147137
GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n);
148138

139+
149140
/**
150-
* Add a new parent commit to an existing commit
151-
* @param commit the commit object
152-
* @param new_parent the new commit which will be a parent
141+
* Create a new commit in the repository
142+
*
143+
*
144+
* @param oid Pointer where to store the OID of the
145+
* newly created commit
146+
*
147+
* @param repo Repository where to store the commit
148+
*
149+
* @param update_ref If not NULL, name of the reference that
150+
* will be updated to point to this commit. If the reference
151+
* is not direct, it will be resolved to a direct reference.
152+
* Use "HEAD" to update the HEAD of the current branch and
153+
* make it point to this commit
154+
*
155+
* @param author Signature representing the author and the authory
156+
* time of this commit
157+
*
158+
* @param committer Signature representing the committer and the
159+
* commit time of this commit
160+
*
161+
* @param message Full message for this commit
162+
*
163+
* @param tree_oid Object ID of the tree for this commit. Note that
164+
* no validation is performed on this OID. Use the _o variants of
165+
* this method to assure a proper tree is passed to the commit.
166+
*
167+
* @param parent_count Number of parents for this commit
168+
*
169+
* @param parents Array of pointers to parent OIDs for this commit.
170+
* Note that no validation is performed on these OIDs. Use the _o
171+
* variants of this method to assure that are parents for the commit
172+
* are proper objects.
173+
*
153174
* @return 0 on success; error code otherwise
175+
* The created commit will be written to the Object Database and
176+
* the given reference will be updated to point to it
154177
*/
155-
GIT_EXTERN(int) git_commit_add_parent(git_commit *commit, git_commit *new_parent);
178+
GIT_EXTERN(int) git_commit_create(
179+
git_oid *oid,
180+
git_repository *repo,
181+
const char *update_ref,
182+
const git_signature *author,
183+
const git_signature *committer,
184+
const char *message,
185+
const git_oid *tree_oid,
186+
int parent_count,
187+
const git_oid *parent_oids[]);
156188

157189
/**
158-
* Set the message of a commit
159-
* @param commit the commit object
160-
* @param message the new message
190+
* Create a new commit in the repository using `git_object`
191+
* instances as parameters.
192+
*
193+
* The `tree_oid` and `parent_oids` paremeters now take a instance
194+
* of `git_tree` and `git_commit`, respectively.
195+
*
196+
* All other parameters remain the same
197+
*
198+
* @see git_commit_create
161199
*/
162-
GIT_EXTERN(void) git_commit_set_message(git_commit *commit, const char *message);
200+
GIT_EXTERN(int) git_commit_create_o(
201+
git_oid *oid,
202+
git_repository *repo,
203+
const char *update_ref,
204+
const git_signature *author,
205+
const git_signature *committer,
206+
const char *message,
207+
const git_tree *tree,
208+
int parent_count,
209+
const git_commit *parents[]);
163210

164211
/**
165-
* Set the committer of a commit
166-
* @param commit the commit object
167-
* @param author_sig signature of the committer
212+
* Create a new commit in the repository using `git_object`
213+
* instances and a variable argument list.
214+
*
215+
* The `tree_oid` paremeter now takes a instance
216+
* of `const git_tree *`.
217+
*
218+
* The parents for the commit are specified as a variable
219+
* list of pointers to `const git_commit *`. Note that this
220+
* is a convenience method which may not be safe to export
221+
* for certain languages or compilers
222+
*
223+
* All other parameters remain the same
224+
*
225+
* @see git_commit_create
168226
*/
169-
GIT_EXTERN(void) git_commit_set_committer(git_commit *commit, const git_signature *committer_sig);
227+
GIT_EXTERN(int) git_commit_create_ov(
228+
git_oid *oid,
229+
git_repository *repo,
230+
const char *update_ref,
231+
const git_signature *author,
232+
const git_signature *committer,
233+
const char *message,
234+
const git_tree *tree,
235+
int parent_count,
236+
...);
170237

171-
/**
172-
* Set the author of a commit
173-
* @param commit the commit object
174-
* @param author_sig signature of the author
175-
*/
176-
GIT_EXTERN(void) git_commit_set_author(git_commit *commit, const git_signature *author_sig);
177238

178239
/**
179-
* Set the tree which is pointed to by a commit
180-
* @param commit the commit object
181-
* @param tree the new tree
182-
* @param 0 on success; error code otherwise
240+
* Create a new commit in the repository using
241+
* a variable argument list.
242+
*
243+
* The parents for the commit are specified as a variable
244+
* list of pointers to `const git_oid *`. Note that this
245+
* is a convenience method which may not be safe to export
246+
* for certain languages or compilers
247+
*
248+
* All other parameters remain the same
249+
*
250+
* @see git_commit_create
183251
*/
184-
GIT_EXTERN(int) git_commit_set_tree(git_commit *commit, git_tree *tree);
252+
GIT_EXTERN(int) git_commit_create_v(
253+
git_oid *oid,
254+
git_repository *repo,
255+
const char *update_ref,
256+
const git_signature *author,
257+
const git_signature *committer,
258+
const char *message,
259+
const git_oid *tree_oid,
260+
int parent_count,
261+
...);
185262

186263
/** @} */
187264
GIT_END_DECL

include/git2/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
/** The state of the reference is not valid */
159159
#define GIT_EINVALIDREFSTATE (GIT_ERROR - 21)
160160

161+
/** This feature has not been implemented yet */
162+
#define GIT_ENOTIMPLEMENTED (GIT_ERROR - 22)
163+
161164
GIT_BEGIN_DECL
162165

163166
typedef struct {

0 commit comments

Comments
 (0)