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

Re: git gc & deleted branches

From
JMJeremy Maitin-Shepard <jbms@cmu.edu>
Date
May 10, 2008, 01:51 UTC
Message-ID
<87y76jx6y4.fsf@jeremyms.com>
In-Reply-To
<7vskwr9coz.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
>> Jeremy Maitin-Shepard <jbms@cmu.edu> wrote:
>>> It is extremely cumbersome to have to worry about whether there are
>>> other concurrent accesses to the repository when running e.g. git gc.
>>> For servers, you may never be able to guarantee that nothing else is
>>> accessing the repository concurrently.  Here is a possible solution:
>>> 
>>> Each git process creates a log file of the references that it has
>>> created.  The log file should be named in some way with e.g. the process
>>> id and start time of the process, and simply consist of a list of
>>> 20-byte sha1 hashes to be considered additional in-use references for
>>> the purpose of garbage collection.
> How would that solve the issue that you should not prune/gc the repository
> "clone --shared" aka "alternates" borrows from?

The log files are only for handling in-progress commands editing the repository. I also describe in first part of the e-mail a possible solution to that issue as well as the issues created by having multiple working directories:

When you create a new working directory, you would also create in the original repository a symlink named e.g. orig_repo/.git/peers/<some-arbitrary-name-that-doesn't-matter> that points to the .git directory of the newly created working directory. git clone -shared would likewise create such a link in the original repository. There could be a separate simple command to "destroy" a repository created via clone -shared or via new-work-dir that would simply remove this "peer" symlink from any repositories it shares from, and then rm -rf the target repository. The list of repositories that a given target repository shares from would be discovered using perhaps several different methods, depending on whether it is a new work dir, an actual separate repository, or the new type of "shared" repository I suggested in my original e-mail, namely one that has its own refs but completely shares the object store of the original repository, e.g. via a symlink to the original repository's objects directory In any case, I believe the information to go "upstream" is already available, and we just need to add those "peer" symlinks in order to be able to go "downstream".

There could also be a simple git command to move a repository that would take care of updating all of the references that other repositories have to it. Currently it is not possible to write such a command, because the "downstream" links are not stored, but with these added symlinks it would be possible.

As I said in my previous e-mail, if git gc finds any broken symlinks (i.e. symlinks that point to invalid repositories), it would error out, because user attention is required to specify whether the symlinks correspond to deleted repositories, or to repositories that have been moved without making the proper updates.

Show 5 quoted lines
> By the way, I do not think your "git-commit stopped for two weeks due to a
> long editing session of the commit message" should result in any object
> lossage, as the new objects are all reachable from the index, and the new
> tree nor the new commit hasn't been built while you are typing (rather,
> not typing) the log message.
> Hmm, a partial commit that uses a temporary index file may lose, come to
> think of it.  Perhaps we should teach reachable.c about the temporary
> index file as well.  I dunno.

Well, providing a generic mechanism for telling git about reachable things other than the index and refs is precisely what these log files would do, and also because they would record the process id and a timestamp, stale log files would automatically get cleaned up. If each individual git command has its own special way of trying to keep track of temporary references, it is just going to be more complicated and more error prone.

-- 
Jeremy Maitin-Shepard
Previous: Junio C HamanoNext: Jeff King
Message 39 of 50 in “git gc & deleted branches”
  1. Guido OstkampMay 8, 2008
  2. Jeff KingMay 8, 2008
  3. Guido OstkampMay 8, 2008
  4. Brandon CaseyMay 8, 2008
  5. Guido OstkampMay 8, 2008
  6. Jeff KingMay 8, 2008
  7. Nicolas PitreMay 8, 2008
  8. Jeff KingMay 8, 2008
  9. Brandon CaseyMay 8, 2008
  10. Jeff KingMay 8, 2008
  11. Brandon CaseyMay 8, 2008
  12. Jeff KingMay 8, 2008
  13. Brandon CaseyMay 8, 2008
  14. Jeff KingMay 8, 2008
  15. Brandon CaseyMay 9, 2008
  16. Junio C HamanoMay 9, 2008
  17. 0/3 leave unreferenced objects unpackeddrafnel@gmail.com, May 10, 2008
  18. 1/3 repack: modify behavior of -A option to leave unreferenced objects unpackeddrafnel@gmail.com, May 10, 2008
  19. Jeff KingMay 10, 2008
  20. Nicolas PitreMay 11, 2008
  21. Junio C HamanoMay 11, 2008
  22. Brandon CaseyMay 11, 2008
  23. Brandon CaseyMay 11, 2008
  24. 2/3 git-gc: always use -A when manually repackingdrafnel@gmail.com, May 10, 2008
  25. 3/3 builtin-gc.c: deprecate --prune, it now really has no effectdrafnel@gmail.com, May 10, 2008
  26. Jeff KingMay 9, 2008
  27. Geert BoschMay 9, 2008
  28. Brandon CaseyMay 9, 2008
  29. Jeff KingMay 9, 2008
  30. Brandon CaseyMay 9, 2008
  31. Nicolas PitreMay 9, 2008
  32. Brandon CaseyMay 9, 2008
  33. Junio C HamanoMay 9, 2008
  34. Updating documentation to match Brandon Casey's proposed git-repack patch.Chris Frey, May 9, 2008
  35. Jeremy Maitin-ShepardMay 10, 2008
  36. Shawn O. PearceMay 10, 2008
  37. Jeremy Maitin-ShepardMay 10, 2008
  38. Junio C HamanoMay 10, 2008
  39. Jeremy Maitin-ShepardMay 10, 2008
  40. Jeff KingMay 10, 2008
  41. Jeremy Maitin-ShepardMay 10, 2008
  42. Johannes SchindelinMay 10, 2008
  43. Jeremy Maitin-ShepardMay 10, 2008
  44. Johannes SchindelinMay 11, 2008
  45. Junio C HamanoMay 11, 2008
  46. Guido OstkampMay 8, 2008
  47. Jeff KingMay 8, 2008
  48. Jeff KingMay 8, 2008
  49. Brandon CaseyMay 10, 2008
  50. Brandon CaseyMay 10, 2008

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.