Skip to content

Commit a9fc14b

Browse files
committed
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.
1 parent 74471ee commit a9fc14b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/branch.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ int git_branch_create(
123123
const git_commit *commit,
124124
int force)
125125
{
126-
return create_branch(ref_out, repository, branch_name, commit, git_oid_tostr_s(git_commit_id(commit)), force);
126+
char commit_id[GIT_OID_HEXSZ + 1];
127+
128+
git_oid_tostr(commit_id, GIT_OID_HEXSZ + 1, git_commit_id(commit));
129+
return create_branch(ref_out, repository, branch_name, commit, commit_id, force);
127130
}
128131

129132
int git_branch_create_from_annotated(

src/reset.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ int git_reset(
188188
git_reset_t reset_type,
189189
const git_checkout_options *checkout_opts)
190190
{
191-
return reset(repo, target, git_oid_tostr_s(git_object_id(target)), reset_type, checkout_opts);
191+
char to[GIT_OID_HEXSZ + 1];
192+
193+
git_oid_tostr(to, GIT_OID_HEXSZ + 1, git_object_id(target));
194+
return reset(repo, target, to, reset_type, checkout_opts);
192195
}
193196

194197
int git_reset_from_annotated(

0 commit comments

Comments
 (0)