mirror of
https://github.com/git/git
synced 2024-10-30 14:03:28 +00:00
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>
This commit is contained in:
parent
8c5acfb923
commit
07af889136
1 changed files with 1 additions and 7 deletions
|
@ -135,8 +135,6 @@ static int too_many_loose_objects(void)
|
||||||
* distributed, we can check only one and get a reasonable
|
* distributed, we can check only one and get a reasonable
|
||||||
* estimate.
|
* estimate.
|
||||||
*/
|
*/
|
||||||
char path[PATH_MAX];
|
|
||||||
const char *objdir = get_object_directory();
|
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
int auto_threshold;
|
int auto_threshold;
|
||||||
|
@ -146,11 +144,7 @@ static int too_many_loose_objects(void)
|
||||||
if (gc_auto_threshold <= 0)
|
if (gc_auto_threshold <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (sizeof(path) <= snprintf(path, sizeof(path), "%s/17", objdir)) {
|
dir = opendir(git_path("objects/17"));
|
||||||
warning(_("insanely long object directory %.*s"), 50, objdir);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
dir = opendir(path);
|
|
||||||
if (!dir)
|
if (!dir)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue