diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/blob.c | 6 | ||||
-rw-r--r-- | src/branch.c | 19 | ||||
-rw-r--r-- | src/checkout.c | 2 | ||||
-rw-r--r-- | src/clone.c | 10 | ||||
-rw-r--r-- | src/commit.c | 53 | ||||
-rw-r--r-- | src/commit.h | 4 | ||||
-rw-r--r-- | src/diff_output.c | 26 | ||||
-rw-r--r-- | src/diff_output.h | 6 | ||||
-rw-r--r-- | src/index.c | 2 | ||||
-rw-r--r-- | src/object.c | 6 | ||||
-rw-r--r-- | src/transports/local.c | 2 |
11 files changed, 60 insertions, 76 deletions
diff --git a/src/blob.c b/src/blob.c index 76d265faa..b168df137 100644 --- a/src/blob.c +++ b/src/blob.c @@ -19,10 +19,10 @@ const void *git_blob_rawcontent(git_blob *blob) return blob->odb_object->raw.data; } -size_t git_blob_rawsize(git_blob *blob) +git_off_t git_blob_rawsize(git_blob *blob) { assert(blob); - return blob->odb_object->raw.len; + return (git_off_t)blob->odb_object->raw.len; } int git_blob__getbuf(git_buf *buffer, git_blob *blob) @@ -205,7 +205,7 @@ static int blob_create_internal(git_oid *oid, git_repository *repo, const char * return error; } -int git_blob_create_fromfile(git_oid *oid, git_repository *repo, const char *path) +int git_blob_create_fromworkdir(git_oid *oid, git_repository *repo, const char *path) { git_buf full_path = GIT_BUF_INIT; const char *workdir; diff --git a/src/branch.c b/src/branch.c index c6173caca..5eab5aef0 100644 --- a/src/branch.c +++ b/src/branch.c @@ -44,12 +44,6 @@ cleanup: return error; } -static int create_error_invalid(const char *msg) -{ - giterr_set(GITERR_INVALID, "Cannot create branch - %s", msg); - return -1; -} - static int not_a_local_branch(git_reference *ref) { giterr_set(GITERR_INVALID, "Reference '%s' is not a local branch.", git_reference_name(ref)); @@ -60,31 +54,26 @@ int git_branch_create( git_reference **ref_out, git_repository *repository, const char *branch_name, - const git_object *target, + const git_commit *commit, int force) { - git_object *commit = NULL; git_reference *branch = NULL; git_buf canonical_branch_name = GIT_BUF_INIT; int error = -1; - assert(branch_name && target && ref_out); - assert(git_object_owner(target) == repository); - - if (git_object_peel(&commit, (git_object *)target, GIT_OBJ_COMMIT) < 0) - return create_error_invalid("The given target does not resolve to a commit"); + assert(branch_name && commit && ref_out); + assert(git_object_owner((const git_object *)commit) == repository); if (git_buf_joinpath(&canonical_branch_name, GIT_REFS_HEADS_DIR, branch_name) < 0) goto cleanup; error = git_reference_create_oid(&branch, repository, - git_buf_cstr(&canonical_branch_name), git_object_id(commit), force); + git_buf_cstr(&canonical_branch_name), git_commit_id(commit), force); if (!error) *ref_out = branch; cleanup: - git_object_free(commit); git_buf_free(&canonical_branch_name); return error; } diff --git a/src/checkout.c b/src/checkout.c index eff14813d..5229357fb 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -691,7 +691,7 @@ cleanup: int git_checkout_tree( git_repository *repo, - git_object *treeish, + const git_object *treeish, git_checkout_opts *opts) { int error = 0; diff --git a/src/clone.c b/src/clone.c index 9ef6f8100..0548dc42c 100644 --- a/src/clone.c +++ b/src/clone.c @@ -28,18 +28,18 @@ static int create_branch( const git_oid *target, const char *name) { - git_object *head_obj = NULL; + git_commit *head_obj = NULL; git_reference *branch_ref; int error; /* Find the target commit */ - if ((error = git_object_lookup(&head_obj, repo, target, GIT_OBJ_ANY)) < 0) + if ((error = git_commit_lookup(&head_obj, repo, target)) < 0) return error; /* Create the new branch */ error = git_branch_create(&branch_ref, repo, name, head_obj, 0); - git_object_free(head_obj); + git_commit_free(head_obj); if (!error) *branch = branch_ref; @@ -381,9 +381,9 @@ int git_clone( git_repository **out, const char *origin_url, const char *workdir_path, + git_checkout_opts *checkout_opts, git_transfer_progress_callback fetch_progress_cb, - void *fetch_progress_payload, - git_checkout_opts *checkout_opts) + void *fetch_progress_payload) { assert(out && origin_url && workdir_path); diff --git a/src/commit.c b/src/commit.c index b66978aff..4072518ff 100644 --- a/src/commit.c +++ b/src/commit.c @@ -22,18 +22,18 @@ static void clear_parents(git_commit *commit) { unsigned int i; - for (i = 0; i < commit->parent_oids.length; ++i) { - git_oid *parent = git_vector_get(&commit->parent_oids, i); + for (i = 0; i < commit->parent_ids.length; ++i) { + git_oid *parent = git_vector_get(&commit->parent_ids, i); git__free(parent); } - git_vector_clear(&commit->parent_oids); + git_vector_clear(&commit->parent_ids); } void git_commit__free(git_commit *commit) { clear_parents(commit); - git_vector_free(&commit->parent_oids); + git_vector_free(&commit->parent_ids); git_signature_free(commit->author); git_signature_free(commit->committer); @@ -43,11 +43,6 @@ void git_commit__free(git_commit *commit) git__free(commit); } -const git_oid *git_commit_id(git_commit *c) -{ - return git_object_id((git_object *)c); -} - int git_commit_create_v( git_oid *oid, git_repository *repo, @@ -141,26 +136,26 @@ int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len) const char *buffer = data; const char *buffer_end = (const char *)data + len; - git_oid parent_oid; + git_oid parent_id; - git_vector_init(&commit->parent_oids, 4, NULL); + git_vector_init(&commit->parent_ids, 4, NULL); - if (git_oid__parse(&commit->tree_oid, &buffer, buffer_end, "tree ") < 0) + if (git_oid__parse(&commit->tree_id, &buffer, buffer_end, "tree ") < 0) goto bad_buffer; /* * TODO: commit grafts! */ - while (git_oid__parse(&parent_oid, &buffer, buffer_end, "parent ") == 0) { - git_oid *new_oid; + while (git_oid__parse(&parent_id, &buffer, buffer_end, "parent ") == 0) { + git_oid *new_id; - new_oid = git__malloc(sizeof(git_oid)); - GITERR_CHECK_ALLOC(new_oid); + new_id = git__malloc(sizeof(git_oid)); + GITERR_CHECK_ALLOC(new_id); - git_oid_cpy(new_oid, &parent_oid); + git_oid_cpy(new_id, &parent_id); - if (git_vector_insert(&commit->parent_oids, new_oid) < 0) + if (git_vector_insert(&commit->parent_ids, new_id) < 0) return -1; } @@ -214,7 +209,7 @@ int git_commit__parse(git_commit *commit, git_odb_object *obj) } #define GIT_COMMIT_GETTER(_rvalue, _name, _return) \ - _rvalue git_commit_##_name(git_commit *commit) \ + _rvalue git_commit_##_name(const git_commit *commit) \ {\ assert(commit); \ return _return; \ @@ -226,34 +221,34 @@ GIT_COMMIT_GETTER(const char *, message, commit->message) GIT_COMMIT_GETTER(const char *, message_encoding, commit->message_encoding) GIT_COMMIT_GETTER(git_time_t, time, commit->committer->when.time) GIT_COMMIT_GETTER(int, time_offset, commit->committer->when.offset) -GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)commit->parent_oids.length) -GIT_COMMIT_GETTER(const git_oid *, tree_oid, &commit->tree_oid); +GIT_COMMIT_GETTER(unsigned int, parentcount, (unsigned int)commit->parent_ids.length) +GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id); -int git_commit_tree(git_tree **tree_out, git_commit *commit) +int git_commit_tree(git_tree **tree_out, const git_commit *commit) { assert(commit); - return git_tree_lookup(tree_out, commit->object.repo, &commit->tree_oid); + return git_tree_lookup(tree_out, commit->object.repo, &commit->tree_id); } -const git_oid *git_commit_parent_oid(git_commit *commit, unsigned int n) +const git_oid *git_commit_parent_id(git_commit *commit, unsigned int n) { assert(commit); - return git_vector_get(&commit->parent_oids, n); + return git_vector_get(&commit->parent_ids, n); } int git_commit_parent(git_commit **parent, git_commit *commit, unsigned int n) { - const git_oid *parent_oid; + const git_oid *parent_id; assert(commit); - parent_oid = git_commit_parent_oid(commit, n); - if (parent_oid == NULL) { + parent_id = git_commit_parent_id(commit, n); + if (parent_id == NULL) { giterr_set(GITERR_INVALID, "Parent %u does not exist", n); return GIT_ENOTFOUND; } - return git_commit_lookup(parent, commit->object.repo, parent_oid); + return git_commit_lookup(parent, commit->object.repo, parent_id); } int git_commit_nth_gen_ancestor( diff --git a/src/commit.h b/src/commit.h index d9f492862..1d1dc0ddb 100644 --- a/src/commit.h +++ b/src/commit.h @@ -17,8 +17,8 @@ struct git_commit { git_object object; - git_vector parent_oids; - git_oid tree_oid; + git_vector parent_ids; + git_oid tree_id; git_signature *author; git_signature *committer; diff --git a/src/diff_output.c b/src/diff_output.c index 46a9e02bf..5c887cd7e 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -441,9 +441,9 @@ static void diff_context_init( git_repository *repo, const git_diff_options *opts, void *data, - git_diff_file_fn file_cb, - git_diff_hunk_fn hunk_cb, - git_diff_data_fn data_cb) + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_data_cb data_cb) { memset(ctxt, 0, sizeof(diff_context)); @@ -905,9 +905,9 @@ static int diff_patch_line_cb( int git_diff_foreach( git_diff_list *diff, void *cb_data, - git_diff_file_fn file_cb, - git_diff_hunk_fn hunk_cb, - git_diff_data_fn data_cb) + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_data_cb data_cb) { int error = 0; diff_context ctxt; @@ -951,7 +951,7 @@ int git_diff_foreach( typedef struct { git_diff_list *diff; - git_diff_data_fn print_cb; + git_diff_data_cb print_cb; void *cb_data; git_buf *buf; } diff_print_info; @@ -1030,7 +1030,7 @@ static int print_compact( int git_diff_print_compact( git_diff_list *diff, void *cb_data, - git_diff_data_fn print_cb) + git_diff_data_cb print_cb) { int error; git_buf buf = GIT_BUF_INIT; @@ -1211,7 +1211,7 @@ static int print_patch_line( int git_diff_print_patch( git_diff_list *diff, void *cb_data, - git_diff_data_fn print_cb) + git_diff_data_cb print_cb) { int error; git_buf buf = GIT_BUF_INIT; @@ -1251,9 +1251,9 @@ int git_diff_blobs( git_blob *new_blob, const git_diff_options *options, void *cb_data, - git_diff_file_fn file_cb, - git_diff_hunk_fn hunk_cb, - git_diff_data_fn data_cb) + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_data_cb data_cb) { int error; git_repository *repo; @@ -1518,7 +1518,7 @@ static int print_to_buffer_cb( int git_diff_patch_print( git_diff_patch *patch, void *cb_data, - git_diff_data_fn print_cb) + git_diff_data_cb print_cb) { int error; git_buf temp = GIT_BUF_INIT; diff --git a/src/diff_output.h b/src/diff_output.h index f74dd3a71..8d7b5e472 100644 --- a/src/diff_output.h +++ b/src/diff_output.h @@ -27,9 +27,9 @@ typedef struct { git_repository *repo; git_diff_list *diff; const git_diff_options *opts; - git_diff_file_fn file_cb; - git_diff_hunk_fn hunk_cb; - git_diff_data_fn data_cb; + git_diff_file_cb file_cb; + git_diff_hunk_cb hunk_cb; + git_diff_data_cb data_cb; void *cb_data; int cb_error; git_diff_range cb_range; diff --git a/src/index.c b/src/index.c index 128dd18cf..350d3632b 100644 --- a/src/index.c +++ b/src/index.c @@ -580,7 +580,7 @@ static int index_entry_init(git_index_entry **entry_out, git_index *index, const */ /* write the blob to disk and get the oid */ - if ((error = git_blob_create_fromfile(&oid, INDEX_OWNER(index), rel_path)) < 0) + if ((error = git_blob_create_fromworkdir(&oid, INDEX_OWNER(index), rel_path)) < 0) return error; entry = git__calloc(1, sizeof(git_index_entry)); diff --git a/src/object.c b/src/object.c index 2e45eb86a..89af9158d 100644 --- a/src/object.c +++ b/src/object.c @@ -374,7 +374,7 @@ static int dereference_object(git_object **dereferenced, git_object *obj) int git_object_peel( git_object **peeled, - git_object *object, + const git_object *object, git_otype target_type) { git_object *source, *deref = NULL; @@ -382,9 +382,9 @@ int git_object_peel( assert(object && peeled); if (git_object_type(object) == target_type) - return git_object__dup(peeled, object); + return git_object__dup(peeled, (git_object *)object); - source = object; + source = (git_object *)object; while (!dereference_object(&deref, source)) { diff --git a/src/transports/local.c b/src/transports/local.c index 46c9218c7..43d5da0f9 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -306,7 +306,7 @@ static int local_download_pack( if (git_odb_exists(odb, &oid)) continue; if (!git_object_lookup((git_object**)&commit, t->repo, &oid, GIT_OBJ_COMMIT)) { - const git_oid *tree_oid = git_commit_tree_oid(commit); + const git_oid *tree_oid = git_commit_tree_id(commit); git_commit_free(commit); /* Add the commit and its tree */ |