Subject: Re: [Bug] data loss with cyclic alternates

From: Ephrim Khong <[email-masked]>
Date: Sun, 13 Jul 2014 12:44:25 +0200

Am 11.07.14 18:01, schrieb Junio C Hamano:
> Ephrim Khong <[email-masked]> writes:
>
>> git seems to have issues with alternates when cycles are present (repo
>> A has B/objects as alternates, B has A/objects as alternates).
>
> Yeah, don't do that.  A thinks "eh, the other guy must have it" and
> B thinks the same.  In general, do not prune or gc a repository
> other repositories borrow from, even if there is no cycle, because
> the borrowee does not know anythning about objects that it itself no
> longer needs but are still needed by its borrowers.

It seems that there is a safeguard against this in sha1_file.c, 
link_alt_odb_entry(), that doesn't work as intended:

	if (!strcmp(ent->base, objdir)) {
		free(ent);
		return -1;
	}

However, printf-debugging tells me that ent->base is absolute and objdir 
is relative (".git/objects") at this point, so the strings are different 
even though the files are the same.

I never submitted a patch to git. Do you think someone can fix this 
hickup, otherwise I'll give it a shot next week.