Skip to content

Commit d5eac49

Browse files
author
Junio C Hamano
committed
server-info: stop sorting packs by latest date.
This does not seem to buy us much, for the same reason as the previous change. Dumb clients are still too dumb. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 6f42f89 commit d5eac49

File tree

1 file changed

+3
-36
lines changed

1 file changed

+3
-36
lines changed

server-info.c

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ static int update_info_refs(int force)
4444

4545
/* packs */
4646
static struct pack_info {
47-
unsigned long latest;
4847
struct packed_git *p;
4948
int old_num;
5049
int new_num;
@@ -193,32 +192,6 @@ static int read_pack_info_file(const char *infofile)
193192
return 1;
194193
}
195194

196-
/* We sort the packs according to the date of the latest commit. That
197-
* in turn indicates how young the pack is, and in general we would
198-
* want to depend on younger packs.
199-
*/
200-
static unsigned long get_latest_commit_date(struct packed_git *p)
201-
{
202-
unsigned char sha1[20];
203-
struct object *o;
204-
int num = num_packed_objects(p);
205-
int i;
206-
unsigned long latest = 0;
207-
208-
for (i = 0; i < num; i++) {
209-
if (nth_packed_object_sha1(p, i, sha1))
210-
die("corrupt pack file %s?", p->pack_name);
211-
if ((o = parse_object_cheap(sha1)) == NULL)
212-
die("cannot parse %s", sha1_to_hex(sha1));
213-
if (o->type == commit_type) {
214-
struct commit *commit = (struct commit *)o;
215-
if (latest < commit->date)
216-
latest = commit->date;
217-
}
218-
}
219-
return latest;
220-
}
221-
222195
static int compare_info(const void *a_, const void *b_)
223196
{
224197
struct pack_info * const* a = a_;
@@ -234,12 +207,8 @@ static int compare_info(const void *a_, const void *b_)
234207
/* The other way around. */
235208
return 1;
236209

237-
if ((*a)->latest < (*b)->latest)
238-
return -1;
239-
else if ((*a)->latest == (*b)->latest)
240-
return 0;
241-
else
242-
return 1;
210+
/* then it does not matter but at least keep the comparison stable */
211+
return (*a)->p - (*b)->p;
243212
}
244213

245214
static void init_pack_info(const char *infofile, int force)
@@ -283,8 +252,6 @@ static void init_pack_info(const char *infofile, int force)
283252
info[i]->old_num = -1;
284253
info[i]->nr_heads = 0;
285254
}
286-
if (info[i]->old_num < 0)
287-
info[i]->latest = get_latest_commit_date(info[i]->p);
288255
}
289256

290257
/* renumber them */
@@ -339,7 +306,7 @@ static void find_pack_info_one(int pack_ix)
339306
for (i = 0; i < num; i++) {
340307
if (nth_packed_object_sha1(p, i, sha1))
341308
die("corrupt pack file %s?", p->pack_name);
342-
if ((o = lookup_object(sha1)) == NULL)
309+
if ((o = parse_object_cheap(sha1)) == NULL)
343310
die("cannot parse %s", sha1_to_hex(sha1));
344311
if (o->refs) {
345312
struct object_refs *refs = o->refs;

0 commit comments

Comments
 (0)