Skip to content

Commit

Permalink
Merge pull request #3424 from arthurschreiber/arthur/transaction-dont…
Browse files Browse the repository at this point in the history
…-free-config

Don't free config in `git_transaction_commit`.
  • Loading branch information
carlosmn committed Sep 13, 2015
2 parents 1e80bf2 + 548cb33 commit 9562ebc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/transaction.c
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions tests/config/write.c
Expand Up @@ -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);
Expand Down

0 comments on commit 9562ebc

Please sign in to comment.