git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Michael J Gruber <git@drmicha.warpmail.net>
Cc: josh@joshtriplett.org, git@vger.kernel.org
Subject: Re: Pretty format specifier for commit count?
Date: Thu, 22 Jan 2015 07:52:43 -0500	[thread overview]
Message-ID: <20150122125243.GB19681@peff.net> (raw)
In-Reply-To: <54C0CCA2.3060307@drmicha.warpmail.net>

On Thu, Jan 22, 2015 at 11:10:42AM +0100, Michael J Gruber wrote:

> We do have a linear history when we walk with --first-parent :)

Yes, but I do not think it is robust to adding new commits on top. E.g.,
given:

  A--B--C---F
      \    /
       D--E

a --first-parent walk from F will show F-C-B-A. Now imagine the branch
advances to I:

          G--H---I
         /      /
  A--B--C---F--J
      \    /
       D--E

A walk from I will show I-H-G-C-B-A. F is no longer mentioned at all,
and A, B, and C are now at different positions.

This might be OK in Josh's case. I have an intuition that commits can
only be _removed_ in this case. Which means position from the _top_
might change, but the position from the root will always be the same
(and that is what he wants to be stable).  But I did not think hard
enough to convince myself that this is always the case.

> So, for the changelog for commits "on a branch", where "on a branch" is
> not the git concept but defined by "git rev-list --first-parent" (more
> like hg branches), the count from root would be deterministic and the
> right concept given the appropriate branch workflow.

Certainly the distance to root is deterministic. But I think we are
really counting "number of commits to be output between the root and
this commit". I guess if:

  1. You only ever start from one traversal point.

  2. You are picking only one parent for each merge.

then we know that our queue of commits to examine only ever has 0 or 1
items in it. And therefore a commit is either shown in the same
position from the end, or not shown at all. Because once we get there,
it is deterministic which commits we will show.

> Generation numbers are monotonous but may increase by steps greater than
> 1 on that "branch" if I remember them correctly. I.e., merge commits are
> "weighted" by the number of commits that get merged in.

Sort of. It is the longest distance to (any) root from the commit. So it
is the max() of the generations of the parents, plus one. So for a
simple branch/merge between two lines of development, the increase is
the number of commits that are merged. But a branch that has its own
branches will not increase the generation count by the total number of
commits, but rather by the longest individual sub-branch.

-Peff

      reply	other threads:[~2015-01-22 12:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19  1:29 Pretty format specifier for commit count? Josh Triplett
2015-01-19 13:54 ` Michael J Gruber
2015-01-20  1:17   ` Josh Triplett
2015-01-20 21:49     ` Jeff King
2015-01-20 23:11       ` josh
2015-01-22 10:10         ` Michael J Gruber
2015-01-22 12:52           ` Jeff King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150122125243.GB19681@peff.net \
    --to=peff@peff.net \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=josh@joshtriplett.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).