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

Re: Keeping reflogs on branch deletion

From
Jeff King <peff@peff.net>
Date
Feb 14, 2008, 16:31 UTC
Message-ID
<20080214163101.GA24673@coredump.intra.peff.net>
In-Reply-To
<alpine.LFD.1.00.0802141103280.2732@xanadu.home>
On Thu, Feb 14, 2008 at 11:16:20AM -0500, Nicolas Pitre wrote:
Show 6 quoted lines
> > How is that any different than accumulating old entries in reflog files
> > for branches that _do_ exist? In both cases, they should be dealt with
> > via time-based pruning.
> 
> Branches that do exist are more likely to be interesting to you than 
> branches that, hopefully in 99% of all cases, you willfully deleted.

I agree that they tend to be more interesting, but the point of reflogs is to have a log of operations performed for later examination. We already have a well-defined boundary for "interesting": things that are older than N days. Why introduce another such boundary? Are your reflogs for deleted branches so large that you aren't willing to keep them?

(There is actually one reason I can think of to get rid of reflogs for deleted branches. Branch naming rules depend on which branches exist. Thus I can have "foo/bar" only if "foo" does not exist, which means that I can only have a reflog for "foo/bar" if the one for "foo" has been deleted. But that is a limitation of the current scheme for storing reflogs).

Show 7 quoted lines
> >   1. it's much more convenient to type branch@{1} than to sift through
> >      HEAD's reflog looking for checkout events and guessing which branch
> >      we were on
> 
> Exact.  But that doesn't apply to non existent branches, surely?  And 
> what would you do with the reflog of a deleted branch when a new branch 
> is created with the same name?

I think it does. Reflogs protect against changes in the "commit" space within a ref (things like "git reset HEAD^"). But there is no protection against changes in the "ref" space (like "git branch -D foo").

As for the behavior, I would just append. Your reflog would look like:
  branch@{0} - commit
  branch@{1} - create branch
  branch@{2} - delete branch
  branch@{3} - commit

The behavior would be identical for recently logged items. But instead of there being no branch@{3}, it would go back into the deleted branch.

Show 5 quoted lines
> >   2. it's possible to change a ref without it being on the HEAD, in
> >      which case the HEAD reflog doesn't contain the change.
> 
> And in those cases this can't be due to your own modifications, hence 
> nothing valuable is lost if you then delete that branch.

For one thing, just because a modification wasn't _yours_ doesn't mean it isn't valuable. It entered your repository, and therefore it may be of interest.

Secondly, you _can_ change a ref without it being the HEAD. Try
  git branch -f foo bar
Show 8 quoted lines
> > In other words, I don't see "oops, I deleted this branch and its history
> > is valuable to me" as significantly less likely than "oops, I got rid of
> > this commit and its history is valuable to me."
> 
> But you still have it, in the HEAD reflog, at least for your own 
> changes. I therefore don't see the value of having to keep named branch 
> reflogs around just for the small convenience, especially with the 
> semantic issues that comes with it.

My HEAD reflog has almost 1000 items in it. Finding out which commit would have been branch@{0} in there is non-trivial.

I agree that this information is less likely to be interesting than the usual use of reflogs. But I don't agree that the semantics are that difficult. What issues are you talking about?

-Peff
Previous: Nicolas PitreNext: Nicolas Pitre
Message 11 of 15 in “A couple branch questions”
  1. Jay SoffianFeb 14, 2008
  2. David SymondsFeb 14, 2008
  3. Bill LearFeb 14, 2008
  4. David SymondsFeb 14, 2008
  5. Junio C HamanoFeb 14, 2008
  6. Keeping reflogs on branch deletionBrian Downing, Feb 14, 2008
  7. Nicolas PitreFeb 14, 2008
  8. Johannes SchindelinFeb 14, 2008
  9. Jeff KingFeb 14, 2008
  10. Nicolas PitreFeb 14, 2008
  11. Jeff KingFeb 14, 2008
  12. Nicolas PitreFeb 14, 2008
  13. Jeff KingFeb 14, 2008
  14. Wincent ColaiutaFeb 14, 2008
  15. Jakub NarebskiFeb 14, 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.