Skip to content

Commit 63b6b4b

Browse files
committed
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
2 parents ac97dc4 + e941c48 commit 63b6b4b

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

server-info.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "cache.h"
2+
#include "dir.h"
23
#include "repository.h"
34
#include "refs.h"
45
#include "object.h"
@@ -283,26 +284,21 @@ static void init_pack_info(const char *infofile, int force)
283284
{
284285
struct packed_git *p;
285286
int stale;
286-
int i = 0;
287+
int i;
288+
size_t alloc = 0;
287289

288290
for (p = get_all_packs(the_repository); p; p = p->next) {
289291
/* we ignore things on alternate path since they are
290292
* not available to the pullers in general.
291293
*/
292-
if (!p->pack_local)
293-
continue;
294-
i++;
295-
}
296-
num_pack = i;
297-
info = xcalloc(num_pack, sizeof(struct pack_info *));
298-
for (i = 0, p = get_all_packs(the_repository); p; p = p->next) {
299-
if (!p->pack_local)
294+
if (!p->pack_local || !file_exists(p->pack_name))
300295
continue;
301-
assert(i < num_pack);
296+
297+
i = num_pack++;
298+
ALLOC_GROW(info, num_pack, alloc);
302299
info[i] = xcalloc(1, sizeof(struct pack_info));
303300
info[i]->p = p;
304301
info[i]->old_num = -1;
305-
i++;
306302
}
307303

308304
if (infofile && !force)

t/t6500-gc.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ test_expect_success 'gc --keep-largest-pack' '
7171
git gc --keep-largest-pack &&
7272
( cd .git/objects/pack && ls *.pack ) >pack-list &&
7373
test_line_count = 2 pack-list &&
74+
awk "/^P /{print \$2}" <.git/objects/info/packs >pack-info &&
75+
test_line_count = 2 pack-info &&
7476
test_path_is_file $BASE_PACK &&
7577
git fsck
7678
)

0 commit comments

Comments
 (0)