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

Re: git log -g bizarre behaviour

From
Dennis Kaarsemaker <dennis@kaarsemaker.net>
Date
Feb 2, 2016, 08:28 UTC
Message-ID
<1454401738.32711.7.camel@kaarsemaker.net>
In-Reply-To
<xmqqegcwt32j.fsf@gitster.mtv.corp.google.com>
On ma, 2016-02-01 at 15:37 -0800, Junio C Hamano wrote:
Show 26 quoted lines
> Dennis Kaarsemaker <dennis@kaarsemaker.net> writes:
> 
> > I'm attempting to understand the log [-g] / reflog code enough to
> > untangle them and make reflog walking work for more than just
> > commit
> > objects [see gmane 283169]. I found something which I think is
> > wrong,
> > and would break after my changes.
> > 
> > git log -g HEAD^ and git log -g v2.7.0^ give no output. This is
> > expected, as those are not things that have a reflog.
> 
> OK.
> 
> > But git log -g v2.7.0 seems to ignore -g and gives the normal
> > log.
> 
> That sounds clearly broken, and I think I see how that happens from
> the hacky way the "-g" traversal was bolted onto the revision
> traversal machinery.
> 
> I _think_ "git log -g" (and by extension "git reflog" which is just
> a short-hand to giving a few more options to that command) ought to
> 
>  * Iterate over the _objects_ that used to be at the tip of the ref;
>  * Show each of these objects as if they were fed to "git show".

That's what I am trying to achieve. Though not quite like 'git show', I want to emulate the --oneline putput for non-commit objects too.

> This clearly is not possible without major surgery, including
> ripping out the hacky "-g" traversal from the revision traversal
> machinery and perhaps lifting it up a few levels in the callchain,
> as many functions in that callchain want to work on commits.

Yup. I'm planning to either split cmd_log_walk or make its behaviour depend on whether we're traversing the reflog (don't call get_revision, but call a new get_reflog_entry function). And then rip out the reflog handling from revision.c and redo (parts of) reflog-walk.c to accomodate the cmd_log_walk (split|replacement) that deals with reflogs better.

Show 18 quoted lines
> Contrast these two:
> 
>     $ git log -1 v2.7.0
>     $ git show v2.7.0
> 
> > I'd like to make git log -g / git reflog abort early when trying to
> > display a reflog of a ref that has no reflog. Objections?
> 
> Do you mean
> 
> 	$ git checkout -b testing
>         $ rm -f .git/logs/refs/heads/testing
>         $ git log -g testing
> 
> will be changed from a silent no-op to an abort with error?
> 
> I do not see a need for such a change--does that count as an
> objection?
No, I'd like to change:

$ ls .git/logs/refs/tags/v2.7.0 ls: cannot access .git/logs/refs/tags/v2.7.0: No such file or directory $ git (log -g|reflog) v2.7.0

>From the bizarre behaviour above to a silent noop. But before I do that

in a rewrite (by simply not implementing it), I'd like to have that behavior now as well and add tests for it.

-- 
Dennis Kaarsemaker
http://www.kaarsemaker.net
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 10 in “git log -g bizarre behaviour”
  1. Dennis KaarsemakerJan 31, 2016
  2. Junio C HamanoFeb 1, 2016
  3. Dennis KaarsemakerFeb 2, 2016
  4. Junio C HamanoFeb 2, 2016
  5. Dennis KaarsemakerFeb 2, 2016
  6. Junio C HamanoFeb 2, 2016
  7. log -g: ignore revision parameters that have no reflogDennis Kaarsemaker, Feb 2, 2016
  8. Junio C HamanoFeb 3, 2016
  9. Dennis KaarsemakerFeb 3, 2016
  10. Junio C HamanoFeb 3, 2016

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.