diff options
author | Jeff King <peff@peff.net> | 2018-11-12 09:49:35 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-13 14:22:02 +0900 |
commit | f3f043a103b7a7da57272ecf3252bda6089e41ae (patch) | |
tree | 1e20f944f65f62442976d3d1cf566bec0a89ccb7 /environment.c | |
parent | sha1_file_name(): overwrite buffer instead of appending (diff) | |
download | tgif-f3f043a103b7a7da57272ecf3252bda6089e41ae.tar.xz |
handle alternates paths the same as the main object dir
When we generate loose file paths for the main object directory, the
caller provides a buffer to loose_object_path (formerly sha1_file_name).
The callers generally keep their own static buffer to avoid excessive
reallocations.
But for alternate directories, each struct carries its own scratch
buffer. This is needlessly different; let's unify them.
We could go either direction here, but this patch moves the alternates
struct over to the main directory style (rather than vice-versa).
Technically the alternates style is more efficient, as it avoids
rewriting the object directory name on each call. But this is unlikely
to matter in practice, as we avoid reallocations either way (and nobody
has ever noticed or complained that the main object directory is copying
a few extra bytes before making a much more expensive system call).
And this has the advantage that the reusable buffers are tied to
particular calls, which makes the invalidation rules simpler (for
example, the return value from stat_sha1_file() used to be invalidated
by basically any other object call, but now it is affected only by other
calls to stat_sha1_file()).
We do steal the trick from alt_sha1_path() of returning a pointer to the
filled buffer, which makes a few conversions more convenient.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'environment.c')
0 files changed, 0 insertions, 0 deletions