]> git.proxmox.com Git - libgit2.git/commitdiff
Don't free config in `git_transaction_commit`.
authorArthur Schreiber <schreiber.arthur@googlemail.com>
Sun, 13 Sep 2015 14:32:24 +0000 (16:32 +0200)
committerArthur Schreiber <schreiber.arthur@googlemail.com>
Sun, 13 Sep 2015 14:32:24 +0000 (16:32 +0200)
The config is not owned by the transaction, so please don’t free it.

src/transaction.c
tests/config/write.c

index e9639bf970ec42114334e1c9c81d57abd6d22704..92e134e5bb01e9967d0d94e1b86383175cc64b9f 100644 (file)
@@ -331,7 +331,6 @@ int git_transaction_commit(git_transaction *tx)
 
        if (tx->type == TRANSACTION_CONFIG) {
                error = git_config_unlock(tx->cfg, true);
-               git_config_free(tx->cfg);
                tx->cfg = NULL;
 
                return error;
index 3d9b1a16aa472e9754ede425b48efa06b8a66469..9ad11ab273a60548c9f74ddcefc7b82dec81a230 100644 (file)
@@ -670,6 +670,16 @@ void test_config_write__locking(void)
        git_transaction_free(tx);
 
        /* Now that we've unlocked it, we should see both updates */
+       cl_git_pass(git_config_get_entry(&entry, cfg, "section.name"));
+       cl_assert_equal_s("other value", entry->value);
+       git_config_entry_free(entry);
+       cl_git_pass(git_config_get_entry(&entry, cfg, "section2.name3"));
+       cl_assert_equal_s("more value", entry->value);
+       git_config_entry_free(entry);
+
+       git_config_free(cfg);
+
+       /* We should also see the changes after reopening the config */
        cl_git_pass(git_config_open_ondisk(&cfg, filename));
        cl_git_pass(git_config_get_entry(&entry, cfg, "section.name"));
        cl_assert_equal_s("other value", entry->value);