- n = xmalloc(sizeof(*n) + len - 40);
- memcpy(n->old_sha1, old_sha1, 20);
- memcpy(n->new_sha1, new_sha1, 20);
- memcpy(n->name, buffer + 41, len - 40);
- n->next = ref_list;
- ref_list = n;
+ ref = xmalloc(sizeof(*ref) + len - 40);
+ memcpy(ref->old_sha1, old_sha1, 20);
+ memcpy(ref->new_sha1, new_sha1, 20);
+ memcpy(ref->name, buffer + 41, len - 40);
+ ref->next = NULL;
+ *last_ref = ref;
+ last_ref = &ref->next;
+ }
+
+ for (ref = ref_list; ref; ref = ref->next) {
+ char old_hex[60], *new_hex;
+ strcpy(old_hex, sha1_to_hex(ref->old_sha1));
+ new_hex = sha1_to_hex(ref->new_sha1);
+ packet_write(out, "%s %s %s", old_hex, new_hex, ref->name);
+ fprintf(stderr, "'%s': updating from %s to %s\n", ref->name, old_hex, new_hex);