git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Potentially dangerous behavior of git gc

From
Sergio Callegari <sergio.callegari@gmail.com>
Date
Oct 19, 2009, 08:04 UTC
Message-ID
<loom.20091019T095725-840@post.gmane.org>
Hi,
I encountered an issue with git gc.

Consider the following scenario. Repo A is using repo B as an alternate object database through the .git/objects/info/alternates mechanism. B is at /some_path/B. A has some references, including HEAD that are pointing at objects that are in fact in the object database of B.

For some reasons, paths are modified on the machine, so that B gets moved at /some_new_path/B.

Obviously A cannot find its objects anymore and its alternate info should be updated.

Suppose that now one runs git gc on A.

Correctly git gc complains about the broken alternate link. And then complains again as it cannot find some objects.

However, rather than trying to preserve the repo integrity, it then _removes_ all the references pointing to non existing objects.

With this when the alternate info of A is finally updated, A is broken, missing many references and not having a head anymore.

Would it be better to have git gc not to take dangerous actions on potentially problematic repos?

Thanks
Sergio
Next: Miklos Vajna
Message 1 of 3 in “Potentially dangerous behavior of git gc”
  1. Sergio CallegariOct 19, 2009
  2. Miklos VajnaOct 19, 2009
  3. SergioOct 20, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.