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

Re: [PATCH] git-am: Run git gc only once and not for every patch.

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 4, 2008, 22:00 UTC
Message-ID
<7vmyrli73h.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<477EA06A.5090606@redhat.com>
Michael Stefaniuc <mstefani@redhat.com> writes:
>> What Nico said.
> Not sure if you read my reply to Nico but the reflog is not there for
> deleted branches. Nor for a cleared stash. Common operations where one
> can loose work by mistake.
I am sure you read what Nico pointed out about HEAD reflog.
Show 9 quoted lines
> Nevertheless is there a reason why git gc needs to run after applying
> each patch in git-am? Why can't it run just once at the end? git prune
> is optional and there's no reason to penalize a user that doesn't feel
> safe to run it by cluttering the output of git am/rebase. There is also
> a time penalty: git gc --auto on a pruned tree runs so fast that it
> isn't measurable but on my unpruned wine it took 1.5 seconds. Waiting
> 1.5 seconds per am/rebase is acceptable; wasting 1.5 seconds per patch
> in the mailbox/rebase isn't that much fun if there are more than a
> handful of patches to apply.

"Optional" does not mean "whether you do it or not you will see identical behaviour". Not pruning may slow things down but you may still choose not to prune and suffer the penalty --- that's your choice. But we still produce the correct result (hopefully ;-) --- and that is what "Optional" means.

The message from "gc --auto" may serve as a coalmine canary for you to know when to prune.

I do not think moving "gc --auto" outside the loop hurts in practice because you are not likely to be rebasing a truly huge series every day, but cruft can accumulate during "git am" run and the "gc --auto" inside loop was meant to clean them up. The idea was taken from importers that run repack every once in a while (e.g. cvsimport runs every 1k commits), but "gc --auto" was designed to be much more lightweight than a full repack and that was the reason it was placed in the loop without counting "every N commits".

Previous: Michael StefaniucNext: Junio C Hamano
Message 7 of 9 in “git-am: Run git gc only once and not for every patch.”
  1. git-am: Run git gc only once and not for every patch.Michael Stefaniuc, Jan 4, 2008
  2. Nicolas PitreJan 4, 2008
  3. Michael StefaniucJan 4, 2008
  4. Nicolas PitreJan 4, 2008
  5. Junio C HamanoJan 4, 2008
  6. Michael StefaniucJan 4, 2008
  7. Junio C HamanoJan 4, 2008
  8. Junio C HamanoJan 5, 2008
  9. Michael StefaniucJan 5, 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.