@matheusbsbs / matheus-bagliano / commits / 6f42f89c1f
Fork 0

server-info.c: drop unused D lines.

We tried to compute pack interdependency information in $GIT_DIR/objects/info/packs, hoping that dumb transports would make use of it when choosing from multiple choice, but that has never materialized, so stop computing D lines for now. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 4, 2005 at 22:52 UTC 6f42f89c1f7030d1101f08bf56d06cc2b6828b83
1 file changed +10 -110
server-info.c
+10 -110
@@ -51,7 +51,6 @@ static struct pack_info {
51 int nr_alloc;
52 int nr_heads;
53 unsigned char (*head)[20];
54 - char dep[0]; /* more */
54 } **info;
55 static int num_pack;
56 static const char *objdir;
@@ -123,49 +122,12 @@ static int parse_pack_def(const char *line, int old_cnt)
122 return 0;
123 }
124 else {
126 - /* The file describes a pack that is no longer here;
127 - * dependencies between packs needs to be recalculated.
128 - */
125 + /* The file describes a pack that is no longer here */
126 return 1;
127 }
128 }
129
133 -/* Returns non-zero when we detect that the info in the
134 - * old file is useless.
135 - */
136 -static int parse_depend_def(char *line)
137 -{
138 - unsigned long num;
139 - char *cp, *ep;
140 - struct pack_info *this, *that;
141 -
142 - cp = line + 2;
143 - num = strtoul(cp, &ep, 10);
144 - if (ep == cp)
145 - return error("invalid input %s", line);
146 - this = find_pack_by_old_num(num);
147 - if (!this)
148 - return 0;
149 - while (ep && *(cp = ep)) {
150 - num = strtoul(cp, &ep, 10);
151 - if (ep == cp)
152 - break;
153 - that = find_pack_by_old_num(num);
154 - if (!that)
155 - /* The pack this one depends on does not
156 - * exist; this should not happen because
157 - * we write out the list of packs first and
158 - * then dependency information, but it means
159 - * the file is useless anyway.
160 - */
161 - return 1;
162 - this->dep[that->new_num] = 1;
163 - }
164 - return 0;
165 -}
166 -
167 -/* Returns non-zero when we detect that the info in the
168 - * old file is useless.
130 +/* Returns non-zero when we detect that the info in the old file is useless.
131 */
132 static int parse_head_def(char *line)
133 {
@@ -212,9 +174,8 @@ static int read_pack_info_file(const char *infofile)
174 if (parse_pack_def(line, old_cnt++))
175 goto out_stale;
176 break;
215 - case 'D': /* D ix dep-ix1 dep-ix2... */
216 - if (parse_depend_def(line))
217 - goto out_stale;
177 + case 'D': /* we used to emit D but that was misguided. */
178 + goto out_stale;
179 break;
180 case 'T': /* T ix sha1 type */
181 if (parse_head_def(line))
@@ -286,7 +247,6 @@ static void init_pack_info(const char *infofile, int force)
247 struct packed_git *p;
248 int stale;
249 int i = 0;
289 - char *dep_temp;
250
251 objdir = get_object_directory();
252 objdirlen = strlen(objdir);
@@ -307,7 +267,7 @@ static void init_pack_info(const char *infofile, int force)
267 if (strncmp(p->pack_name, objdir, objdirlen) ||
268 p->pack_name[objdirlen] != '/')
269 continue;
310 - info[i] = xcalloc(1, sizeof(struct pack_info) + num_pack);
270 + info[i] = xcalloc(1, sizeof(struct pack_info));
271 info[i]->p = p;
272 info[i]->old_num = -1;
273 i++;
@@ -321,41 +281,16 @@ static void init_pack_info(const char *infofile, int force)
281 for (i = 0; i < num_pack; i++) {
282 if (stale) {
283 info[i]->old_num = -1;
324 - memset(info[i]->dep, 0, num_pack);
284 info[i]->nr_heads = 0;
285 }
286 if (info[i]->old_num < 0)
287 info[i]->latest = get_latest_commit_date(info[i]->p);
288 }
289
290 + /* renumber them */
291 qsort(info, num_pack, sizeof(info[0]), compare_info);
292 for (i = 0; i < num_pack; i++)
293 info[i]->new_num = i;
334 -
335 - /* we need to fix up the dependency information
336 - * for the old ones.
337 - */
338 - dep_temp = NULL;
339 - for (i = 0; i < num_pack; i++) {
340 - int old;
341 -
342 - if (info[i]->old_num < 0)
343 - continue;
344 - if (! dep_temp)
345 - dep_temp = xmalloc(num_pack);
346 - memset(dep_temp, 0, num_pack);
347 - for (old = 0; old < num_pack; old++) {
348 - struct pack_info *base;
349 - if (!info[i]->dep[old])
350 - continue;
351 - base = find_pack_by_old_num(old);
352 - if (!base)
353 - die("internal error renumbering");
354 - dep_temp[base->new_num] = 1;
355 - }
356 - memcpy(info[i]->dep, dep_temp, num_pack);
357 - }
358 - free(dep_temp);
294 }
295
296 static void write_pack_info_file(FILE *fp)
@@ -363,17 +298,6 @@ static void write_pack_info_file(FILE *fp)
298 int i, j;
299 for (i = 0; i < num_pack; i++)
300 fprintf(fp, "P %s\n", info[i]->p->pack_name + objdirlen + 6);
366 -
367 - for (i = 0; i < num_pack; i++) {
368 - fprintf(fp, "D %1d", i);
369 - for (j = 0; j < num_pack; j++) {
370 - if ((i == j) || !(info[i]->dep[j]))
371 - continue;
372 - fprintf(fp, " %1d", j);
373 - }
374 - fputc('\n', fp);
375 - }
376 -
301 for (i = 0; i < num_pack; i++) {
302 struct pack_info *this = info[i];
303 for (j = 0; j < this->nr_heads; j++) {
@@ -386,37 +310,18 @@ static void write_pack_info_file(FILE *fp)
310 }
311
312 #define REFERENCED 01
389 -#define INTERNAL 02
313 #define EMITTED 04
314
315 static void show(struct object *o, int pack_ix)
316 {
317 /*
318 * We are interested in objects that are not referenced,
396 - * and objects that are referenced but not internal.
319 */
320 if (o->flags & EMITTED)
321 return;
322
323 if (!(o->flags & REFERENCED))
324 add_head_def(info[pack_ix], o->sha1);
403 - else if ((o->flags & REFERENCED) && !(o->flags & INTERNAL)) {
404 - int i;
405 -
406 - /* Which pack contains this object? That is what
407 - * pack_ix can depend on. We earlier sorted info
408 - * array from youngest to oldest, so try newer packs
409 - * first to favor them here.
410 - */
411 - for (i = num_pack - 1; 0 <= i; i--) {
412 - struct packed_git *p = info[i]->p;
413 - struct pack_entry ent;
414 - if (find_pack_entry_one(o->sha1, &ent, p)) {
415 - info[pack_ix]->dep[i] = 1;
416 - break;
417 - }
418 - }
419 - }
325 o->flags |= EMITTED;
326 }
327
@@ -445,7 +350,7 @@ static void find_pack_info_one(int pack_ix)
350 o->flags = 0;
351 }
352
448 - /* Mark all the internal ones */
353 + /* Mark all the referenced ones */
354 for (i = 0; i < num; i++) {
355 if (nth_packed_object_sha1(p, i, sha1))
356 die("corrupt pack file %s?", p->pack_name);
@@ -457,7 +362,6 @@ static void find_pack_info_one(int pack_ix)
362 for (j = 0; j < refs->count; j++)
363 refs->ref[j]->flags |= REFERENCED;
364 }
460 - o->flags |= INTERNAL;
365 }
366
367 for (i = 0; i < num; i++) {
@@ -465,14 +369,7 @@ static void find_pack_info_one(int pack_ix)
369 die("corrupt pack file %s?", p->pack_name);
370 if ((o = lookup_object(sha1)) == NULL)
371 die("cannot find %s", sha1_to_hex(sha1));
468 -
372 show(o, pack_ix);
470 - if (o->refs) {
471 - struct object_refs *refs = o->refs;
472 - int j;
473 - for (j = 0; j < refs->count; j++)
474 - show(refs->ref[j], pack_ix);
475 - }
373 }
374
375 }
@@ -530,5 +427,8 @@ int update_server_info(int force)
427 errs = errs | update_info_refs(force);
428 errs = errs | update_info_packs(force);
429
430 + /* remove leftover rev-cache file if there is any */
431 + unlink(git_path("info/rev-cache"));
432 +
433 return errs;
434 }