Skip to content

Commit 57121a2

Browse files
committed
repository: clear out-parameter instead of freeing it
The `path` out-parameter of `find_repo` is being sanitized initially such that we do not try to append to existing content. The sanitization is done via `git_buf_free`, though, which forces us to needlessly reallocate the buffer later in the function. Fix this by using `git_buf_clear` instead.
1 parent e526fbc commit 57121a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/repository.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static int find_repo(
440440
bool in_dot_git;
441441
size_t ceiling_offset = 0;
442442

443-
git_buf_free(repo_path);
443+
git_buf_clear(repo_path);
444444

445445
error = git_path_prettify(&path, start_path, NULL);
446446
if (error < 0)

0 commit comments

Comments
 (0)