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>
Junio C Hamano committed
Dec 4, 2005 at 23:02 UTC
d5eac49868eba3b13d4816b82e99e86ec5ac9eb8
1 file changed
+3
-36
server-info.c
+3
-36
@@ -44,7 +44,6 @@ static int update_info_refs(int force)
44
45
/* packs */
46
static struct pack_info {
47
- unsigned long latest;
47
struct packed_git *p;
48
int old_num;
49
int new_num;
@@ -193,32 +192,6 @@ static int read_pack_info_file(const char *infofile)
192
return 1;
193
}
194
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
-
195
static int compare_info(const void *a_, const void *b_)
196
{
197
struct pack_info * const* a = a_;
@@ -234,12 +207,8 @@ static int compare_info(const void *a_, const void *b_)
207
/* The other way around. */
208
return 1;
209
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;
212
}
213
214
static void init_pack_info(const char *infofile, int force)
@@ -283,8 +252,6 @@ static void init_pack_info(const char *infofile, int force)
252
info[i]->old_num = -1;
253
info[i]->nr_heads = 0;
254
}
286
- if (info[i]->old_num < 0)
287
- info[i]->latest = get_latest_commit_date(info[i]->p);
255
}
256
257
/* renumber them */
@@ -339,7 +306,7 @@ static void find_pack_info_one(int pack_ix)
306
for (i = 0; i < num; i++) {
307
if (nth_packed_object_sha1(p, i, sha1))
308
die("corrupt pack file %s?", p->pack_name);
342
- if ((o = lookup_object(sha1)) == NULL)
309
+ if ((o = parse_object_cheap(sha1)) == NULL)
310
die("cannot parse %s", sha1_to_hex(sha1));
311
if (o->refs) {
312
struct object_refs *refs = o->refs;