summaryrefslogtreecommitdiff
path: root/server-info.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-06-17 10:15:15 -0700
committerJunio C Hamano <gitster@pobox.com>2019-06-17 10:15:15 -0700
commit63b6b4b7e107d5b40620d0b3dc3efff0284dfb7b (patch)
tree57735557a3950c3dcba0f3d8c8aedb705c2ff63e /server-info.c
parentac97dc4fa9869146f774f6df854e23afb38e15cd (diff)
parente941c48d49ebe24404515acf258d8003f2374627 (diff)
downloadgit-63b6b4b7e107d5b40620d0b3dc3efff0284dfb7b.tar.gz
Merge branch 'ew/server-info-remove-crufts'
"git update-server-info" used to leave stale packfiles in its output, which has been corrected. * ew/server-info-remove-crufts: server-info: do not list unlinked packs
Diffstat (limited to 'server-info.c')
-rw-r--r--server-info.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/server-info.c b/server-info.c
index e68f785c2f..4d8199b1d9 100644
--- a/server-info.c
+++ b/server-info.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "dir.h"
#include "repository.h"
#include "refs.h"
#include "object.h"
@@ -283,26 +284,21 @@ static void init_pack_info(const char *infofile, int force)
{
struct packed_git *p;
int stale;
- int i = 0;
+ int i;
+ size_t alloc = 0;
for (p = get_all_packs(the_repository); p; p = p->next) {
/* we ignore things on alternate path since they are
* not available to the pullers in general.
*/
- if (!p->pack_local)
- continue;
- i++;
- }
- num_pack = i;
- info = xcalloc(num_pack, sizeof(struct pack_info *));
- for (i = 0, p = get_all_packs(the_repository); p; p = p->next) {
- if (!p->pack_local)
+ if (!p->pack_local || !file_exists(p->pack_name))
continue;
- assert(i < num_pack);
+
+ i = num_pack++;
+ ALLOC_GROW(info, num_pack, alloc);
info[i] = xcalloc(1, sizeof(struct pack_info));
info[i]->p = p;
info[i]->old_num = -1;
- i++;
}
if (infofile && !force)