static int delete_one_config( const char *var_name, const char *value, void *payload) { git_config *cfg = payload; GIT_UNUSED(value); return git_config_delete(cfg, var_name); }
int Config_setitem(Config *self, PyObject *py_key, PyObject *py_value) { int err; char *c_key; char *py_str; if (!(c_key = py_str_to_c_str(py_key,NULL))) return -1; if (!py_value) { err = git_config_delete(self->config, c_key); } else if (PyBool_Check(py_value)) { err = git_config_set_bool(self->config, c_key, (int)PyObject_IsTrue(py_value)); } else if (PyInt_Check(py_value)) { err = git_config_set_int64(self->config, c_key, (int64_t)PyInt_AsLong(py_value)); } else { py_value = PyObject_Str(py_value); py_str = py_str_to_c_str(py_value,NULL); err = git_config_set_string(self->config, c_key, py_str); free(py_str); } free(c_key); if (err < 0) { Error_set(err); return -1; } return 0; }
void test_notes_notesref__config_corenotesref(void) { git_oid oid, note_oid; const char *default_ref; cl_git_pass(git_signature_now(&_sig, "alice", "*****@*****.**")); cl_git_pass(git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479")); cl_git_pass(git_repository_config(&_cfg, _repo)); cl_git_pass(git_config_set_string(_cfg, "core.notesRef", "refs/notes/mydefaultnotesref")); cl_git_pass(git_note_create(¬e_oid, _repo, _sig, _sig, NULL, &oid, "test123test\n")); cl_git_pass(git_note_read(&_note, _repo, NULL, &oid)); cl_assert(!strcmp(git_note_message(_note), "test123test\n")); cl_assert(!git_oid_cmp(git_note_oid(_note), ¬e_oid)); git_note_free(_note); cl_git_pass(git_note_read(&_note, _repo, "refs/notes/mydefaultnotesref", &oid)); cl_assert(!strcmp(git_note_message(_note), "test123test\n")); cl_assert(!git_oid_cmp(git_note_oid(_note), ¬e_oid)); cl_git_pass(git_note_default_ref(&default_ref, _repo)); cl_assert(!strcmp(default_ref, "refs/notes/mydefaultnotesref")); cl_git_pass(git_config_delete(_cfg, "core.notesRef")); cl_git_pass(git_note_default_ref(&default_ref, _repo)); cl_assert(!strcmp(default_ref, GIT_NOTES_DEFAULT_REF)); }
void test_config_write__delete_inexistent(void) { git_config *cfg; cl_git_pass(git_config_open_ondisk(&cfg, "config9")); cl_assert(git_config_delete(cfg, "core.imaginary") == GIT_ENOTFOUND); git_config_free(cfg); }
void test_network_remoterename__renaming_a_remote_without_a_fetchrefspec_doesnt_create_one(void) { git_config *config; git_remote_free(_remote); cl_git_pass(git_repository_config__weakptr(&config, _repo)); cl_git_pass(git_config_delete(config, "remote.test.fetch")); cl_git_pass(git_remote_load(&_remote, _repo, "test")); assert_config_entry_existence(_repo, "remote.test.fetch", false); cl_git_pass(git_remote_rename(_remote, "just/renamed", dont_call_me_cb, NULL)); assert_config_entry_existence(_repo, "remote.just/renamed.fetch", false); }
void test_config_write__delete_value(void) { git_config *cfg; int32_t i; cl_git_pass(git_config_open_ondisk(&cfg, "config9")); cl_git_pass(git_config_set_int32(cfg, "core.dummy", 5)); git_config_free(cfg); cl_git_pass(git_config_open_ondisk(&cfg, "config9")); cl_git_pass(git_config_delete(cfg, "core.dummy")); git_config_free(cfg); cl_git_pass(git_config_open_ondisk(&cfg, "config9")); cl_assert(git_config_get_int32(&i, cfg, "core.dummy") == GIT_ENOTFOUND); cl_git_pass(git_config_set_int32(cfg, "core.dummy", 1)); git_config_free(cfg); }
must_be_true(num == 2); git_config_free(cfg); git_repository_free(repo); END_TEST BEGIN_TEST(config12, "delete a value") git_config *cfg; int i; /* By freeing the config, we make sure we flush the values */ must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9")); must_pass(git_config_set_int(cfg, "core.dummy", 5)); git_config_free(cfg); must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9")); must_pass(git_config_delete(cfg, "core.dummy")); git_config_free(cfg); must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9")); must_be_true(git_config_get_int(cfg, "core.dummy", &i) == GIT_ENOTFOUND); must_pass(git_config_set_int(cfg, "core.dummy", 1)); git_config_free(cfg); END_TEST BEGIN_TEST(config13, "can't delete a non-existent value") git_config *cfg; /* By freeing the config, we make sure we flush the values */ must_pass(git_config_open_ondisk(&cfg, CONFIG_BASE "/config9")); must_be_true(git_config_delete(cfg, "core.imaginary") == GIT_ENOTFOUND); git_config_free(cfg);