void test_network_fetchlocal__partial(void) { git_repository *repo = cl_git_sandbox_init("partial-testrepo"); git_remote *origin; int callcount = 0; git_strarray refnames = {0}; const char *url; git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT; callbacks.transfer_progress = transfer_cb; callbacks.payload = &callcount; cl_set_cleanup(&cleanup_sandbox, NULL); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(1, (int)refnames.count); url = cl_git_fixture_url("testrepo.git"); cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url)); git_remote_set_callbacks(origin, &callbacks); cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH)); cl_git_pass(git_remote_download(origin)); cl_git_pass(git_remote_update_tips(origin, NULL, NULL)); git_strarray_free(&refnames); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(20, (int)refnames.count); /* 18 remote + 1 local */ cl_assert(callcount > 0); git_strarray_free(&refnames); git_remote_free(origin); }
PyObject * Repository_remotes__get__(Repository *self) { git_strarray remotes; git_remote *remote = NULL; PyObject *py_list = NULL; PyObject *py_remote = NULL; size_t i; int err; git_remote_list(&remotes, self->repo); py_list = PyList_New(remotes.count); for (i=0; i < remotes.count; ++i) { err = git_remote_load(&remote, self->repo, remotes.strings[i]); if (err < 0) goto cleanup; py_remote = wrap_remote(remote, self); if (py_remote == NULL) goto cleanup; PyList_SetItem(py_list, i, py_remote); } git_strarray_free(&remotes); return (PyObject*) py_list; cleanup: git_strarray_free(&remotes); if (py_list) Py_DECREF(py_list); if (err < 0) return Error_set(err); return NULL; }
void test_network_remote_remotes__query_refspecs(void) { git_remote *remote; git_strarray array; int i; cl_git_pass(git_remote_create_with_fetchspec(&remote, _repo, "query", "git://github.com/libgit2/libgit2", NULL)); git_remote_free(remote); for (i = 0; i < 3; i++) { cl_git_pass(git_remote_add_fetch(_repo, "query", fetch_refspecs[i])); cl_git_pass(git_remote_add_push(_repo, "query", push_refspecs[i])); } cl_git_pass(git_remote_lookup(&remote, _repo, "query")); cl_git_pass(git_remote_get_fetch_refspecs(&array, remote)); for (i = 0; i < 3; i++) { cl_assert_equal_s(fetch_refspecs[i], array.strings[i]); } git_strarray_free(&array); cl_git_pass(git_remote_get_push_refspecs(&array, remote)); for (i = 0; i < 3; i++) { cl_assert_equal_s(push_refspecs[i], array.strings[i]); } git_strarray_free(&array); git_remote_free(remote); git_remote_delete(_repo, "test"); }
static int store_refs(transport_local *t) { unsigned int i; git_strarray ref_names = {0}; git_transport *transport = (git_transport *) t; assert(t); if (git_reference_list(&ref_names, t->repo, GIT_REF_LISTALL) < 0 || git_vector_init(&transport->refs, (unsigned int)ref_names.count, NULL) < 0) goto on_error; /* Sort the references first */ git__tsort((void **)ref_names.strings, ref_names.count, &git__strcmp_cb); /* Add HEAD */ if (add_ref(t, GIT_HEAD_FILE) < 0) goto on_error; for (i = 0; i < ref_names.count; ++i) { if (add_ref(t, ref_names.strings[i]) < 0) goto on_error; } git_strarray_free(&ref_names); return 0; on_error: git_vector_free(&transport->refs); git_strarray_free(&ref_names); return -1; }
int git_remote_dup(git_remote **dest, git_remote *source) { int error = 0; git_strarray refspecs = { 0 }; git_remote *remote = git__calloc(1, sizeof(git_remote)); GITERR_CHECK_ALLOC(remote); if (source->name != NULL) { remote->name = git__strdup(source->name); GITERR_CHECK_ALLOC(remote->name); } if (source->url != NULL) { remote->url = git__strdup(source->url); GITERR_CHECK_ALLOC(remote->url); } if (source->pushurl != NULL) { remote->pushurl = git__strdup(source->pushurl); GITERR_CHECK_ALLOC(remote->pushurl); } remote->transport_cb = source->transport_cb; remote->transport_cb_payload = source->transport_cb_payload; remote->repo = source->repo; remote->download_tags = source->download_tags; remote->check_cert = source->check_cert; remote->update_fetchhead = source->update_fetchhead; if (git_vector_init(&remote->refs, 32, NULL) < 0 || git_vector_init(&remote->refspecs, 2, NULL) < 0 || git_vector_init(&remote->active_refspecs, 2, NULL) < 0) { error = -1; goto cleanup; } if ((error = git_remote_get_fetch_refspecs(&refspecs, source)) < 0 || (error = git_remote_set_fetch_refspecs(remote, &refspecs)) < 0) goto cleanup; git_strarray_free(&refspecs); if ((error = git_remote_get_push_refspecs(&refspecs, source)) < 0 || (error = git_remote_set_push_refspecs(remote, &refspecs)) < 0) goto cleanup; *dest = remote; cleanup: git_strarray_free(&refspecs); if (error < 0) git__free(remote); return error; }
void test_network_fetchlocal__prune(void) { git_repository *repo; git_remote *origin; int callcount = 0; git_strarray refnames = {0}; git_reference *ref; git_repository *remote_repo = cl_git_sandbox_init("testrepo.git"); const char *url = cl_git_path_url(git_repository_path(remote_repo)); git_fetch_options options = GIT_FETCH_OPTIONS_INIT; options.callbacks.transfer_progress = transfer_cb; options.callbacks.payload = &callcount; cl_set_cleanup(&cleanup_local_repo, "foo"); cl_git_pass(git_repository_init(&repo, "foo", true)); cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url)); cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL)); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(19, (int)refnames.count); cl_assert(callcount > 0); git_strarray_free(&refnames); git_remote_free(origin); cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/br2")); cl_git_pass(git_reference_delete(ref)); git_reference_free(ref); cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN)); cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL)); cl_git_pass(git_remote_prune(origin, &options.callbacks)); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(18, (int)refnames.count); git_strarray_free(&refnames); git_remote_free(origin); cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/packed")); cl_git_pass(git_reference_delete(ref)); git_reference_free(ref); cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN)); cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL)); cl_git_pass(git_remote_prune(origin, &options.callbacks)); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(17, (int)refnames.count); git_strarray_free(&refnames); git_remote_free(origin); git_repository_free(repo); }
void test_network_remote_rename__overwrite_ref_in_target(void) { git_oid id; char idstr[GIT_OID_HEXSZ + 1] = {0}; git_reference *ref; git_branch_t btype; git_branch_iterator *iter; git_strarray problems = {0}; cl_git_pass(git_oid_fromstr(&id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750")); cl_git_pass(git_reference_create(&ref, _repo, "refs/remotes/renamed/master", &id, 1, NULL, NULL)); git_reference_free(ref); cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "renamed")); cl_assert_equal_i(0, problems.count); git_strarray_free(&problems); /* make sure there's only one remote-tracking branch */ cl_git_pass(git_branch_iterator_new(&iter, _repo, GIT_BRANCH_REMOTE)); cl_git_pass(git_branch_next(&ref, &btype, iter)); cl_assert_equal_s("refs/remotes/renamed/master", git_reference_name(ref)); git_oid_fmt(idstr, git_reference_target(ref)); cl_assert_equal_s("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", idstr); git_reference_free(ref); cl_git_fail_with(GIT_ITEROVER, git_branch_next(&ref, &btype, iter)); git_branch_iterator_free(iter); }
void mne_git_load_blobs(const char *path) { mne_git_initialize(); printf("\nLoading blobs...\n\n"); gettimeofday(&begin, NULL); git_repository_open(&repo, path); git_repository_odb(&odb, repo); git_strarray tag_names; git_tag_list(&tag_names, repo); total_refs = tag_names.count + 1; /* + 1 for HEAD. */ ref_names = malloc(sizeof(char*) * total_refs); mne_git_walk_ctx ctx; ctx.bytes = 0; ctx.ref_index = 0; mne_git_walk_head(&ctx); mne_git_walk_tags(&ctx, &tag_names); git_strarray_free(&tag_names); git_repository_free(repo); gettimeofday(&end, NULL); float mb = ctx.bytes / 1048576.0; printf("\nLoaded %d blobs (%.2fmb) ", g_hash_table_size(blobs), mb); mne_print_duration(&end, &begin); printf(".\n"); }
/** * Give the remote a new name * * @param repo S4 class git_repository * @param oldname The old name of the remote * @param newname The new name of the remote * @return R_NilValue */ SEXP git2r_remote_rename(SEXP repo, SEXP oldname, SEXP newname) { int err; git_strarray problems = {0}; git_repository *repository = NULL; if (git2r_arg_check_string(oldname)) git2r_error(__func__, NULL, "'oldname'", git2r_err_string_arg); if (git2r_arg_check_string(newname)) git2r_error(__func__, NULL, "'newname'", git2r_err_string_arg); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); err = git_remote_rename( &problems, repository, CHAR(STRING_ELT(oldname, 0)), CHAR(STRING_ELT(newname, 0))); if (err) goto cleanup; git_strarray_free(&problems); cleanup: if (repository) git_repository_free(repository); if (err) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; }
PyObject * Repository_listall_references(Repository *self, PyObject *args) { git_strarray c_result; PyObject *py_result, *py_string; unsigned index; int err; /* Get the C result */ err = git_reference_list(&c_result, self->repo); if (err < 0) return Error_set(err); /* Create a new PyTuple */ py_result = PyList_New(c_result.count); if (py_result == NULL) goto out; /* Fill it */ for (index=0; index < c_result.count; index++) { py_string = to_path(c_result.strings[index]); if (py_string == NULL) { Py_CLEAR(py_result); goto out; } PyList_SET_ITEM(py_result, index, py_string); } out: git_strarray_free(&c_result); return py_result; }
/* * call-seq: * remote.check_connection(direction, options = {}) -> boolean * * Try to connect to the +remote+. Useful to simulate * <tt>git fetch --dry-run</tt> and <tt>git push --dry-run</tt>. * * Returns +true+ if connection is successful, +false+ otherwise. * * +direction+ must be either +:fetch+ or +:push+. * * The following options can be passed in the +options+ Hash: * * +credentials+ :: * The credentials to use for the connection. Can be either an instance of * one of the Rugged::Credentials types, or a proc returning one of the * former. * The proc will be called with the +url+, the +username+ from the url (if * applicable) and a list of applicable credential types. * * :headers :: * Extra HTTP headers to include with the request (only applies to http:// or https:// remotes) * * Example: * * remote = repo.remotes["origin"] * success = remote.check_connection(:fetch) * raise Error("Unable to pull without credentials") unless success */ static VALUE rb_git_remote_check_connection(int argc, VALUE *argv, VALUE self) { git_remote *remote; git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT; git_strarray custom_headers = {0}; struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 }; VALUE rb_direction, rb_options; ID id_direction; int error, direction; Data_Get_Struct(self, git_remote, remote); rb_scan_args(argc, argv, "01:", &rb_direction, &rb_options); Check_Type(rb_direction, T_SYMBOL); id_direction = SYM2ID(rb_direction); if (id_direction == rb_intern("fetch")) direction = GIT_DIRECTION_FETCH; else if (id_direction == rb_intern("push")) direction = GIT_DIRECTION_PUSH; else rb_raise(rb_eTypeError, "Invalid direction. Expected :fetch or :push"); rugged_remote_init_callbacks_and_payload_from_options(rb_options, &callbacks, &payload); init_custom_headers(rb_options, &custom_headers); error = git_remote_connect(remote, direction, &callbacks, NULL, &custom_headers); git_remote_disconnect(remote); git_strarray_free(&custom_headers); if (payload.exception) rb_jump_tag(payload.exception); return error ? Qfalse : Qtrue; }
/** * Give the remote a new name * * @param repo S4 class git_repository * @param oldname The old name of the remote * @param newname The new name of the remote * @return R_NilValue */ SEXP git2r_remote_rename(SEXP repo, SEXP oldname, SEXP newname) { int err; git_strarray problems = {0}; git_repository *repository = NULL; if (git2r_arg_check_string(oldname)) git2r_error(git2r_err_string_arg, __func__, "oldname"); if (git2r_arg_check_string(newname)) git2r_error(git2r_err_string_arg, __func__, "newname"); repository = git2r_repository_open(repo); if (!repository) git2r_error(git2r_err_invalid_repository, __func__, NULL); err = git_remote_rename( &problems, repository, CHAR(STRING_ELT(oldname, 0)), CHAR(STRING_ELT(newname, 0))); if (GIT_OK != err) goto cleanup; git_strarray_free(&problems); cleanup: if (repository) git_repository_free(repository); if (GIT_OK != err) git2r_error(git2r_err_from_libgit2, __func__, giterr_last()->message); return R_NilValue; }
/** * Get the configured remotes for a repo * * @param repo S4 class git_repository * @return Character vector with name of the remotes */ SEXP git2r_remote_list(SEXP repo) { int err; size_t i; git_strarray rem_list; SEXP list = R_NilValue; git_repository *repository; repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); err = git_remote_list(&rem_list, repository); if (err) goto cleanup; PROTECT(list = allocVector(STRSXP, rem_list.count)); for (i = 0; i < rem_list.count; i++) SET_STRING_ELT(list, i, mkChar(rem_list.strings[i])); cleanup: git_strarray_free(&rem_list); if (repository) git_repository_free(repository); if (R_NilValue != list) UNPROTECT(1); if (err) git2r_error(__func__, giterr_last(), NULL, NULL); return list; }
/* * call-seq: * remote.push(refspecs = nil, options = {}) -> hash * * Pushes the given +refspecs+ to the given +remote+. Returns a hash that contains * key-value pairs that reflect pushed refs and error messages, if applicable. * * You can optionally pass in an alternative list of +refspecs+ to use instead of the push * refspecs already configured for +remote+. * * The following options can be passed in the +options+ Hash: * * :credentials :: * The credentials to use for the push operation. Can be either an instance of one * of the Rugged::Credentials types, or a proc returning one of the former. * The proc will be called with the +url+, the +username+ from the url (if applicable) and * a list of applicable credential types. * * :update_tips :: * A callback that will be executed each time a reference is updated remotely. It will be * passed the +refname+, +old_oid+ and +new_oid+. * * :headers :: * Extra HTTP headers to include with the push (only applies to http:// or https:// remotes) * * Example: * * remote = Rugged::Remote.lookup(@repo, 'origin') * remote.push(["refs/heads/master", ":refs/heads/to_be_deleted"]) */ static VALUE rb_git_remote_push(int argc, VALUE *argv, VALUE self) { VALUE rb_refspecs, rb_options; git_remote *remote; git_strarray refspecs; git_push_options opts = GIT_PUSH_OPTIONS_INIT; int error = 0; struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, rb_hash_new(), 0 }; rb_scan_args(argc, argv, "01:", &rb_refspecs, &rb_options); rugged_rb_ary_to_strarray(rb_refspecs, &refspecs); Data_Get_Struct(self, git_remote, remote); rugged_remote_init_callbacks_and_payload_from_options(rb_options, &opts.callbacks, &payload); init_custom_headers(rb_options, &opts.custom_headers); error = git_remote_push(remote, &refspecs, &opts); xfree(refspecs.strings); git_strarray_free(&opts.custom_headers); if (payload.exception) rb_jump_tag(payload.exception); rugged_exception_check(error); return payload.result; }
void test_network_fetchlocal__complete(void) { git_repository *repo; git_remote *origin; int callcount = 0; git_strarray refnames = {0}; const char *url = cl_git_fixture_url("testrepo.git"); git_fetch_options options = GIT_FETCH_OPTIONS_INIT; options.callbacks.transfer_progress = transfer_cb; options.callbacks.payload = &callcount; cl_set_cleanup(&cleanup_local_repo, "foo"); cl_git_pass(git_repository_init(&repo, "foo", true)); cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url)); cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL)); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(19, (int)refnames.count); cl_assert(callcount > 0); git_strarray_free(&refnames); git_remote_free(origin); git_repository_free(repo); }
void test_refs_branches_listall__cleanup(void) { git_strarray_free(&branch_list); git_reference_free(fake_remote); git_repository_free(repo); cl_fixture_cleanup("testrepo.git"); }
void test_network_remotes__list(void) { git_strarray list; git_config *cfg; cl_git_pass(git_remote_list(&list, _repo)); cl_assert(list.count == 1); git_strarray_free(&list); cl_git_pass(git_repository_config(&cfg, _repo)); cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com")); cl_git_pass(git_remote_list(&list, _repo)); cl_assert(list.count == 2); git_strarray_free(&list); git_config_free(cfg); }
static void curls_free(git_stream *stream) { curl_stream *s = (curl_stream *) stream; curls_close(stream); git_strarray_free(&s->cert_info_strings); git__free(s); }
static int remote_name(git_buf *buf, git_repository *repo, const char *canonical_branch_name) { git_strarray remote_list = {0}; size_t i; git_remote *remote; const git_refspec *fetchspec; int error = 0; char *remote_name = NULL; assert(buf && repo && canonical_branch_name); /* Verify that this is a remote branch */ if (!git_reference__is_remote(canonical_branch_name)) { giterr_set(GITERR_INVALID, "Reference '%s' is not a remote branch.", canonical_branch_name); error = GIT_ERROR; goto cleanup; } /* Get the remotes */ if ((error = git_remote_list(&remote_list, repo)) < 0) goto cleanup; /* Find matching remotes */ for (i = 0; i < remote_list.count; i++) { if ((error = git_remote_load(&remote, repo, remote_list.strings[i])) < 0) continue; fetchspec = git_remote__matching_dst_refspec(remote, canonical_branch_name); if (fetchspec) { /* If we have not already set out yet, then set * it to the matching remote name. Otherwise * multiple remotes match this reference, and it * is ambiguous. */ if (!remote_name) { remote_name = remote_list.strings[i]; } else { git_remote_free(remote); error = GIT_EAMBIGUOUS; goto cleanup; } } git_remote_free(remote); } if (remote_name) { git_buf_clear(buf); error = git_buf_puts(buf, remote_name); } else { error = GIT_ENOTFOUND; } cleanup: git_strarray_free(&remote_list); return error; }
void test_refs_namespaces__namespace_doesnt_show_normal_refs(void) { static git_strarray ref_list; cl_git_pass(git_repository_set_namespace(g_repo, "namespace")); cl_git_pass(git_reference_list(&ref_list, g_repo)); cl_assert_equal_i(0, ref_list.count); git_strarray_free(&ref_list); }
void test_network_remote_rename__new_name_can_contain_dots(void) { git_strarray problems = {0}; cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just.renamed")); cl_assert_equal_i(0, problems.count); git_strarray_free(&problems); assert_config_entry_existence(_repo, "remote.just.renamed.fetch", true); }
void Gitarre::CheckRepoState(int i) { Repository *repo = Repos[i]; StatusCbData cbData = { this, i, Gitarre::Update }; git_strarray *pathspec = pathspecAll (); git_status_options cbOptns = { 1, GIT_STATUS_SHOW_INDEX_AND_WORKDIR, GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_INCLUDE_IGNORED | GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS, *pathspec }; git_status_foreach_ext (repo->GetGitRepo(), &cbOptns, Gitarre::sStatusCb, (void *)&cbData); git_strarray_free (pathspec); }
/* * call-seq: * remote.fetch(refspecs = nil, options = {}) -> hash * * Downloads new data from the remote for the given +refspecs+ and updates tips. * * You can optionally pass in a single or multiple alternative +refspecs+ to use instead of the fetch * refspecs already configured for +remote+. * * Returns a hash containing statistics for the fetch operation. * * The following options can be passed in the +options+ Hash: * * :credentials :: * The credentials to use for the fetch operation. Can be either an instance of one * of the Rugged::Credentials types, or a proc returning one of the former. * The proc will be called with the +url+, the +username+ from the url (if applicable) and * a list of applicable credential types. * * :headers :: * Extra HTTP headers to include with the request (only applies to http:// or https:// remotes) * * :progress :: * A callback that will be executed with the textual progress received from the remote. * This is the text send over the progress side-band (ie. the "counting objects" output). * * :transfer_progress :: * A callback that will be executed to report clone progress information. It will be passed * the amount of +total_objects+, +indexed_objects+, +received_objects+, +local_objects+, * +total_deltas+, +indexed_deltas+ and +received_bytes+. * * :update_tips :: * A callback that will be executed each time a reference is updated locally. It will be * passed the +refname+, +old_oid+ and +new_oid+. * * :certificate_check :: * A callback that will be executed each time we validate a certificate using https. It * will be passed the +valid+, +host_name+ and the callback should return a true/false to * indicate if the certificate has been validated. * * :message :: * The message to insert into the reflogs. Defaults to "fetch". * * :prune :: * Specifies the prune mode for the fetch. +true+ remove any remote-tracking references that * no longer exist, +false+ do not prune, +nil+ use configured settings Defaults to "nil". * * Example: * * remote = Rugged::Remote.lookup(@repo, 'origin') * remote.fetch({ * transfer_progress: lambda { |total_objects, indexed_objects, received_objects, local_objects, total_deltas, indexed_deltas, received_bytes| * # ... * } * }) */ static VALUE rb_git_remote_fetch(int argc, VALUE *argv, VALUE self) { git_remote *remote; git_strarray refspecs; git_fetch_options opts = GIT_FETCH_OPTIONS_INIT; const git_transfer_progress *stats; struct rugged_remote_cb_payload payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 }; char *log_message = NULL; int error; VALUE rb_options, rb_refspecs, rb_result = Qnil; rb_scan_args(argc, argv, "01:", &rb_refspecs, &rb_options); rugged_rb_ary_to_strarray(rb_refspecs, &refspecs); Data_Get_Struct(self, git_remote, remote); rugged_remote_init_callbacks_and_payload_from_options(rb_options, &opts.callbacks, &payload); init_custom_headers(rb_options, &opts.custom_headers); if (!NIL_P(rb_options)) { VALUE rb_prune_type; VALUE rb_val = rb_hash_aref(rb_options, CSTR2SYM("message")); if (!NIL_P(rb_val)) log_message = StringValueCStr(rb_val); rb_prune_type = rb_hash_aref(rb_options, CSTR2SYM("prune")); opts.prune = parse_prune_type(rb_prune_type); } error = git_remote_fetch(remote, &refspecs, &opts, log_message); xfree(refspecs.strings); git_strarray_free(&opts.custom_headers); if (payload.exception) rb_jump_tag(payload.exception); rugged_exception_check(error); stats = git_remote_stats(remote); rb_result = rb_hash_new(); rb_hash_aset(rb_result, CSTR2SYM("total_objects"), UINT2NUM(stats->total_objects)); rb_hash_aset(rb_result, CSTR2SYM("indexed_objects"), UINT2NUM(stats->indexed_objects)); rb_hash_aset(rb_result, CSTR2SYM("received_objects"), UINT2NUM(stats->received_objects)); rb_hash_aset(rb_result, CSTR2SYM("local_objects"), UINT2NUM(stats->local_objects)); rb_hash_aset(rb_result, CSTR2SYM("total_deltas"), UINT2NUM(stats->total_deltas)); rb_hash_aset(rb_result, CSTR2SYM("indexed_deltas"), UINT2NUM(stats->indexed_deltas)); rb_hash_aset(rb_result, CSTR2SYM("received_bytes"), INT2FIX(stats->received_bytes)); return rb_result; }
void test_network_remote_rename__renaming_a_remote_updates_default_fetchrefspec(void) { git_strarray problems = {0}; cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed")); cl_assert_equal_i(0, problems.count); git_strarray_free(&problems); assert_config_entry_value(_repo, "remote.just/renamed.fetch", "+refs/heads/*:refs/remotes/just/renamed/*"); }
void test_refs_listall__from_repository_with_no_trailing_newline(void) { cl_git_pass(git_repository_open(&repo, cl_fixture("bad_tag.git"))); cl_git_pass(git_reference_list(&ref_list, repo)); cl_assert(ref_list.count > 0); git_strarray_free(&ref_list); git_repository_free(repo); }
void test_object_tag_list__list_all(void) { // list all tag names from the repository git_strarray tag_list; cl_git_pass(git_tag_list(&tag_list, g_repo)); cl_assert_equal_i((int)tag_list.count, 6); git_strarray_free(&tag_list); }
void test_network_remote_rename__renaming_a_remote_notifies_of_non_default_fetchrefspec(void) { git_config *config; git_remote *remote; git_strarray problems = {0}; cl_git_pass(git_repository_config__weakptr(&config, _repo)); cl_git_pass(git_config_set_string(config, "remote.test.fetch", "+refs/*:refs/*")); cl_git_pass(git_remote_lookup(&remote, _repo, "test")); git_remote_free(remote); cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed")); cl_assert_equal_i(1, problems.count); cl_assert_equal_s("+refs/*:refs/*", problems.strings[0]); git_strarray_free(&problems); assert_config_entry_value(_repo, "remote.just/renamed.fetch", "+refs/*:refs/*"); git_strarray_free(&problems); }
void test_object_tag_read__list(void) { // list all tag names from the repository git_strarray tag_list; cl_git_pass(git_tag_list(&tag_list, g_repo)); cl_assert(tag_list.count == 3); git_strarray_free(&tag_list); }
static int count_references(void) { git_strarray array; int refs; cl_git_pass(git_reference_list(&array, g_repo)); refs = array.count; git_strarray_free(&array); return refs; }
void test_clone_nonetwork__custom_autotag(void) { git_strarray tags = {0}; g_options.remote_autotag = GIT_REMOTE_DOWNLOAD_TAGS_NONE; cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options)); cl_git_pass(git_tag_list(&tags, g_repo)); cl_assert_equal_sz(0, tags.count); git_strarray_free(&tags); }