summaryrefslogtreecommitdiff
path: root/object-store.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-11-12 14:49:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-13 05:22:02 (GMT)
commitf3f043a103b7a7da57272ecf3252bda6089e41ae (patch)
tree1e20f944f65f62442976d3d1cf566bec0a89ccb7 /object-store.h
parentb69fb867b4bb9e30e705d2176fe8a0a90b208325 (diff)
downloadgit-f3f043a103b7a7da57272ecf3252bda6089e41ae.zip
git-f3f043a103b7a7da57272ecf3252bda6089e41ae.tar.gz
git-f3f043a103b7a7da57272ecf3252bda6089e41ae.tar.bz2
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 'object-store.h')
-rw-r--r--object-store.h14
1 files changed, 1 insertions, 13 deletions
diff --git a/object-store.h b/object-store.h
index fefa17e..b2fa0d0 100644
--- a/object-store.h
+++ b/object-store.h
@@ -10,10 +10,6 @@
struct object_directory {
struct object_directory *next;
- /* see alt_scratch_buf() */
- struct strbuf scratch;
- size_t base_len;
-
/*
* Used to store the results of readdir(3) calls when searching
* for unique abbreviated hashes. This cache is never
@@ -54,14 +50,6 @@ void add_to_alternates_file(const char *dir);
*/
void add_to_alternates_memory(const char *dir);
-/*
- * Returns a scratch strbuf pre-filled with the alternate object directory,
- * including a trailing slash, which can be used to access paths in the
- * alternate. Always use this over direct access to alt->scratch, as it
- * cleans up any previous use of the scratch buffer.
- */
-struct strbuf *alt_scratch_buf(struct object_directory *odb);
-
struct packed_git {
struct packed_git *next;
struct list_head mru;
@@ -157,7 +145,7 @@ void raw_object_store_clear(struct raw_object_store *o);
* Put in `buf` the name of the file in the local object database that
* would be used to store a loose object with the specified sha1.
*/
-void loose_object_path(struct repository *r, struct strbuf *buf, const unsigned char *sha1);
+const char *loose_object_path(struct repository *r, struct strbuf *buf, const unsigned char *sha1);
void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);