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

Re: [PATCH] log: use true parents for diff when walking reflogs

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 5, 2013, 19:16 UTC
Message-ID
<7vd2psj6dq.fsf@alter.siamese.dyndns.org>
In-Reply-To
<d6dadc4ab54d81490ca46bcfbd44a61be24f6eb7.1375524982.git.trast@inf.ethz.ch>
Thomas Rast <trast@inf.ethz.ch> writes:
Show 29 quoted lines
> The reflog walking logic (git log -g) replaces the true parent list
> with the preceding commit in the reflog.  This results in bogus commit
> diffs when combined with options such as -p; the diff is against the
> reflog predecessor, not the parent of the commit.
>
> Save the true parents on the side, extending the functions from the
> previous commit.  The diff logic picks them up and uses them to show
> the correct diffs.
>
> We do have to be somewhat careful about repeated calling of
> save_parents(), since the reflog may list a commit more than once.  We
> now store (commit_list*)-1 to distinguish the "not saved yet" and
> "root commit" cases.  This lets us preserve an empty parent list even
> if save_parents() is repeatedly called.
>
> Suggested-by: Jeff King <peff@peff.net>
> Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
> ---
>
> Jeff King <peff@peff.net> wrote:
>> 
>> Your description (and solution) make a lot of sense to me. Another code
>> path that has a similar problem is the "-g" reflog walker. It rewrites
>> the parents based on the reflog, and the diffs it produces are mostly
>> useless (e.g., try "git stash list -p").
>> 
>> Should we be applying the same technique there?
>
> Good point.  This is how.  It applies on top of the other patch.
Thanks.
> It doesn't really help for 'git stash list -p', though, because
> stashes are merge commits.  Now they just don't show anything.
> could try 'git stash list -p -m', though.
Using --first-parent may be more convenient and useful.
Previous: Thomas Rast
Message 3 of 3 in “log: use true parents for diff when walking reflogs”
  1. log: use true parents for diff when walking reflogsThomas Rast, Aug 3, 2013
  2. Thomas RastAug 3, 2013
  3. Junio C HamanoAug 5, 2013

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.