Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Add git-relink-script to fix up missing hardlinks

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:00

Not that I think it matters that much anymore since I am
proposing removal of "delta" support and Linus seems to be
inclined in the same direction, but I said "most of the time" in
the earlier message on this same topic for a reason:

    Message-ID: [ref]
    Subject: Re: RFE: git relink
    Date: Fri, 10 Jun 2005 20:44:01 -0700
    References: [ref]

    Whoever is doing this script needs to be a bit careful.

    ...

    Ryan Anderson code will notice delta vs full object case most of
    the time because it checks and makes sure the sizes of
    corresponding files from two repositories match.  The problem
    with the code is that it dies, instead of just ignoring, when
    size differs....

Your latest version has an option not to die which is very good
[*1*], but in a very narrow corner case, without comparing the
file contents, I think the code would still do a wrong thing.
Two trees can store the same object both in delitified form but
based on different base objects, and the deltified
representation still having the same length, no?  And I suspect
you would end up linking them together, corrupting one of the
trees.

Of course, even when you do not have "delta", if an object in
one tree is corrupted (but has the correct size), you would end
up relinking the corrupt one into another tree, nuking a good
copy, if you do not compare the file contents.

If/when/after the proposed removal of "delta" support happens, I
think the correct way to do git-relink-script would be to keep
most of your latest version intact, except:

 (1) make it always die when you see differences in size.
     Without "delta" in the repository, SHA1 files that
     represent the same object must have the same size.

 (2) make --safe also check on file contents.  You do not need
     the flag for the "delta" reason anymore, so I am suggesting
     reusing the flag to detect file corruption, to be extra
     safe, when the user permits you to spend cycles to be more
     careful.

[Footnote]

*1* and other parts of the script all look nicely done.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help