GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const char *value);
/**
- * Perform an operation on each config variable
+ * Delete a config variable
+ *
+ * @param cfg the configuration
+ * @param name the variable to delete
+ */
+GIT_EXTERN(int) git_config_del(git_config *cfg, const char *name);
+
+/**
+ * Perform an operation on each config variable.
*
* The callback receives the normalized name and value of each variable
* in the config backend, and the data pointer passed to this function.
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_del(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_del(cfg, "core.imaginary") == GIT_ENOTFOUND);
+ git_config_free(cfg);
+END_TEST
+
BEGIN_SUITE(config)
ADD_TEST(config0);
ADD_TEST(config1);
ADD_TEST(config9);
ADD_TEST(config10);
ADD_TEST(config11);
+ ADD_TEST(config12);
+ ADD_TEST(config13);
END_SUITE