@matheusbsbs / matheus-bagliano / commits / 3e15c67c90
Fork 0

server-info: throw away T computation as well.

Again, dumb transport clients are too dumb to make use of the top objects information to make a choice among multiple packs, so computing these lines are useless for now. We could resurrect them if needed later. Also dumb transport clients presumably can do their own approximation by downloading idx files to see how relevant each pack is for their fetch. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 4, 2005 at 23:12 UTC 3e15c67c90f8eaa655165cf642d0553919a06464
1 file changed +3 -130
server-info.c
+3 -130
@@ -100,16 +100,6 @@ static struct pack_info *find_pack_by_old_num(int old_num)
100 return NULL;
101 }
102
103 -static int add_head_def(struct pack_info *this, unsigned char *sha1)
104 -{
105 - if (this->nr_alloc <= this->nr_heads) {
106 - this->nr_alloc = alloc_nr(this->nr_alloc);
107 - this->head = xrealloc(this->head, this->nr_alloc * 20);
108 - }
109 - memcpy(this->head[this->nr_heads++], sha1, 20);
110 - return 0;
111 -}
112 -
103 /* Returns non-zero when we detect that the info in the
104 * old file is useless.
105 */
@@ -126,30 +116,6 @@ static int parse_pack_def(const char *line, int old_cnt)
116 }
117 }
118
129 -/* Returns non-zero when we detect that the info in the old file is useless.
130 - */
131 -static int parse_head_def(char *line)
132 -{
133 - unsigned char sha1[20];
134 - unsigned long num;
135 - char *cp, *ep;
136 - struct pack_info *this;
137 - struct object *o;
138 -
139 - cp = line + 2;
140 - num = strtoul(cp, &ep, 10);
141 - if (ep == cp || *ep++ != ' ')
142 - return error("invalid input ix %s", line);
143 - this = find_pack_by_old_num(num);
144 - if (!this)
145 - return 1; /* You know the drill. */
146 - if (get_sha1_hex(ep, sha1) || ep[40] != ' ')
147 - return error("invalid input sha1 %s (%s)", line, ep);
148 - if ((o = parse_object_cheap(sha1)) == NULL)
149 - return error("no such object: %s", line);
150 - return add_head_def(this, sha1);
151 -}
152 -
119 /* Returns non-zero when we detect that the info in the
120 * old file is useless.
121 */
@@ -176,9 +142,8 @@ static int read_pack_info_file(const char *infofile)
142 case 'D': /* we used to emit D but that was misguided. */
143 goto out_stale;
144 break;
179 - case 'T': /* T ix sha1 type */
180 - if (parse_head_def(line))
181 - goto out_stale;
145 + case 'T': /* we used to emit T but nobody uses it. */
146 + goto out_stale;
147 break;
148 default:
149 error("unrecognized: %s", line);
@@ -262,100 +227,9 @@ static void init_pack_info(const char *infofile, int force)
227
228 static void write_pack_info_file(FILE *fp)
229 {
265 - int i, j;
230 + int i;
231 for (i = 0; i < num_pack; i++)
232 fprintf(fp, "P %s\n", info[i]->p->pack_name + objdirlen + 6);
268 - for (i = 0; i < num_pack; i++) {
269 - struct pack_info *this = info[i];
270 - for (j = 0; j < this->nr_heads; j++) {
271 - struct object *o = lookup_object(this->head[j]);
272 - fprintf(fp, "T %1d %s %s\n",
273 - i, sha1_to_hex(this->head[j]), o->type);
274 - }
275 - }
276 -
277 -}
278 -
279 -#define REFERENCED 01
280 -#define EMITTED 04
281 -
282 -static void show(struct object *o, int pack_ix)
283 -{
284 - /*
285 - * We are interested in objects that are not referenced,
286 - */
287 - if (o->flags & EMITTED)
288 - return;
289 -
290 - if (!(o->flags & REFERENCED))
291 - add_head_def(info[pack_ix], o->sha1);
292 - o->flags |= EMITTED;
293 -}
294 -
295 -static void find_pack_info_one(int pack_ix)
296 -{
297 - unsigned char sha1[20];
298 - struct object *o;
299 - int i;
300 - struct packed_git *p = info[pack_ix]->p;
301 - int num = num_packed_objects(p);
302 -
303 - /* Scan objects, clear flags from all the edge ones and
304 - * internal ones, possibly marked in the previous round.
305 - */
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);
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;
313 - int j;
314 - for (j = 0; j < refs->count; j++)
315 - refs->ref[j]->flags = 0;
316 - }
317 - o->flags = 0;
318 - }
319 -
320 - /* Mark all the referenced ones */
321 - for (i = 0; i < num; i++) {
322 - if (nth_packed_object_sha1(p, i, sha1))
323 - die("corrupt pack file %s?", p->pack_name);
324 - if ((o = lookup_object(sha1)) == NULL)
325 - die("cannot find %s", sha1_to_hex(sha1));
326 - if (o->refs) {
327 - struct object_refs *refs = o->refs;
328 - int j;
329 - for (j = 0; j < refs->count; j++)
330 - refs->ref[j]->flags |= REFERENCED;
331 - }
332 - }
333 -
334 - for (i = 0; i < num; i++) {
335 - if (nth_packed_object_sha1(p, i, sha1))
336 - die("corrupt pack file %s?", p->pack_name);
337 - if ((o = lookup_object(sha1)) == NULL)
338 - die("cannot find %s", sha1_to_hex(sha1));
339 - show(o, pack_ix);
340 - }
341 -
342 -}
343 -
344 -static void find_pack_info(void)
345 -{
346 - int i;
347 - for (i = 0; i < num_pack; i++) {
348 - /* The packed objects are cast in stone, and a head
349 - * in a pack will stay as head, so is the set of missing
350 - * objects. If the repo has been reorganized and we
351 - * are missing some packs available back then, we have
352 - * already discarded the info read from the file, so
353 - * we will find (old_num < 0) in that case.
354 - */
355 - if (0 <= info[i]->old_num)
356 - continue;
357 - find_pack_info_one(i);
358 - }
233 }
234
235 static int update_info_packs(int force)
@@ -370,7 +244,6 @@ static int update_info_packs(int force)
244 strcpy(name + namelen, "+");
245
246 init_pack_info(infofile, force);
373 - find_pack_info();
247
248 safe_create_leading_directories(name);
249 fp = fopen(name, "w");