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

Re: [RFC] git reflog show

From
Junio C Hamano <junkio@cox.net>
Date
Dec 24, 2006, 21:47 UTC
Message-ID
<7v1wmpq83g.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0612241333280.19693@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 5 quoted lines
> Yes, but if we have to read the reflog anyway to determine the logical 
> (local) parent, we can just as well read the message, and display it, too.
>
> What it buys us is that we do not duplicate efforts here, and we can 
> easily visualize the reflog in gitk, too.
I do not think you can sanely rewrite parenthood.
Think about this sequence
	$ git init-db; edit foo; git add foo
	$ git commit -m 'first'
	$ edit foo; git add foo
        $ git commit -m 'second'
        $ git reset --hard HEAD@{1}
At this point, the commits on the reflog are:
        $ git show-branch --reflog=3 HEAD
        ! [HEAD@{0}] first
         ! [HEAD@{1}] second
          ! [HEAD@{2}] first
        ---
         +  [HEAD@{1}] second
        +++ [HEAD@{0}] first

We are currently at the first commit, and its "rewritten" parent should point at the second commit (i.e. pretend HEAD@{1} is the parent of HEAD@{0}). The "rewritten" parent of the second commit should be HEAD@{2}, but that is actually the same first commit which is HEAD@{0}.

Also I highly doubt visualization based on parents information rewritten to match the reflog order is of _any_ use. By rewriting the parenthood, you are losing the topology and your visualization is no better than what "tac .git/logs/$ref" would give.

I do agree that reusing the message formattng and display code from the usual log machinery is desirable. I think you can hook that information somewhere in object->util (or a callback mechanism) and teach log display machinery to use it as a generic mechanism. That might make the existing code to insert "Subject: " for --pretty=format simpler, but I haven't looked.

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 6 of 14 in “[RFC] git reflog show”
  1. Shawn PearceDec 23, 2006
  2. Junio C HamanoDec 23, 2006
  3. Johannes SchindelinDec 23, 2006
  4. Shawn PearceDec 24, 2006
  5. Johannes SchindelinDec 24, 2006
  6. Junio C HamanoDec 24, 2006
  7. Johannes SchindelinDec 25, 2006
  8. Junio C HamanoDec 25, 2006
  9. Shawn PearceDec 26, 2006
  10. Junio C HamanoDec 26, 2006
  11. Johannes SchindelinDec 26, 2006
  12. Junio C HamanoDec 26, 2006
  13. Johannes SchindelinDec 26, 2006
  14. Junio C HamanoDec 26, 2006

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.