summaryrefslogtreecommitdiff
path: root/builtin/gc.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-03-28 19:47:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-30 21:59:50 (GMT)
commit07af88913662f1179ba34b92370a6df24263ae5f (patch)
tree76762bdb7f353d1bdfb1e32e82a22cfa9cb80981 /builtin/gc.c
parent8c5acfb923a94dc746baa4eef8454cb4c4f18270 (diff)
downloadgit-07af88913662f1179ba34b92370a6df24263ae5f.zip
git-07af88913662f1179ba34b92370a6df24263ae5f.tar.gz
git-07af88913662f1179ba34b92370a6df24263ae5f.tar.bz2
gc: replace local buffer with git_path
We probe the "17/" loose object directory for auto-gc, and use a local buffer to format the path. We can just use git_path() for this. It handles paths of any length (reducing our error handling). And because we feed the result straight to a system call, we can just use the static variant. Note that git_path also knows the string "objects/" is special, and will replace it with git_object_directory() when necessary. Another alternative would be to use sha1_file_name() for the pretend object "170000...", but that ends up being more hassle for no gain, as we have to truncate the final path component. Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'builtin/gc.c')
-rw-r--r--builtin/gc.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index c2c61a5..2daede7 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -135,8 +135,6 @@ static int too_many_loose_objects(void)
* distributed, we can check only one and get a reasonable
* estimate.
*/
- char path[PATH_MAX];
- const char *objdir = get_object_directory();
DIR *dir;
struct dirent *ent;
int auto_threshold;
@@ -146,11 +144,7 @@ static int too_many_loose_objects(void)
if (gc_auto_threshold <= 0)
return 0;
- if (sizeof(path) <= snprintf(path, sizeof(path), "%s/17", objdir)) {
- warning(_("insanely long object directory %.*s"), 50, objdir);
- return 0;
- }
- dir = opendir(path);
+ dir = opendir(git_path("objects/17"));
if (!dir)
return 0;