#include "cache.h"
+#include "dir.h"
#include "repository.h"
#include "refs.h"
#include "object.h"
return for_each_ref(add_info_ref, fp);
}
-static int update_info_refs(int force)
+static int update_info_refs(void)
{
char *path = git_pathdup("info/refs");
int ret = update_info_file(path, generate_info_refs);
{
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)
*/
int errs = 0;
- errs = errs | update_info_refs(force);
+ errs = errs | update_info_refs();
errs = errs | update_info_packs(force);
/* remove leftover rev-cache file if there is any */