mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-15 00:21:26 -05:00
refs: drop local buffer in refs_compute_filesystem_location()
We're using a local buffer in `refs_compute_filesystem_location()` that is only used so that we can fill it and then call `strbuf_realpath()` on its result. This roundtrip isn't necessary though: `strbuf_realpath()` already knows to use a single buffer as both input and output at the same time. So all this does is to add a bit of confusion and an extra memory allocation. Drop the local buffer. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
238191ecfc
commit
707197c159
8
refs.c
8
refs.c
@@ -3571,8 +3571,6 @@ void refs_compute_filesystem_location(const char *gitdir, const char *payload,
|
||||
bool *is_worktree, struct strbuf *refdir,
|
||||
struct strbuf *ref_common_dir)
|
||||
{
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
*is_worktree = get_common_dir_noenv(ref_common_dir, gitdir);
|
||||
|
||||
if (!payload) {
|
||||
@@ -3586,8 +3584,8 @@ void refs_compute_filesystem_location(const char *gitdir, const char *payload,
|
||||
}
|
||||
|
||||
if (!is_absolute_path(payload)) {
|
||||
strbuf_addf(&sb, "%s/%s", ref_common_dir->buf, payload);
|
||||
strbuf_realpath(ref_common_dir, sb.buf, 1);
|
||||
strbuf_addf(ref_common_dir, "/%s", payload);
|
||||
strbuf_realpath(ref_common_dir, ref_common_dir->buf, 1);
|
||||
} else {
|
||||
strbuf_realpath(ref_common_dir, payload, 1);
|
||||
}
|
||||
@@ -3600,6 +3598,4 @@ void refs_compute_filesystem_location(const char *gitdir, const char *payload,
|
||||
BUG("worktree path does not contain slash");
|
||||
strbuf_addf(refdir, "/worktrees/%s", wt_id + 1);
|
||||
}
|
||||
|
||||
strbuf_release(&sb);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user