Re: Truncating HEAD reflog on branch move
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 22, 2017, 20:32 UTC
- Message-ID
- <xmqqd19vix03.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170622202146.cxrkjca636xl4dgk@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 15 quoted lines
> So I'd be tempted to just ditch the whole thing and teach > get_revision_1() to just walk through the list of logs, rather than this > weird "add a pending commit and then try to figure out which reflog it > referred to". For instance, right now: > > git log -g HEAD $(git symbolic-ref HEAD) > > only shows _one_ reflog. The patch below is the direction I'm thinking. > It fails two tests, but haven't dug yet. > > --- > reflog-walk.c | 112 +++++++++-------------------------- > reflog-walk.h | 4 +- > revision.c | 24 ++++---- > 3 files changed, 43 insertions(+), 97 deletions(-)
Yeah, I agree with the "we now show diffs with true parents" reasoning, and I like the above code reduction, obviously ;-)
Show 27 quoted lines
> @@ -3114,18 +3112,20 @@ static void track_linear(struct rev_info *revs, struct commit *commit)
>
> static struct commit *get_revision_1(struct rev_info *revs)
> {
> + if (revs->reflog_info) {
> + struct commit *commit = next_reflog_entry(revs->reflog_info);
> + if (commit) {
> + commit->object.flags &= ~(ADDED | SEEN | SHOWN);
> + return commit;
> + }
> + }
> +
> if (!revs->commits)
> return NULL;
>
> do {
> struct commit *commit = pop_commit(&revs->commits);
>
> - if (revs->reflog_info) {
> - save_parents(revs, commit);
> - fake_reflog_parent(revs->reflog_info, commit);
> - commit->object.flags &= ~(ADDED | SEEN | SHOWN);
> - }
> -
> /*
> * If we haven't done the list limiting, we need to look at
> * the parents here. We also need to do the date-based limitingThis part of the patch I can 100% agree with ;-)
I do not think command line parser does not allow "log -g maint..master" so all the "limited" processing the remainder of get_revision_1() does shouldn't matter.
I however think pathspec will affect simplify_commit() and suspect that "git log -g -20 HEAD path" will behave differently. Perhaps the difference is "it used to use path in an unexplainable way, now it ignores", in which case this is an improvement.
Thanks.