summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-01-21 19:43:42 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2022-01-22 14:28:34 -0500
commite49aa1c4824fb9412ab32eb4fbffdc0c2fc7a486 (patch)
treed5b919f72d633f357969878ee46872c93c94ab0e
parent3f0b00f7d4c8ec61c9133dfff12771b04fc558f3 (diff)
downloadlibgit2-e49aa1c4824fb9412ab32eb4fbffdc0c2fc7a486.tar.gz
oid: avoid `tostr_s` in many places
The `git_oid_tostr_s` helper is indeed helpful, unless you are using printf debugging (by inserting more `git_oid_tostr_s` calls) shortly after using it. Avoid it before invoking complex functions.
-rw-r--r--src/branch.c7
-rw-r--r--src/reset.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/src/branch.c b/src/branch.c
index 03892a4b0..cc42903f2 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -123,7 +123,12 @@ int git_branch_create(
const git_commit *commit,
int force)
{
- return create_branch(ref_out, repository, branch_name, commit, git_oid_tostr_s(git_commit_id(commit)), force);
+ char commit_id[GIT_OID_HEXSZ + 1];
+
+ if (git_oid_tostr(commit_id, GIT_OID_HEXSZ + 1, git_commit_id(commit)) < 0)
+ return -1;
+
+ return create_branch(ref_out, repository, branch_name, commit, commit_id, force);
}
int git_branch_create_from_annotated(
diff --git a/src/reset.c b/src/reset.c
index b8327fe5e..5c645f23a 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -188,7 +188,12 @@ int git_reset(
git_reset_t reset_type,
const git_checkout_options *checkout_opts)
{
- return reset(repo, target, git_oid_tostr_s(git_object_id(target)), reset_type, checkout_opts);
+ char to[GIT_OID_HEXSZ + 1];
+
+ if (git_oid_tostr(to, GIT_OID_HEXSZ + 1, git_object_id(target)) < 0)
+ return -1;
+
+ return reset(repo, target, to, reset_type, checkout_opts);
}
int git_reset_from_annotated(