Skip to content

Commit 776d668

Browse files
committed
Merge branch 'ew/server-info-remove-crufts' into maint
"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 518e874 + e941c48 commit 776d668

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"
@@ -191,26 +192,21 @@ static void init_pack_info(const char *infofile, int force)
191192
{
192193
struct packed_git *p;
193194
int stale;
194-
int i = 0;
195+
int i;
196+
size_t alloc = 0;
195197

196198
for (p = get_all_packs(the_repository); p; p = p->next) {
197199
/* we ignore things on alternate path since they are
198200
* not available to the pullers in general.
199201
*/
200-
if (!p->pack_local)
201-
continue;
202-
i++;
203-
}
204-
num_pack = i;
205-
info = xcalloc(num_pack, sizeof(struct pack_info *));
206-
for (i = 0, p = get_all_packs(the_repository); p; p = p->next) {
207-
if (!p->pack_local)
202+
if (!p->pack_local || !file_exists(p->pack_name))
208203
continue;
209-
assert(i < num_pack);
204+
205+
i = num_pack++;
206+
ALLOC_GROW(info, num_pack, alloc);
210207
info[i] = xcalloc(1, sizeof(struct pack_info));
211208
info[i]->p = p;
212209
info[i]->old_num = -1;
213-
i++;
214210
}
215211

216212
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)