summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/diff_tform.c4
-rw-r--r--src/rebase.c4
-rw-r--r--src/refs.c10
-rw-r--r--src/repository.c3
-rw-r--r--tests/config/include.c1
-rw-r--r--tests/reset/hard.c2
-rw-r--r--tests/reset/mixed.c2
7 files changed, 19 insertions, 7 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c
index 8ee568cf4..06c12308b 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -277,7 +277,7 @@ static int normalize_find_opts(
if (!given ||
(given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG)
{
- const char *rule =
+ char *rule =
git_config__get_string_force(cfg, "diff.renames", "true");
int boolval;
@@ -287,6 +287,8 @@ static int normalize_find_opts(
opts->flags |= GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES;
else
opts->flags |= GIT_DIFF_FIND_RENAMES;
+
+ git__free(rule);
}
/* some flags imply others */
diff --git a/src/rebase.c b/src/rebase.c
index 43945df15..eb25d4c3a 100644
--- a/src/rebase.c
+++ b/src/rebase.c
@@ -466,11 +466,11 @@ static int rebase_normalize_opts(
opts->rewrite_notes_ref = git__strdup(given_opts->rewrite_notes_ref);
GITERR_CHECK_ALLOC(opts->rewrite_notes_ref);
} else if (git_config__get_bool_force(config, "notes.rewrite.rebase", 1)) {
- const char *rewrite_ref = git_config__get_string_force(
+ char *rewrite_ref = git_config__get_string_force(
config, "notes.rewriteref", NOTES_DEFAULT_REF);
if (rewrite_ref) {
- opts->rewrite_notes_ref = git__strdup(rewrite_ref);
+ opts->rewrite_notes_ref = rewrite_ref;
GITERR_CHECK_ALLOC(opts->rewrite_notes_ref);
}
}
diff --git a/src/refs.c b/src/refs.c
index 3f6c33dcd..360e65373 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1075,7 +1075,7 @@ int git_reference__update_terminal(
const git_signature *sig,
const char *log_message)
{
- git_reference *ref = NULL;
+ git_reference *ref = NULL, *ref2 = NULL;
git_signature *who = NULL;
const git_signature *to_use;
int error = 0;
@@ -1090,18 +1090,20 @@ int git_reference__update_terminal(
if (error == GIT_ENOTFOUND && ref) {
assert(git_reference_type(ref) == GIT_REF_SYMBOLIC);
giterr_clear();
- error = reference__create(&ref, repo, ref->target.symbolic, oid, NULL, 0, to_use,
+ error = reference__create(&ref2, repo, ref->target.symbolic, oid, NULL, 0, to_use,
log_message, NULL, NULL);
} else if (error == GIT_ENOTFOUND) {
giterr_clear();
- error = reference__create(&ref, repo, ref_name, oid, NULL, 0, to_use,
+ error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use,
log_message, NULL, NULL);
} else if (error == 0) {
assert(git_reference_type(ref) == GIT_REF_OID);
- error = reference__create(&ref, repo, ref->name, oid, NULL, 1, to_use,
+ error = reference__create(&ref2, repo, ref->name, oid, NULL, 1, to_use,
log_message, &ref->target.oid, NULL);
}
+ git_reference_free(ref2);
+ git_reference_free(ref);
git_signature_free(who);
return error;
}
diff --git a/src/repository.c b/src/repository.c
index 43d3aeaea..e9d74b7df 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1948,6 +1948,7 @@ int git_repository_set_head(
}
cleanup:
+ git_buf_free(&log_message);
git_reference_free(current);
git_reference_free(ref);
git_reference_free(new_head);
@@ -1980,6 +1981,7 @@ int git_repository_set_head_detached(
error = git_reference_create(&new_head, repo, GIT_HEAD_FILE, git_object_id(peeled), true, git_buf_cstr(&log_message));
cleanup:
+ git_buf_free(&log_message);
git_object_free(object);
git_object_free(peeled);
git_reference_free(current);
@@ -2012,6 +2014,7 @@ int git_repository_detach_head(git_repository* repo)
1, git_buf_cstr(&log_message));
cleanup:
+ git_buf_free(&log_message);
git_object_free(object);
git_reference_free(old_head);
git_reference_free(new_head);
diff --git a/tests/config/include.c b/tests/config/include.c
index e9f542afe..882b89b16 100644
--- a/tests/config/include.c
+++ b/tests/config/include.c
@@ -128,5 +128,6 @@ void test_config_include__depth2(void)
cl_git_pass(git_config_get_string_buf(&buf, cfg, "foo.bar2"));
cl_assert_equal_s("baz2", git_buf_cstr(&buf));
+ git_buf_free(&buf);
git_config_free(cfg);
}
diff --git a/tests/reset/hard.c b/tests/reset/hard.c
index f21ea9f15..f6ca1037b 100644
--- a/tests/reset/hard.c
+++ b/tests/reset/hard.c
@@ -221,4 +221,6 @@ void test_reset_hard__reflog_is_correct(void)
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
reflog_check(repo, "HEAD", 4, NULL, git_buf_cstr(&buf));
reflog_check(repo, "refs/heads/master", 4, NULL, git_buf_cstr(&buf));
+
+ git_buf_free(&buf);
}
diff --git a/tests/reset/mixed.c b/tests/reset/mixed.c
index 5b42ebca5..b374902aa 100644
--- a/tests/reset/mixed.c
+++ b/tests/reset/mixed.c
@@ -72,4 +72,6 @@ void test_reset_mixed__reflog_is_correct(void)
cl_git_pass(git_reset(repo, target, GIT_RESET_MIXED, NULL));
reflog_check(repo, "HEAD", 10, NULL, git_buf_cstr(&buf));
reflog_check(repo, "refs/heads/master", 10, NULL, git_buf_cstr(&buf));
+
+ git_buf_free(&buf);
}