Re: should git download missing objects?
From: Alex Riesen <hidden>
Date: 2016-08-11 19:49:56
Junio C Hamano, Mon, Nov 13, 2006 21:05:48 +0100:
quoted
Junio C Hamano, Sun, Nov 12, 2006 20:41:23 +0100:quoted
Since this is not everyday anyway, a far easier way would be to clone-pack from the upstream into a new repository, take the pack you downloaded from that new repository and mv it into your corrupt repository. You can run fsck-objects to see if you got back everything you lost earlier.I get into such a situation annoyingly often, by using "git clone -l -s from to" and doing some "cleanup" in the origin repository. For example, it happens that I remove a tag, or a branch, and do a repack or prune afterwards. The related repositories, which had "accidentally" referenced the pruned objects become "corrupt", as you put it. At the moment, if I run into the situation, I copy packs/objects from all repos I have (objects/info/alternates are useful here too), run a fsck-objects/repack and hope nothing is lost. It works, as I almost always have "accidental" backups somewhere, but is kind of annoying to setup. A tool to do this job more effectively will be very handy (at least, it wont have to copy gigabytes of data over switched windows network. Not often, I hope. Not _so_ many gigabytes, possibly).I suspect it is a different issue. Maybe you would need reverse links from the origin directory to .git/refs/ directroy of repositories that borrow from it to prevent pruning. No amount of butchering fetch-pack to look behind incomplete refs that lie and claim they are complete would solve your problem if you do not have any "accidental backups".
It's is not about preventing this from happening. It is about recovering from user error (which I plainly did). The discussion about "git fetch --recover" sound very much like what would helped in that situation. I'll just try not doing it next time, but if I do, it'd be nice to have a tool to help me recover from it. Not prevent, not seeing it possible, just help. Anyway, it's kind of too late for that repositories. And not very convenient to work with: the branches in the slave repos come and go often, they pull from each other and push into central (aka origin) repo. Maintain the borrowed refs in sync would be nightmare (as is: "I promise to forget doing it").